[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / target_data_no_device_codegen.cpp
blob3ebe34c0fb943249b71e1aee8b8f95c2a3dcca01
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
2 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -emit-llvm -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -fopenmp -triple x86_64-apple-darwin10 -x c++ -std=c++11 -emit-pch -o %t %s
4 // RUN: %clang_cc1 -fopenmp -triple x86_64-apple-darwin10 -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
6 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -emit-llvm -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
7 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-apple-darwin10 -x c++ -std=c++11 -emit-pch -o %t %s
8 // RUN: %clang_cc1 -fopenmp-simd -triple x86_64-apple-darwin10 -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
9 // expected-no-diagnostics
11 #ifndef HEADER
12 #define HEADER
14 template <int T> class A {
15 double *ptr = nullptr;
17 public:
18 void foo() {
19 #pragma omp target data use_device_ptr(ptr)
20 { double *capture = ptr; }
24 template class A<0>;
25 #endif // HEADER
26 // CHECK-LABEL: define {{[^@]+}}@_ZN1AILi0EE3fooEv
27 // CHECK-SAME: (ptr noundef nonnull align 8 dereferenceable(8) [[THIS:%.*]]) #[[ATTR0:[0-9]+]] align 2 {
28 // CHECK-NEXT: entry:
29 // CHECK-NEXT: [[THIS_ADDR:%.*]] = alloca ptr, align 8
30 // CHECK-NEXT: [[PTR:%.*]] = alloca ptr, align 8
31 // CHECK-NEXT: [[CAPTURE:%.*]] = alloca ptr, align 8
32 // CHECK-NEXT: store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
33 // CHECK-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
34 // CHECK-NEXT: [[PTR2:%.*]] = getelementptr inbounds nuw [[CLASS_A:%.*]], ptr [[THIS1]], i32 0, i32 0
35 // CHECK-NEXT: store ptr [[PTR2]], ptr [[PTR]], align 8
36 // CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[PTR]], align 8
37 // CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[TMP0]], align 8
38 // CHECK-NEXT: store ptr [[TMP1]], ptr [[CAPTURE]], align 8
39 // CHECK-NEXT: ret void
42 // SIMD-ONLY0-LABEL: define {{[^@]+}}@_ZN1AILi0EE3fooEv
43 // SIMD-ONLY0-SAME: (ptr noundef nonnull align 8 dereferenceable(8) [[THIS:%.*]]) #[[ATTR0:[0-9]+]] align 2 {
44 // SIMD-ONLY0-NEXT: entry:
45 // SIMD-ONLY0-NEXT: [[THIS_ADDR:%.*]] = alloca ptr, align 8
46 // SIMD-ONLY0-NEXT: [[PTR:%.*]] = alloca ptr, align 8
47 // SIMD-ONLY0-NEXT: [[TMP:%.*]] = alloca ptr, align 8
48 // SIMD-ONLY0-NEXT: [[CAPTURE:%.*]] = alloca ptr, align 8
49 // SIMD-ONLY0-NEXT: store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
50 // SIMD-ONLY0-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
51 // SIMD-ONLY0-NEXT: [[PTR2:%.*]] = getelementptr inbounds nuw [[CLASS_A:%.*]], ptr [[THIS1]], i32 0, i32 0
52 // SIMD-ONLY0-NEXT: store ptr [[PTR2]], ptr [[PTR]], align 8
53 // SIMD-ONLY0-NEXT: [[TMP0:%.*]] = load ptr, ptr [[PTR]], align 8
54 // SIMD-ONLY0-NEXT: store ptr [[TMP0]], ptr [[TMP]], align 8
55 // SIMD-ONLY0-NEXT: [[TMP1:%.*]] = load ptr, ptr [[TMP]], align 8
56 // SIMD-ONLY0-NEXT: [[TMP2:%.*]] = load ptr, ptr [[TMP1]], align 8
57 // SIMD-ONLY0-NEXT: store ptr [[TMP2]], ptr [[CAPTURE]], align 8
58 // SIMD-ONLY0-NEXT: ret void