[clang] 52b4bec - [Clang][OpenMP] Emit unroll directive w/o captured stmt (#65862)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 9 15:52:02 PDT 2023
Author: Shilei Tian
Date: 2023-09-09T18:51:58-04:00
New Revision: 52b4bec9395703d4757c065649fa43a93e19b7b2
URL: https://github.com/llvm/llvm-project/commit/52b4bec9395703d4757c065649fa43a93e19b7b2
DIFF: https://github.com/llvm/llvm-project/commit/52b4bec9395703d4757c065649fa43a93e19b7b2.diff
LOG: [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.
Added:
clang/test/OpenMP/bug63570.c
Modified:
clang/lib/CodeGen/CGStmtOpenMP.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 6eca0a5ccab41d7..a4e80a4a9e1fd75 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -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 =
diff --git a/clang/test/OpenMP/bug63570.c b/clang/test/OpenMP/bug63570.c
new file mode 100644
index 000000000000000..f61a2ee49b388d0
--- /dev/null
+++ b/clang/test/OpenMP/bug63570.c
@@ -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];
+ }
+}
More information about the cfe-commits
mailing list