Skip to content

Commit 52b4bec

Browse files
authored
[Clang][OpenMP] Emit unroll directive w/o captured stmt (#65862)
The front end doesn't create captured stmt for unroll directive. This leads to a crash when `-fopenmp-simd` is used, as reported in #63570. Fix #63570.
1 parent 6f5ebfb commit 52b4bec

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/lib/CodeGen/CGStmtOpenMP.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8064,7 +8064,8 @@ void CodeGenFunction::EmitSimpleOMPExecutableDirective(
80648064
D.getDirectiveKind() == OMPD_critical ||
80658065
D.getDirectiveKind() == OMPD_section ||
80668066
D.getDirectiveKind() == OMPD_master ||
8067-
D.getDirectiveKind() == OMPD_masked) {
8067+
D.getDirectiveKind() == OMPD_masked ||
8068+
D.getDirectiveKind() == OMPD_unroll) {
80688069
EmitStmt(D.getAssociatedStmt());
80698070
} else {
80708071
auto LPCRegion =

clang/test/OpenMP/bug63570.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-apple-darwin10 %s
2+
// RUN: %clang_cc1 -verify -fopenmp-simd -x c -triple x86_64-apple-darwin10 %s
3+
// expected-no-diagnostics
4+
5+
void f(float *a, float *b) {
6+
#pragma omp unroll
7+
for (int i = 0; i < 128; i++) {
8+
a[i] = b[i];
9+
}
10+
}

0 commit comments

Comments
 (0)