Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
clang/test/OpenMP/for_codegen.cpp
Show First 20 Lines • Show All 560 Lines • ▼ Show 20 Lines | |||||
int foo() { extern void mayThrow(); mayThrow(); return 0;}; | int foo() { extern void mayThrow(); mayThrow(); return 0;}; | ||||
// TERM_DEBUG-LABEL: parallel_for | // TERM_DEBUG-LABEL: parallel_for | ||||
void parallel_for(float *a) { | void parallel_for(float *a) { | ||||
#pragma omp parallel | #pragma omp parallel | ||||
#pragma omp for schedule(static, 5) | #pragma omp for schedule(static, 5) | ||||
// TERM_DEBUG-NOT: __kmpc_global_thread_num | // TERM_DEBUG-NOT: __kmpc_global_thread_num | ||||
// TERM_DEBUG: call void @__kmpc_for_static_init_4u({{.+}}), !dbg [[DBG_LOC:![0-9]+]] | // TERM_DEBUG: call void @__kmpc_for_static_init_4u({{.+}}), !dbg [[DBG_LOC:![0-9]+]] | ||||
// TERM_DEBUG: invoke noundef i32 {{.*}}foo{{.*}}() | // TERM_DEBUG: call unwindabort noundef i32 {{.*}}foo{{.*}}() | ||||
// TERM_DEBUG: unwind label %[[TERM_LPAD:.+]], | |||||
// TERM_DEBUG-NOT: __kmpc_global_thread_num | // TERM_DEBUG-NOT: __kmpc_global_thread_num | ||||
// TERM_DEBUG: call void @__kmpc_for_static_fini({{.+}}), !dbg [[DBG_LOC]] | // TERM_DEBUG: call void @__kmpc_for_static_fini({{.+}}), !dbg [[DBG_LOC]] | ||||
// TERM_DEBUG: call {{.+}} @__kmpc_barrier({{.+}}), !dbg [[DBG_LOC]] | // TERM_DEBUG: call {{.+}} @__kmpc_barrier({{.+}}), !dbg [[DBG_LOC]] | ||||
// TERM_DEBUG: [[TERM_LPAD]] | |||||
// TERM_DEBUG: call void @__clang_call_terminate | |||||
// TERM_DEBUG: unreachable | |||||
for (unsigned i = 131071; i <= 2147483647; i += 127) | for (unsigned i = 131071; i <= 2147483647; i += 127) | ||||
a[i] += foo(); | a[i] += foo(); | ||||
} | } | ||||
// Check source line corresponds to "#pragma omp for schedule(static, 5)" above: | // Check source line corresponds to "#pragma omp for schedule(static, 5)" above: | ||||
// TERM_DEBUG: [[DBG_LOC]] = !DILocation(line: [[@LINE-15]], | // TERM_DEBUG: [[DBG_LOC]] = !DILocation(line: [[@LINE-11]], | ||||
char i = 1, j = 2, k = 3; | char i = 1, j = 2, k = 3; | ||||
// CHECK-LABEL: for_with_global_lcv | // CHECK-LABEL: for_with_global_lcv | ||||
void for_with_global_lcv() { | void for_with_global_lcv() { | ||||
// CHECK: alloca i8, | // CHECK: alloca i8, | ||||
// CHECK: [[I_ADDR:%.+]] = alloca i8, | // CHECK: [[I_ADDR:%.+]] = alloca i8, | ||||
// CHECK: alloca i8, | // CHECK: alloca i8, | ||||
// CHECK: [[J_ADDR:%.+]] = alloca i8, | // CHECK: [[J_ADDR:%.+]] = alloca i8, | ||||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | |||||
// OMP5-LABEL: imperfectly_nested_loop | // OMP5-LABEL: imperfectly_nested_loop | ||||
void imperfectly_nested_loop() { | void imperfectly_nested_loop() { | ||||
// OMP5: call void @__kmpc_for_static_init_4( | // OMP5: call void @__kmpc_for_static_init_4( | ||||
#pragma omp for collapse(3) order(concurrent) | #pragma omp for collapse(3) order(concurrent) | ||||
for (int i = 0; i < 10; ++i) { | for (int i = 0; i < 10; ++i) { | ||||
{ | { | ||||
int a, d; | int a, d; | ||||
// OMP5: invoke void @{{.+}}first{{.+}}() | // OMP5: call unwindabort void @{{.+}}first{{.+}}() | ||||
first(); | first(); | ||||
// OMP5: load i32{{.*}}!llvm.access.group ![[AG:[0-9]+]] | // OMP5: load i32{{.*}}!llvm.access.group ![[AG:[0-9]+]] | ||||
// OMP5: store i32{{.*}}!llvm.access.group ![[AG]] | // OMP5: store i32{{.*}}!llvm.access.group ![[AG]] | ||||
a = d; | a = d; | ||||
for (int j = 0; j < 10; ++j) { | for (int j = 0; j < 10; ++j) { | ||||
int a, d; | int a, d; | ||||
// OMP5: invoke void @{{.+}}inner_f{{.+}}() | // OMP5: call unwindabort void @{{.+}}inner_f{{.+}}() | ||||
inner_f(); | inner_f(); | ||||
// OMP5: load i32{{.*}}!llvm.access.group ![[AG]] | // OMP5: load i32{{.*}}!llvm.access.group ![[AG]] | ||||
// OMP5: store i32{{.*}}!llvm.access.group ![[AG]] | // OMP5: store i32{{.*}}!llvm.access.group ![[AG]] | ||||
a = d; | a = d; | ||||
for (int k = 0; k < 10; ++k) { | for (int k = 0; k < 10; ++k) { | ||||
int a, d; | int a, d; | ||||
// OMP5: invoke void @{{.+}}body_f{{.+}}() | // OMP5: call unwindabort void @{{.+}}body_f{{.+}}() | ||||
body_f(); | body_f(); | ||||
// OMP5: load i32{{.*}}!llvm.access.group ![[AG]] | // OMP5: load i32{{.*}}!llvm.access.group ![[AG]] | ||||
// OMP5: store i32{{.*}}!llvm.access.group ![[AG]] | // OMP5: store i32{{.*}}!llvm.access.group ![[AG]] | ||||
a = d; | a = d; | ||||
} | } | ||||
// OMP5: invoke void @{{.+}}inner_l{{.+}}() | // OMP5: call unwindabort void @{{.+}}inner_l{{.+}}() | ||||
inner_l(); | inner_l(); | ||||
} | } | ||||
// OMP5: invoke void @{{.+}}last{{.+}}() | // OMP5: call unwindabort void @{{.+}}last{{.+}}() | ||||
last(); | last(); | ||||
} | } | ||||
} | } | ||||
// OMP5: call void @__kmpc_for_static_fini( | // OMP5: call void @__kmpc_for_static_fini( | ||||
} | } | ||||
// OMP5: ![[AG]] = distinct !{} | // OMP5: ![[AG]] = distinct !{} | ||||
// OMP5: !{!"llvm.loop.parallel_accesses", ![[AG]]} | // OMP5: !{!"llvm.loop.parallel_accesses", ![[AG]]} | ||||
#endif | #endif | ||||
#endif // HEADER | #endif // HEADER |