[clang] [Clang][OpenMP] Emit unroll directive w/o captured region (PR #65862)
Shilei Tian via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 9 14:32:59 PDT 2023
https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/65862:
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.
>From 7ba55161a5d24e9d67c00696bca9e4d06b907689 Mon Sep 17 00:00:00 2001
From: Shilei Tian <i at tianshilei.me>
Date: Sat, 9 Sep 2023 17:30:17 -0400
Subject: [PATCH] [Clang][OpenMP] Emit unroll directive w/o captured region
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.
---
clang/lib/CodeGen/CGStmtOpenMP.cpp | 3 ++-
clang/test/OpenMP/bug63570.c | 10 ++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
create mode 100644 clang/test/OpenMP/bug63570.c
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