• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - -femit-all-decls | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - -femit-all-decls | FileCheck %s
4 // expected-no-diagnostics
5 // REQUIRES: x86-registered-target
6 #ifndef HEADER
7 #define HEADER
8 
9 // CHECK-LABEL: @main
main(int argc,char ** argv)10 int main(int argc, char **argv) {
11 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(%ident_t* [[DEFLOC:@.+]])
12 // CHECK: [[TASKV:%.+]] = call i8* @__kmpc_omp_task_alloc(%ident_t* [[DEFLOC]], i32 [[GTID]], i32 33, i64 72, i64 1, i32 (i32, i8*)* bitcast (i32 (i32, [[TDP_TY:%.+]]*)* [[TASK1:@.+]] to i32 (i32, i8*)*))
13 // CHECK: [[TASK:%.+]] = bitcast i8* [[TASKV]] to [[TDP_TY]]*
14 // CHECK: [[TASK_DATA:%.+]] = getelementptr inbounds [[TDP_TY]], [[TDP_TY]]* [[TASK]], i32 0, i32 0
15 // CHECK: [[DOWN:%.+]] = getelementptr inbounds [[TD_TY:%.+]], [[TD_TY]]* [[TASK_DATA]], i32 0, i32 5
16 // CHECK: store i64 0, i64* [[DOWN]],
17 // CHECK: [[UP:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* [[TASK_DATA]], i32 0, i32 6
18 // CHECK: store i64 9, i64* [[UP]],
19 // CHECK: [[ST:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* [[TASK_DATA]], i32 0, i32 7
20 // CHECK: store i64 1, i64* [[ST]],
21 // CHECK: [[ST_VAL:%.+]] = load i64, i64* [[ST]],
22 // CHECK: call void @__kmpc_taskloop(%ident_t* [[DEFLOC]], i32 [[GTID]], i8* [[TASKV]], i32 1, i64* [[DOWN]], i64* [[UP]], i64 [[ST_VAL]], i32 0, i32 0, i64 0, i8* null)
23 #pragma omp taskloop priority(argc)
24   for (int i = 0; i < 10; ++i)
25     ;
26 // CHECK: [[TASKV:%.+]] = call i8* @__kmpc_omp_task_alloc(%ident_t* [[DEFLOC]], i32 [[GTID]], i32 1, i64 72, i64 1, i32 (i32, i8*)* bitcast (i32 (i32, [[TDP_TY:%.+]]*)* [[TASK2:@.+]] to i32 (i32, i8*)*))
27 // CHECK: [[TASK:%.+]] = bitcast i8* [[TASKV]] to [[TDP_TY]]*
28 // CHECK: [[TASK_DATA:%.+]] = getelementptr inbounds [[TDP_TY]], [[TDP_TY]]* [[TASK]], i32 0, i32 0
29 // CHECK: [[DOWN:%.+]] = getelementptr inbounds [[TD_TY:%.+]], [[TD_TY]]* [[TASK_DATA]], i32 0, i32 5
30 // CHECK: store i64 0, i64* [[DOWN]],
31 // CHECK: [[UP:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* [[TASK_DATA]], i32 0, i32 6
32 // CHECK: store i64 9, i64* [[UP]],
33 // CHECK: [[ST:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* [[TASK_DATA]], i32 0, i32 7
34 // CHECK: store i64 1, i64* [[ST]],
35 // CHECK: [[ST_VAL:%.+]] = load i64, i64* [[ST]],
36 // CHECK: [[GRAINSIZE:%.+]] = zext i32 %{{.+}} to i64
37 // CHECK: call void @__kmpc_taskloop(%ident_t* [[DEFLOC]], i32 [[GTID]], i8* [[TASKV]], i32 1, i64* [[DOWN]], i64* [[UP]], i64 [[ST_VAL]], i32 1, i32 1, i64 [[GRAINSIZE]], i8* null)
38 #pragma omp taskloop nogroup grainsize(argc)
39   for (int i = 0; i < 10; ++i)
40     ;
41 // CHECK: [[TASKV:%.+]] = call i8* @__kmpc_omp_task_alloc(%ident_t* [[DEFLOC]], i32 [[GTID]], i32 1, i64 72, i64 24, i32 (i32, i8*)* bitcast (i32 (i32, [[TDP_TY:%.+]]*)* [[TASK3:@.+]] to i32 (i32, i8*)*))
42 // CHECK: [[TASK:%.+]] = bitcast i8* [[TASKV]] to [[TDP_TY]]*
43 // CHECK: [[TASK_DATA:%.+]] = getelementptr inbounds [[TDP_TY]], [[TDP_TY]]* [[TASK]], i32 0, i32 0
44 // CHECK: [[IF:%.+]] = icmp ne i32 %{{.+}}, 0
45 // CHECK: [[IF_INT:%.+]] = sext i1 [[IF]] to i32
46 // CHECK: [[DOWN:%.+]] = getelementptr inbounds [[TD_TY:%.+]], [[TD_TY]]* [[TASK_DATA]], i32 0, i32 5
47 // CHECK: store i64 0, i64* [[DOWN]],
48 // CHECK: [[UP:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* [[TASK_DATA]], i32 0, i32 6
49 // CHECK: store i64 %{{.+}}, i64* [[UP]],
50 // CHECK: [[ST:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* [[TASK_DATA]], i32 0, i32 7
51 // CHECK: store i64 1, i64* [[ST]],
52 // CHECK: [[ST_VAL:%.+]] = load i64, i64* [[ST]],
53 // CHECK: call void @__kmpc_taskloop(%ident_t* [[DEFLOC]], i32 [[GTID]], i8* [[TASKV]], i32 [[IF_INT]], i64* [[DOWN]], i64* [[UP]], i64 [[ST_VAL]], i32 0, i32 2, i64 4, i8* null)
54   int i;
55 #pragma omp taskloop if(argc) shared(argc, argv) collapse(2) num_tasks(4)
56   for (i = 0; i < argc; ++i)
57   for (int j = argc; j < argv[argc][argc]; ++j)
58     ;
59 }
60 
61 // CHECK: define internal i32 [[TASK1]](
62 // CHECK: [[DOWN:%.+]] = getelementptr inbounds [[TD_TY:%.+]], [[TD_TY]]* %{{.+}}, i32 0, i32 5
63 // CHECK: [[DOWN_VAL:%.+]] = load i64, i64* [[DOWN]],
64 // CHECK: [[UP:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* %{{.+}}, i32 0, i32 6
65 // CHECK: [[UP_VAL:%.+]] = load i64, i64* [[UP]],
66 // CHECK: [[ST:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* %{{.+}}, i32 0, i32 7
67 // CHECK: [[ST_VAL:%.+]] = load i64, i64* [[ST]],
68 // CHECK: [[LITER:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* %{{.+}}, i32 0, i32 8
69 // CHECK: [[LITER_VAL:%.+]] = load i32, i32* [[LITER]],
70 // CHECK: store i64 [[DOWN_VAL]], i64* [[LB:%[^,]+]],
71 // CHECK: store i64 [[UP_VAL]], i64* [[UB:%[^,]+]],
72 // CHECK: store i64 [[ST_VAL]], i64* [[ST:%[^,]+]],
73 // CHECK: store i32 [[LITER_VAL]], i32* [[LITER:%[^,]+]],
74 // CHECK: [[LB_VAL:%.+]] = load i64, i64* [[LB]],
75 // CHECK: [[LB_I32:%.+]] = trunc i64 [[LB_VAL]] to i32
76 // CHECK: store i32 [[LB_I32]], i32* [[CNT:%.+]],
77 // CHECK: br label
78 // CHECK: [[VAL:%.+]] = load i32, i32* [[CNT]],
79 // CHECK: [[VAL_I64:%.+]] = sext i32 [[VAL]] to i64
80 // CHECK: [[UB_VAL:%.+]] = load i64, i64* [[UB]],
81 // CHECK: [[CMP:%.+]] = icmp ule i64 [[VAL_I64]], [[UB_VAL]]
82 // CHECK: br i1 [[CMP]], label %{{.+}}, label %{{.+}}
83 // CHECK: load i32, i32* %
84 // CHECK: store i32 %
85 // CHECK: load i32, i32* %
86 // CHECK: add nsw i32 %{{.+}}, 1
87 // CHECK: store i32 %{{.+}}, i32* %
88 // CHECK: br label %
89 // CHECK: ret i32 0
90 
91 // CHECK: define internal i32 [[TASK2]](
92 // CHECK: [[DOWN:%.+]] = getelementptr inbounds [[TD_TY:%.+]], [[TD_TY]]* %{{.+}}, i32 0, i32 5
93 // CHECK: [[DOWN_VAL:%.+]] = load i64, i64* [[DOWN]],
94 // CHECK: [[UP:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* %{{.+}}, i32 0, i32 6
95 // CHECK: [[UP_VAL:%.+]] = load i64, i64* [[UP]],
96 // CHECK: [[ST:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* %{{.+}}, i32 0, i32 7
97 // CHECK: [[ST_VAL:%.+]] = load i64, i64* [[ST]],
98 // CHECK: [[LITER:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* %{{.+}}, i32 0, i32 8
99 // CHECK: [[LITER_VAL:%.+]] = load i32, i32* [[LITER]],
100 // CHECK: store i64 [[DOWN_VAL]], i64* [[LB:%[^,]+]],
101 // CHECK: store i64 [[UP_VAL]], i64* [[UB:%[^,]+]],
102 // CHECK: store i64 [[ST_VAL]], i64* [[ST:%[^,]+]],
103 // CHECK: store i32 [[LITER_VAL]], i32* [[LITER:%[^,]+]],
104 // CHECK: [[LB_VAL:%.+]] = load i64, i64* [[LB]],
105 // CHECK: [[LB_I32:%.+]] = trunc i64 [[LB_VAL]] to i32
106 // CHECK: store i32 [[LB_I32]], i32* [[CNT:%.+]],
107 // CHECK: br label
108 // CHECK: [[VAL:%.+]] = load i32, i32* [[CNT]],
109 // CHECK: [[VAL_I64:%.+]] = sext i32 [[VAL]] to i64
110 // CHECK: [[UB_VAL:%.+]] = load i64, i64* [[UB]],
111 // CHECK: [[CMP:%.+]] = icmp ule i64 [[VAL_I64]], [[UB_VAL]]
112 // CHECK: br i1 [[CMP]], label %{{.+}}, label %{{.+}}
113 // CHECK: load i32, i32* %
114 // CHECK: store i32 %
115 // CHECK: load i32, i32* %
116 // CHECK: add nsw i32 %{{.+}}, 1
117 // CHECK: store i32 %{{.+}}, i32* %
118 // CHECK: br label %
119 // CHECK: ret i32 0
120 
121 // CHECK: define internal i32 [[TASK3]](
122 // CHECK: [[DOWN:%.+]] = getelementptr inbounds [[TD_TY:%.+]], [[TD_TY]]* %{{.+}}, i32 0, i32 5
123 // CHECK: [[DOWN_VAL:%.+]] = load i64, i64* [[DOWN]],
124 // CHECK: [[UP:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* %{{.+}}, i32 0, i32 6
125 // CHECK: [[UP_VAL:%.+]] = load i64, i64* [[UP]],
126 // CHECK: [[ST:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* %{{.+}}, i32 0, i32 7
127 // CHECK: [[ST_VAL:%.+]] = load i64, i64* [[ST]],
128 // CHECK: [[LITER:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* %{{.+}}, i32 0, i32 8
129 // CHECK: [[LITER_VAL:%.+]] = load i32, i32* [[LITER]],
130 // CHECK: store i64 [[DOWN_VAL]], i64* [[LB:%[^,]+]],
131 // CHECK: store i64 [[UP_VAL]], i64* [[UB:%[^,]+]],
132 // CHECK: store i64 [[ST_VAL]], i64* [[ST:%[^,]+]],
133 // CHECK: store i32 [[LITER_VAL]], i32* [[LITER:%[^,]+]],
134 // CHECK: [[LB_VAL:%.+]] = load i64, i64* [[LB]],
135 // CHECK: store i64 [[LB_VAL]], i64* [[CNT:%.+]],
136 // CHECK: br label
137 // CHECK: ret i32 0
138 
139 // CHECK-LABEL: @_ZN1SC2Ei
140 struct S {
141   int a;
SS142   S(int c) {
143 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(%ident_t* [[DEFLOC:@.+]])
144 // CHECK: [[TASKV:%.+]] = call i8* @__kmpc_omp_task_alloc(%ident_t* [[DEFLOC]], i32 [[GTID]], i32 1, i64 72, i64 16, i32 (i32, i8*)* bitcast (i32 (i32, [[TDP_TY:%.+]]*)* [[TASK4:@.+]] to i32 (i32, i8*)*))
145 // CHECK: [[TASK:%.+]] = bitcast i8* [[TASKV]] to [[TDP_TY]]*
146 // CHECK: [[TASK_DATA:%.+]] = getelementptr inbounds [[TDP_TY]], [[TDP_TY]]* [[TASK]], i32 0, i32 0
147 // CHECK: [[DOWN:%.+]] = getelementptr inbounds [[TD_TY:%.+]], [[TD_TY]]* [[TASK_DATA]], i32 0, i32 5
148 // CHECK: store i64 0, i64* [[DOWN]],
149 // CHECK: [[UP:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* [[TASK_DATA]], i32 0, i32 6
150 // CHECK: store i64 %{{.+}}, i64* [[UP]],
151 // CHECK: [[ST:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* [[TASK_DATA]], i32 0, i32 7
152 // CHECK: store i64 1, i64* [[ST]],
153 // CHECK: [[ST_VAL:%.+]] = load i64, i64* [[ST]],
154 // CHECK: [[NUM_TASKS:%.+]] = zext i32 %{{.+}} to i64
155 // CHECK: call void @__kmpc_taskloop(%ident_t* [[DEFLOC]], i32 [[GTID]], i8* [[TASKV]], i32 1, i64* [[DOWN]], i64* [[UP]], i64 [[ST_VAL]], i32 0, i32 2, i64 [[NUM_TASKS]], i8* null)
156 #pragma omp taskloop shared(c) num_tasks(a)
157     for (a = 0; a < c; ++a)
158       ;
159   }
160 } s(1);
161 
162 // CHECK: define internal i32 [[TASK4]](
163 // CHECK: [[DOWN:%.+]] = getelementptr inbounds [[TD_TY:%.+]], [[TD_TY]]* %{{.+}}, i32 0, i32 5
164 // CHECK: [[DOWN_VAL:%.+]] = load i64, i64* [[DOWN]],
165 // CHECK: [[UP:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* %{{.+}}, i32 0, i32 6
166 // CHECK: [[UP_VAL:%.+]] = load i64, i64* [[UP]],
167 // CHECK: [[ST:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* %{{.+}}, i32 0, i32 7
168 // CHECK: [[ST_VAL:%.+]] = load i64, i64* [[ST]],
169 // CHECK: [[LITER:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* %{{.+}}, i32 0, i32 8
170 // CHECK: [[LITER_VAL:%.+]] = load i32, i32* [[LITER]],
171 // CHECK: store i64 [[DOWN_VAL]], i64* [[LB:%[^,]+]],
172 // CHECK: store i64 [[UP_VAL]], i64* [[UB:%[^,]+]],
173 // CHECK: store i64 [[ST_VAL]], i64* [[ST:%[^,]+]],
174 // CHECK: store i32 [[LITER_VAL]], i32* [[LITER:%[^,]+]],
175 // CHECK: [[LB_VAL:%.+]] = load i64, i64* [[LB]],
176 // CHECK: [[LB_I32:%.+]] = trunc i64 [[LB_VAL]] to i32
177 // CHECK: store i32 [[LB_I32]], i32* [[CNT:%.+]],
178 // CHECK: br label
179 // CHECK: [[VAL:%.+]] = load i32, i32* [[CNT]],
180 // CHECK: [[VAL_I64:%.+]] = sext i32 [[VAL]] to i64
181 // CHECK: [[UB_VAL:%.+]] = load i64, i64* [[UB]],
182 // CHECK: [[CMP:%.+]] = icmp ule i64 [[VAL_I64]], [[UB_VAL]]
183 // CHECK: br i1 [[CMP]], label %{{.+}}, label %{{.+}}
184 // CHECK: load i32, i32* %
185 // CHECK: store i32 %
186 // CHECK: load i32, i32* %
187 // CHECK: add nsw i32 %{{.+}}, 1
188 // CHECK: store i32 %{{.+}}, i32* %
189 // CHECK: br label %
190 // CHECK: ret i32 0
191 
192 #endif
193