Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / function-attr.cpp
blob4c002114c20f8864118fbc6850739f4b6c0e90a9
1 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -stack-protector 2 -emit-llvm -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -stack-protector 2 -emit-llvm -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
4 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
6 // Check that function attributes are added to the OpenMP runtime functions.
8 template <class T>
9 struct S {
10 T f;
11 S(T a) : f(a) {}
12 S() : f() {}
13 operator T() { return T(); }
14 ~S() {}
17 // CHECK: define internal void @.omp.copyprivate.copy_func(ptr noundef %0, ptr noundef %1) [[ATTR0:#[0-9]+]] {
19 void foo0();
21 int foo1() {
22 char a;
24 #pragma omp parallel
25 a = 2;
26 #pragma omp single copyprivate(a)
27 foo0();
29 return 0;
32 // CHECK: define internal void @.omp_task_privates_map.({{.*}}) [[ATTR3:#[0-9]+]] {
33 // CHECK: define internal noundef i32 @.omp_task_entry.({{.*}}) [[ATTR0]] {
34 // CHECK: define internal noundef i32 @.omp_task_destructor.({{.*}}) [[ATTR0]] {
36 int foo2() {
37 S<double> s_arr[] = {1, 2};
38 S<double> var(3);
39 #pragma omp task private(s_arr, var)
40 s_arr[0] = var;
41 return 0;
44 // CHECK: define internal void @_Z4foo3iPfS_.omp_outlined.omp.reduction.reduction_func(ptr noundef %0, ptr noundef %1) [[ATTR0]] {
46 float foo3(int n, float *a, float *b) {
47 int i;
48 float result;
50 #pragma omp parallel for private(i) reduction(+:result)
51 for (i=0; i < n; i++)
52 result = result + (a[i] * b[i]);
53 return result;
56 // CHECK: attributes [[ATTR0]] = {{{.*}} sspstrong {{.*}}}
57 // CHECK: attributes [[ATTR3]] = {{{.*}} sspstrong {{.*}}}