1 // RUN: %clang_cc1 -verify -fopenmp -x c -emit-llvm %s -triple %itanium_abi_triple -o - -femit-all-decls -disable-llvm-passes | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -x c -triple %itanium_abi_triple -emit-pch -o %t %s -femit-all-decls -disable-llvm-passes
3 // RUN: %clang_cc1 -fopenmp -x c -triple %itanium_abi_triple -include-pch %t -verify %s -emit-llvm -o - -femit-all-decls -disable-llvm-passes | FileCheck --check-prefix=CHECK-LOAD %s
5 // RUN: %clang_cc1 -fopenmp -x c -triple %itanium_abi_triple -emit-pch -o %t %s -femit-all-decls -disable-llvm-passes -fopenmp-version=45
6 // RUN: %clang_cc1 -fopenmp -x c -triple %itanium_abi_triple -include-pch %t -verify %s -emit-llvm -o - -femit-all-decls -disable-llvm-passes -fopenmp-version=45 | FileCheck --check-prefixes=CHECK-LOAD,OMP45-LOAD %s
8 // RUN: %clang_cc1 -verify -fopenmp-simd -x c -emit-llvm %s -triple %itanium_abi_triple -o - -femit-all-decls -disable-llvm-passes | FileCheck --check-prefix SIMD-ONLY0 %s
9 // RUN: %clang_cc1 -fopenmp-simd -x c -triple %itanium_abi_triple -emit-pch -o %t %s -femit-all-decls -disable-llvm-passes
10 // RUN: %clang_cc1 -fopenmp-simd -x c -triple %itanium_abi_triple -include-pch %t -verify %s -emit-llvm -o - -femit-all-decls -disable-llvm-passes | FileCheck --check-prefix SIMD-ONLY0 %s
11 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
12 // expected-no-diagnostics
17 // CHECK: [[SSS_INT:.+]] = type { i32 }
18 // CHECK-LOAD: [[SSS_INT:.+]] = type { i32 }
20 // CHECK-DAG: [[SSS_INIT:@.+]] = private constant %struct.SSS zeroinitializer
21 // CHECK-DAG: [[INT_INIT:@.+]] = private constant i32 0
23 #pragma omp declare reduction(+ : int, char : omp_out *= omp_in)
24 // CHECK: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
25 // CHECK: [[MUL:%.+]] = mul nsw i32
26 // CHECK-NEXT: store i32 [[MUL]], ptr
27 // CHECK-NEXT: ret void
29 // CHECK-LOAD: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
30 // CHECK-LOAD: [[MUL:%.+]] = mul nsw i32
31 // CHECK-LOAD-NEXT: store i32 [[MUL]], ptr
32 // CHECK-LOAD-NEXT: ret void
35 // CHECK: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
38 // CHECK: [[MUL:%.+]] = mul nsw i32
39 // CHECK-NEXT: [[TRUNC:%.+]] = trunc i32 [[MUL]] to i8
40 // CHECK-NEXT: store i8 [[TRUNC]], ptr
41 // CHECK-NEXT: ret void
43 // CHECK-LOAD: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
44 // CHECK-LOAD: sext i8
45 // CHECK-LOAD: sext i8
46 // CHECK-LOAD: [[MUL:%.+]] = mul nsw i32
47 // CHECK-LOAD-NEXT: [[TRUNC:%.+]] = trunc i32 [[MUL]] to i8
48 // CHECK-LOAD-NEXT: store i8 [[TRUNC]], ptr
49 // CHECK-LOAD-NEXT: ret void
52 #pragma omp declare reduction(fun : float : omp_out += omp_in) initializer(omp_priv = 15 + omp_orig)
53 // CHECK: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
54 // CHECK: [[ADD:%.+]] = fadd float
55 // CHECK-NEXT: store float [[ADD]], ptr
56 // CHECK-NEXT: ret void
58 // CHECK: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
59 // CHECK: [[ADD:%.+]] = fadd float 1.5
60 // CHECK-NEXT: store float [[ADD]], ptr
61 // CHECK-NEXT: ret void
63 // CHECK-LOAD: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
64 // CHECK-LOAD: [[ADD:%.+]] = fadd float
65 // CHECK-LOAD-NEXT: store float [[ADD]], ptr
66 // CHECK-LOAD-NEXT: ret void
68 // CHECK-LOAD: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
69 // CHECK-LOAD: [[ADD:%.+]] = fadd float 1.5
70 // CHECK-LOAD-NEXT: store float [[ADD]], ptr
71 // CHECK-LOAD-NEXT: ret void
76 #pragma omp declare reduction(+ : int, char : omp_out *= omp_in)
77 // CHECK: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
78 // CHECK: [[MUL:%.+]] = mul nsw i32
79 // CHECK-NEXT: store i32 [[MUL]], ptr
80 // CHECK-NEXT: ret void
83 // CHECK: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
86 // CHECK: [[MUL:%.+]] = mul nsw i32
87 // CHECK-NEXT: [[TRUNC:%.+]] = trunc i32 [[MUL]] to i8
88 // CHECK-NEXT: store i8 [[TRUNC]], ptr
89 // CHECK-NEXT: ret void
93 void init(struct SSS
*priv
, struct SSS orig
);
95 #pragma omp declare reduction(fun : struct SSS : omp_out = omp_in) initializer(init(&omp_priv, omp_orig))
96 // CHECK: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
97 // CHECK: call void @llvm.memcpy
98 // CHECK-NEXT: ret void
100 // CHECK: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
101 // CHECK: call void @init(
102 // CHECK-NEXT: ret void
104 // CHECK-LOAD: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
105 // CHECK-LOAD: call void @llvm.memcpy
106 // CHECK-LOAD-NEXT: ret void
107 // CHECK-LOAD-NEXT: }
108 // CHECK-LOAD: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
109 // CHECK-LOAD: call void @init(
110 // CHECK-LOAD-NEXT: ret void
111 // CHECK-LOAD-NEXT: }
113 // CHECK-LABEL: @main
114 // CHECK-LOAD-LABEL: @main
116 #pragma omp declare reduction(fun : struct SSS : omp_out = omp_in) initializer(init(&omp_priv, omp_orig))
117 // CHECK: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
118 // CHECK: call void @llvm.memcpy
119 // CHECK-NEXT: ret void
121 // CHECK: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
122 // CHECK: call void @init(
123 // CHECK-NEXT: ret void
125 // CHECK-LOAD: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
126 // CHECK-LOAD: call void @llvm.memcpy
127 // CHECK-LOAD-NEXT: ret void
128 // CHECK-LOAD-NEXT: }
129 // CHECK-LOAD: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
130 // CHECK-LOAD: call void @init(
131 // CHECK-LOAD-NEXT: ret void
132 // CHECK-LOAD-NEXT: }
134 #pragma omp declare reduction(fun : struct SSS : omp_out = omp_in) initializer(init(&omp_priv, omp_orig))
135 // CHECK: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
136 // CHECK: call void @llvm.memcpy
137 // CHECK-NEXT: ret void
139 // CHECK: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
140 // CHECK: call void @init(
141 // CHECK-NEXT: ret void
143 // CHECK-LOAD: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
144 // CHECK-LOAD: call void @llvm.memcpy
145 // CHECK-LOAD-NEXT: ret void
146 // CHECK-LOAD-NEXT: }
147 // CHECK-LOAD: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
148 // CHECK-LOAD: call void @init(
149 // CHECK-LOAD-NEXT: ret void
150 // CHECK-LOAD-NEXT: }
155 // OMP45-LOAD: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
156 // OMP45-LOAD: [[MUL:%.+]] = mul nsw i32
157 // OMP45-LOAD-NEXT: store i32 [[MUL]], ptr
158 // OMP45-LOAD-NEXT: ret void
159 // OMP45-LOAD-NEXT: }
161 // OMP45-LOAD: define internal {{.*}}void @{{[^(]+}}(ptr noalias noundef %0, ptr noalias noundef %1)
162 // OMP45-LOAD: sext i8
163 // OMP45-LOAD: sext i8
164 // OMP45-LOAD: [[MUL:%.+]] = mul nsw i32
165 // OMP45-LOAD-NEXT: [[TRUNC:%.+]] = trunc i32 [[MUL]] to i8
166 // OMP45-LOAD-NEXT: store i8 [[TRUNC]], ptr
167 // OMP45-LOAD-NEXT: ret void
168 // OMP45-LOAD-NEXT: }
174 // CHECK: [[SS_PRIV:%.+]] = alloca %struct.SSS,
175 // CHECK: [[IN_PRIV:%.+]] = alloca i32,
176 // CHECK: call void @llvm.memcpy.p0.p0.i{{64|32}}(ptr {{.*}}[[SS_PRIV]], ptr {{.*}}[[SSS_INIT]], i{{64|32}} 4, i1 false)
177 // CHECK: [[IN_VAL:%.+]] = load i32, ptr [[INT_INIT]],
178 // CHECK: store i32 [[IN_VAL]], ptr [[IN_PRIV]],
179 // CHECK: call void @__kmpc_for_static_init_4(
180 #pragma omp declare reduction(+ \
183 #pragma omp declare reduction(+ \
186 #pragma omp for reduction(+ \
188 for (int i
= 0; i
< 10; ++i
)