1// clang-format off
2// RUN: %libomptarget-compileoptxx-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-compileoptxx-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
17extern "C" {
18void *llvm_omp_target_alloc_shared(size_t Size, int DeviceNum);
19void llvm_omp_target_free_host(void *Ptr, int DeviceNum);
20}
21
22int main(void) {
23 void *P = llvm_omp_target_alloc_shared(8, 0);
24 llvm_omp_target_free_host(Ptr: P, DeviceNum: 0);
25}
26
27// clang-format off
28// CHECK: OFFLOAD ERROR: deallocation requires pinned host memory but allocation was managed memory: 0x
29// CHECK: dataDelete
30// CHECK: llvm_omp_target_free_host
31// NDEBG: main
32// DEBUG: main {{.*}}free_wrong_ptr_kind.cpp:25
33//
34// CHECK: Last allocation of size 8 -> device pointer
35// CHECK: dataAlloc
36// CHECK: llvm_omp_target_alloc_shared
37// NDEBG: main
38// DEBUG: main {{.*}}free_wrong_ptr_kind.cpp:24
39

source code of offload/test/sanitizer/free_wrong_ptr_kind.cpp