[clang] [Clang][OpenMP] Emit unroll directive w/o captured region (PR #65862)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 9 14:33:58 PDT 2023
llvmbot wrote:
@llvm/pr-subscribers-clang
<details>
<summary>Changes</summary>
The front end doesn't create captured region for unroll directive. This leads to
a crash when `-fopenmp-simd` is used, as reported in #63570.
Fix #63570.
--
Full diff: https://github.com/llvm/llvm-project/pull/65862.diff
2 Files Affected:
- (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+2-1)
- (added) clang/test/OpenMP/bug63570.c (+10)
<pre>
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];
+ }
+}
</pre>
</details>
https://github.com/llvm/llvm-project/pull/65862
More information about the cfe-commits
mailing list