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 -fopenmp-enable-irbuilder -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
3 // expected-no-diagnostics
9 MyIterator(unsigned pos
);
10 MyIterator(const MyIterator
&other
);
11 const MyIterator
&operator=(const MyIterator
&that
);
12 MyIterator
&operator++();
13 int operator-(const MyIterator
&that
) const;
14 MyIterator
&operator+=(unsigned a
);
15 MyIterator
operator+(unsigned a
) const;
16 bool operator==(const MyIterator
&that
) const;
17 bool operator!=(const MyIterator
&that
) const;
18 unsigned operator*() const;
21 extern "C" void workshareloop_iterator(float *a
, float *b
, float *c
) {
23 for (MyIterator it
= MyIterator(7); it
!= MyIterator(41); ++it
) {
30 // CHECK-LABEL: define {{[^@]+}}@workshareloop_iterator
31 // CHECK-SAME: (ptr noundef [[A:%.*]], ptr noundef [[B:%.*]], ptr noundef [[C:%.*]]) #[[ATTR0:[0-9]+]] {
33 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca ptr, align 8
34 // CHECK-NEXT: [[B_ADDR:%.*]] = alloca ptr, align 8
35 // CHECK-NEXT: [[C_ADDR:%.*]] = alloca ptr, align 8
36 // CHECK-NEXT: [[IT:%.*]] = alloca [[STRUCT_MYITERATOR:%.*]], align 1
37 // CHECK-NEXT: [[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 8
38 // CHECK-NEXT: [[AGG_CAPTURED1:%.*]] = alloca [[STRUCT_ANON_0:%.*]], align 1
39 // CHECK-NEXT: [[DOTCOUNT_ADDR:%.*]] = alloca i64, align 8
40 // CHECK-NEXT: [[I:%.*]] = alloca i32, align 4
41 // CHECK-NEXT: [[P_LASTITER:%.*]] = alloca i32, align 4
42 // CHECK-NEXT: [[P_LOWERBOUND:%.*]] = alloca i64, align 8
43 // CHECK-NEXT: [[P_UPPERBOUND:%.*]] = alloca i64, align 8
44 // CHECK-NEXT: [[P_STRIDE:%.*]] = alloca i64, align 8
45 // CHECK-NEXT: store ptr [[A]], ptr [[A_ADDR]], align 8
46 // CHECK-NEXT: store ptr [[B]], ptr [[B_ADDR]], align 8
47 // CHECK-NEXT: store ptr [[C]], ptr [[C_ADDR]], align 8
48 // CHECK-NEXT: call void @_ZN10MyIteratorC1Ej(ptr noundef nonnull align 1 dereferenceable(1) [[IT]], i32 noundef 7)
49 // CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds nuw [[STRUCT_ANON]], ptr [[AGG_CAPTURED]], i32 0, i32 0
50 // CHECK-NEXT: store ptr [[IT]], ptr [[TMP0]], align 8
51 // CHECK-NEXT: call void @_ZN10MyIteratorC1ERKS_(ptr noundef nonnull align 1 dereferenceable(1) [[AGG_CAPTURED1]], ptr noundef nonnull align 1 dereferenceable(1) [[IT]])
52 // CHECK-NEXT: call void @__captured_stmt(ptr [[DOTCOUNT_ADDR]], ptr [[AGG_CAPTURED]])
53 // CHECK-NEXT: [[DOTCOUNT:%.*]] = load i64, ptr [[DOTCOUNT_ADDR]], align 8
54 // CHECK-NEXT: br label [[OMP_LOOP_PREHEADER:%.*]]
55 // CHECK: omp_loop.preheader:
56 // CHECK-NEXT: store i64 0, ptr [[P_LOWERBOUND]], align 8
57 // CHECK-NEXT: [[TMP1:%.*]] = sub i64 [[DOTCOUNT]], 1
58 // CHECK-NEXT: store i64 [[TMP1]], ptr [[P_UPPERBOUND]], align 8
59 // CHECK-NEXT: store i64 1, ptr [[P_STRIDE]], align 8
60 // CHECK-NEXT: [[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1:[0-9]+]])
61 // CHECK-NEXT: call void @__kmpc_for_static_init_8u(ptr @[[GLOB1]], i32 [[OMP_GLOBAL_THREAD_NUM]], i32 34, ptr [[P_LASTITER]], ptr [[P_LOWERBOUND]], ptr [[P_UPPERBOUND]], ptr [[P_STRIDE]], i64 1, i64 0)
62 // CHECK-NEXT: [[TMP2:%.*]] = load i64, ptr [[P_LOWERBOUND]], align 8
63 // CHECK-NEXT: [[TMP3:%.*]] = load i64, ptr [[P_UPPERBOUND]], align 8
64 // CHECK-NEXT: [[TMP4:%.*]] = sub i64 [[TMP3]], [[TMP2]]
65 // CHECK-NEXT: [[TMP5:%.*]] = add i64 [[TMP4]], 1
66 // CHECK-NEXT: br label [[OMP_LOOP_HEADER:%.*]]
67 // CHECK: omp_loop.header:
68 // CHECK-NEXT: [[OMP_LOOP_IV:%.*]] = phi i64 [ 0, [[OMP_LOOP_PREHEADER]] ], [ [[OMP_LOOP_NEXT:%.*]], [[OMP_LOOP_INC:%.*]] ]
69 // CHECK-NEXT: br label [[OMP_LOOP_COND:%.*]]
70 // CHECK: omp_loop.cond:
71 // CHECK-NEXT: [[OMP_LOOP_CMP:%.*]] = icmp ult i64 [[OMP_LOOP_IV]], [[TMP5]]
72 // CHECK-NEXT: br i1 [[OMP_LOOP_CMP]], label [[OMP_LOOP_BODY:%.*]], label [[OMP_LOOP_EXIT:%.*]]
73 // CHECK: omp_loop.body:
74 // CHECK-NEXT: [[TMP6:%.*]] = add i64 [[OMP_LOOP_IV]], [[TMP2]]
75 // CHECK-NEXT: call void @__captured_stmt.1(ptr [[IT]], i64 [[TMP6]], ptr [[AGG_CAPTURED1]])
76 // CHECK-NEXT: [[CALL:%.*]] = call noundef i32 @_ZNK10MyIteratordeEv(ptr noundef nonnull align 1 dereferenceable(1) [[IT]])
77 // CHECK-NEXT: store i32 [[CALL]], ptr [[I]], align 4
78 // CHECK-NEXT: [[TMP7:%.*]] = load ptr, ptr [[B_ADDR]], align 8
79 // CHECK-NEXT: [[TMP8:%.*]] = load i32, ptr [[I]], align 4
80 // CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[TMP8]] to i64
81 // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds nuw float, ptr [[TMP7]], i64 [[IDXPROM]]
82 // CHECK-NEXT: [[TMP9:%.*]] = load float, ptr [[ARRAYIDX]], align 4
83 // CHECK-NEXT: [[TMP10:%.*]] = load ptr, ptr [[C_ADDR]], align 8
84 // CHECK-NEXT: [[TMP11:%.*]] = load i32, ptr [[I]], align 4
85 // CHECK-NEXT: [[IDXPROM2:%.*]] = zext i32 [[TMP11]] to i64
86 // CHECK-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds nuw float, ptr [[TMP10]], i64 [[IDXPROM2]]
87 // CHECK-NEXT: [[TMP12:%.*]] = load float, ptr [[ARRAYIDX3]], align 4
88 // CHECK-NEXT: [[MUL:%.*]] = fmul float [[TMP9]], [[TMP12]]
89 // CHECK-NEXT: [[TMP13:%.*]] = load ptr, ptr [[A_ADDR]], align 8
90 // CHECK-NEXT: [[TMP14:%.*]] = load i32, ptr [[I]], align 4
91 // CHECK-NEXT: [[IDXPROM4:%.*]] = zext i32 [[TMP14]] to i64
92 // CHECK-NEXT: [[ARRAYIDX5:%.*]] = getelementptr inbounds nuw float, ptr [[TMP13]], i64 [[IDXPROM4]]
93 // CHECK-NEXT: store float [[MUL]], ptr [[ARRAYIDX5]], align 4
94 // CHECK-NEXT: br label [[OMP_LOOP_INC]]
95 // CHECK: omp_loop.inc:
96 // CHECK-NEXT: [[OMP_LOOP_NEXT]] = add nuw i64 [[OMP_LOOP_IV]], 1
97 // CHECK-NEXT: br label [[OMP_LOOP_HEADER]]
98 // CHECK: omp_loop.exit:
99 // CHECK-NEXT: call void @__kmpc_for_static_fini(ptr @[[GLOB1]], i32 [[OMP_GLOBAL_THREAD_NUM]])
100 // CHECK-NEXT: [[OMP_GLOBAL_THREAD_NUM6:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1]])
101 // CHECK-NEXT: call void @__kmpc_barrier(ptr @[[GLOB2:[0-9]+]], i32 [[OMP_GLOBAL_THREAD_NUM6]])
102 // CHECK-NEXT: br label [[OMP_LOOP_AFTER:%.*]]
103 // CHECK: omp_loop.after:
104 // CHECK-NEXT: ret void
107 // CHECK-LABEL: define {{[^@]+}}@__captured_stmt
108 // CHECK-SAME: (ptr noundef nonnull align 8 dereferenceable(8) [[DISTANCE:%.*]], ptr noalias noundef [[__CONTEXT:%.*]]) #[[ATTR2:[0-9]+]] {
109 // CHECK-NEXT: entry:
110 // CHECK-NEXT: [[DISTANCE_ADDR:%.*]] = alloca ptr, align 8
111 // CHECK-NEXT: [[__CONTEXT_ADDR:%.*]] = alloca ptr, align 8
112 // CHECK-NEXT: [[DOTSTART:%.*]] = alloca [[STRUCT_MYITERATOR:%.*]], align 1
113 // CHECK-NEXT: [[DOTSTOP:%.*]] = alloca [[STRUCT_MYITERATOR]], align 1
114 // CHECK-NEXT: [[DOTSTEP:%.*]] = alloca i64, align 8
115 // CHECK-NEXT: store ptr [[DISTANCE]], ptr [[DISTANCE_ADDR]], align 8
116 // CHECK-NEXT: store ptr [[__CONTEXT]], ptr [[__CONTEXT_ADDR]], align 8
117 // CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[__CONTEXT_ADDR]], align 8
118 // CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds nuw [[STRUCT_ANON:%.*]], ptr [[TMP0]], i32 0, i32 0
119 // CHECK-NEXT: [[TMP2:%.*]] = load ptr, ptr [[TMP1]], align 8
120 // CHECK-NEXT: call void @_ZN10MyIteratorC1ERKS_(ptr noundef nonnull align 1 dereferenceable(1) [[DOTSTART]], ptr noundef nonnull align 1 dereferenceable(1) [[TMP2]])
121 // CHECK-NEXT: call void @_ZN10MyIteratorC1Ej(ptr noundef nonnull align 1 dereferenceable(1) [[DOTSTOP]], i32 noundef 41)
122 // CHECK-NEXT: store i64 1, ptr [[DOTSTEP]], align 8
123 // CHECK-NEXT: [[TMP3:%.*]] = load i64, ptr [[DOTSTEP]], align 8
124 // CHECK-NEXT: [[CMP:%.*]] = icmp ult i64 [[TMP3]], 0
125 // CHECK-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
127 // CHECK-NEXT: [[CALL:%.*]] = call noundef i32 @_ZNK10MyIteratormiERKS_(ptr noundef nonnull align 1 dereferenceable(1) [[DOTSTART]], ptr noundef nonnull align 1 dereferenceable(1) [[DOTSTOP]])
128 // CHECK-NEXT: [[CONV:%.*]] = sext i32 [[CALL]] to i64
129 // CHECK-NEXT: [[TMP4:%.*]] = load i64, ptr [[DOTSTEP]], align 8
130 // CHECK-NEXT: [[SUB:%.*]] = sub i64 0, [[TMP4]]
131 // CHECK-NEXT: [[DIV:%.*]] = udiv i64 [[CONV]], [[SUB]]
132 // CHECK-NEXT: br label [[COND_END:%.*]]
133 // CHECK: cond.false:
134 // CHECK-NEXT: [[CALL1:%.*]] = call noundef i32 @_ZNK10MyIteratormiERKS_(ptr noundef nonnull align 1 dereferenceable(1) [[DOTSTOP]], ptr noundef nonnull align 1 dereferenceable(1) [[DOTSTART]])
135 // CHECK-NEXT: [[CONV2:%.*]] = sext i32 [[CALL1]] to i64
136 // CHECK-NEXT: [[TMP5:%.*]] = load i64, ptr [[DOTSTEP]], align 8
137 // CHECK-NEXT: [[DIV3:%.*]] = udiv i64 [[CONV2]], [[TMP5]]
138 // CHECK-NEXT: br label [[COND_END]]
140 // CHECK-NEXT: [[COND:%.*]] = phi i64 [ [[DIV]], [[COND_TRUE]] ], [ [[DIV3]], [[COND_FALSE]] ]
141 // CHECK-NEXT: [[TMP6:%.*]] = load ptr, ptr [[DISTANCE_ADDR]], align 8
142 // CHECK-NEXT: store i64 [[COND]], ptr [[TMP6]], align 8
143 // CHECK-NEXT: ret void
146 // CHECK-LABEL: define {{[^@]+}}@__captured_stmt.1
147 // CHECK-SAME: (ptr noundef nonnull align 1 dereferenceable(1) [[LOOPVAR:%.*]], i64 noundef [[LOGICAL:%.*]], ptr noalias noundef [[__CONTEXT:%.*]]) #[[ATTR2]] {
148 // CHECK-NEXT: entry:
149 // CHECK-NEXT: [[LOOPVAR_ADDR:%.*]] = alloca ptr, align 8
150 // CHECK-NEXT: [[LOGICAL_ADDR:%.*]] = alloca i64, align 8
151 // CHECK-NEXT: [[__CONTEXT_ADDR:%.*]] = alloca ptr, align 8
152 // CHECK-NEXT: [[REF_TMP:%.*]] = alloca [[STRUCT_MYITERATOR:%.*]], align 1
153 // CHECK-NEXT: store ptr [[LOOPVAR]], ptr [[LOOPVAR_ADDR]], align 8
154 // CHECK-NEXT: store i64 [[LOGICAL]], ptr [[LOGICAL_ADDR]], align 8
155 // CHECK-NEXT: store ptr [[__CONTEXT]], ptr [[__CONTEXT_ADDR]], align 8
156 // CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[__CONTEXT_ADDR]], align 8
157 // CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr [[LOGICAL_ADDR]], align 8
158 // CHECK-NEXT: [[MUL:%.*]] = mul i64 1, [[TMP1]]
159 // CHECK-NEXT: [[CONV:%.*]] = trunc i64 [[MUL]] to i32
160 // CHECK-NEXT: call void @_ZNK10MyIteratorplEj(ptr dead_on_unwind writable sret([[STRUCT_MYITERATOR]]) align 1 [[REF_TMP]], ptr noundef nonnull align 1 dereferenceable(1) [[TMP0]], i32 noundef [[CONV]])
161 // CHECK-NEXT: [[TMP2:%.*]] = load ptr, ptr [[LOOPVAR_ADDR]], align 8
162 // CHECK-NEXT: [[CALL:%.*]] = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN10MyIteratoraSERKS_(ptr noundef nonnull align 1 dereferenceable(1) [[TMP2]], ptr noundef nonnull align 1 dereferenceable(1) [[REF_TMP]])
163 // CHECK-NEXT: ret void