[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.
This commit is contained in:
Shilei Tian 2023-09-09 18:51:58 -04:00 committed by GitHub
parent 6f5ebfb987
commit 52b4bec939
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -8064,7 +8064,8 @@ void CodeGenFunction::EmitSimpleOMPExecutableDirective(
D.getDirectiveKind() == OMPD_critical ||
D.getDirectiveKind() == OMPD_section ||
D.getDirectiveKind() == OMPD_master ||
D.getDirectiveKind() == OMPD_masked) {
D.getDirectiveKind() == OMPD_masked ||
D.getDirectiveKind() == OMPD_unroll) {
EmitStmt(D.getAssociatedStmt());
} else {
auto LPCRegion =

View File

@ -0,0 +1,10 @@
// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-apple-darwin10 %s
// RUN: %clang_cc1 -verify -fopenmp-simd -x c -triple x86_64-apple-darwin10 %s
// expected-no-diagnostics
void f(float *a, float *b) {
#pragma omp unroll
for (int i = 0; i < 128; i++) {
a[i] = b[i];
}
}