| 1 | // clang-format off |
| 2 | // RUN: %libomptarget-compileopt-generic |
| 3 | // RUN: %not --crash env -u LLVM_DISABLE_SYMBOLIZATION OFFLOAD_TRACK_ALLOCATION_TRACES=1 %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefixes=CHECK,NDEBG |
| 4 | // RUN: %libomptarget-compileopt-generic -g |
| 5 | // RUN: %not --crash env -u LLVM_DISABLE_SYMBOLIZATION OFFLOAD_TRACK_ALLOCATION_TRACES=1 %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefixes=CHECK,DEBUG |
| 6 | // clang-format on |
| 7 | |
| 8 | // UNSUPPORTED: aarch64-unknown-linux-gnu |
| 9 | // UNSUPPORTED: aarch64-unknown-linux-gnu-LTO |
| 10 | // UNSUPPORTED: x86_64-unknown-linux-gnu |
| 11 | // UNSUPPORTED: x86_64-unknown-linux-gnu-LTO |
| 12 | // UNSUPPORTED: s390x-ibm-linux-gnu |
| 13 | // UNSUPPORTED: s390x-ibm-linux-gnu-LTO |
| 14 | |
| 15 | #include <omp.h> |
| 16 | |
| 17 | int main(void) { |
| 18 | void *Ptr1 = omp_target_alloc(8, 0); |
| 19 | omp_target_free(Ptr1, 0); |
| 20 | void *Ptr2 = omp_target_alloc(8, 0); |
| 21 | omp_target_free(Ptr2, 0); |
| 22 | void *Ptr3 = omp_target_alloc(8, 0); |
| 23 | omp_target_free(Ptr3, 0); |
| 24 | omp_target_free(Ptr2, 0); |
| 25 | } |
| 26 | |
| 27 | // CHECK: OFFLOAD ERROR: double-free of device memory: 0x |
| 28 | // CHECK: dataDelete |
| 29 | // CHECK: omp_target_free |
| 30 | // NDEBG: main |
| 31 | // DEBUG: main {{.*}}double_free.c:25 |
| 32 | // |
| 33 | // CHECK: Last deallocation: |
| 34 | // CHECK: dataDelete |
| 35 | // CHECK: omp_target_free |
| 36 | // NDEBG: main |
| 37 | // DEBUG: main {{.*}}double_free.c:24 |
| 38 | // |
| 39 | // CHECK: Last allocation of size 8 -> device pointer |
| 40 | // CHECK: dataAlloc |
| 41 | // CHECK: omp_target_alloc |
| 42 | // NDEBG: main |
| 43 | // DEBUG: main {{.*}}double_free.c:23 |
| 44 | // |
| 45 | // CHECK: Prior allocations with the same base pointer: |
| 46 | // CHECK: #0 Prior deallocation of size 8: |
| 47 | // CHECK: dataDelete |
| 48 | // CHECK: omp_target_free |
| 49 | // NDEBG: main |
| 50 | // DEBUG: main {{.*}}double_free.c:22 |
| 51 | // |
| 52 | // CHECK: #0 Prior allocation -> device pointer |
| 53 | // CHECK: dataAlloc |
| 54 | // CHECK: omp_target_alloc |
| 55 | // NDEBG: main |
| 56 | // DEBUG: main {{.*}}double_free.c:20 |
| 57 | // |
| 58 | // CHECK: #1 Prior deallocation of size 8: |
| 59 | // CHECK: dataDelete |
| 60 | // CHECK: omp_target_free |
| 61 | // NDEBG: main |
| 62 | // DEBUG: main {{.*}}double_free.c:20 |
| 63 | // |
| 64 | // CHECK: #1 Prior allocation -> device pointer |
| 65 | // CHECK: dataAlloc |
| 66 | // CHECK: omp_target_alloc |
| 67 | // NDEBG: main |
| 68 | // DEBUG: main {{.*}}double_free.c:19 |
| 69 | |