[llvm-branch-commits] [cfe-branch] r358923 - Merging r356198:
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Apr 22 15:12:22 PDT 2019
Author: tstellar
Date: Mon Apr 22 15:12:21 2019
New Revision: 358923
URL: http://llvm.org/viewvc/llvm-project?rev=358923&view=rev
Log:
Merging r356198:
------------------------------------------------------------------------
r356198 | abataev | 2019-03-14 13:36:00 -0700 (Thu, 14 Mar 2019) | 5 lines
[OPENMP]Fix crash for the ordered(n) clause.
If the doacross lop construct is used and the loop counter is declare
outside of the loop, the compiler might crash trying to get the address
of the loop counter. Patch fixes this problem.
------------------------------------------------------------------------
Modified:
cfe/branches/release_80/lib/CodeGen/CGStmtOpenMP.cpp
cfe/branches/release_80/lib/Sema/SemaOpenMP.cpp
cfe/branches/release_80/test/OpenMP/ordered_doacross_codegen.cpp
Modified: cfe/branches/release_80/lib/CodeGen/CGStmtOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/lib/CodeGen/CGStmtOpenMP.cpp?rev=358923&r1=358922&r2=358923&view=diff
==============================================================================
--- cfe/branches/release_80/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/branches/release_80/lib/CodeGen/CGStmtOpenMP.cpp Mon Apr 22 15:12:21 2019
@@ -1518,8 +1518,9 @@ void CodeGenFunction::EmitOMPPrivateLoop
I < E; ++I) {
const auto *DRE = cast<DeclRefExpr>(C->getLoopCounter(I));
const auto *VD = cast<VarDecl>(DRE->getDecl());
- // Override only those variables that are really emitted already.
- if (LocalDeclMap.count(VD)) {
+ // Override only those variables that can be captured to avoid re-emission
+ // of the variables declared within the loops.
+ if (DRE->refersToEnclosingVariableOrCapture()) {
(void)LoopScope.addPrivate(VD, [this, DRE, VD]() {
return CreateMemTemp(DRE->getType(), VD->getName());
});
Modified: cfe/branches/release_80/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/lib/Sema/SemaOpenMP.cpp?rev=358923&r1=358922&r2=358923&view=diff
==============================================================================
--- cfe/branches/release_80/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/branches/release_80/lib/Sema/SemaOpenMP.cpp Mon Apr 22 15:12:21 2019
@@ -4602,8 +4602,7 @@ DeclRefExpr *OpenMPIterationSpaceChecker
Captures.insert(std::make_pair(LCRef, Ref));
return Ref;
}
- return buildDeclRefExpr(SemaRef, VD, VD->getType().getNonReferenceType(),
- DefaultLoc);
+ return cast<DeclRefExpr>(LCRef);
}
Expr *OpenMPIterationSpaceChecker::buildPrivateCounterVar() const {
Modified: cfe/branches/release_80/test/OpenMP/ordered_doacross_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/test/OpenMP/ordered_doacross_codegen.cpp?rev=358923&r1=358922&r2=358923&view=diff
==============================================================================
--- cfe/branches/release_80/test/OpenMP/ordered_doacross_codegen.cpp (original)
+++ cfe/branches/release_80/test/OpenMP/ordered_doacross_codegen.cpp Mon Apr 22 15:12:21 2019
@@ -16,6 +16,17 @@ extern int n;
int a[10], b[10], c[10], d[10];
void foo();
+// CHECK-LABEL:bar
+void bar() {
+ int i,j;
+// CHECK: call void @__kmpc_doacross_init(
+// CHECK: call void @__kmpc_doacross_fini(
+#pragma omp parallel for ordered(2)
+ for (i = 0; i < n; ++i)
+ for (j = 0; j < n; ++j)
+ a[i] = b[i] + 1;
+}
+
// CHECK-LABEL: @main()
int main() {
int i;
@@ -35,7 +46,7 @@ int main() {
// CHECK: call void @__kmpc_doacross_init([[IDENT]], i32 [[GTID]], i32 1, i8* [[CAST]])
// CHECK: call void @__kmpc_for_static_init_4(
#pragma omp for ordered(1)
- for (i = 0; i < n; ++i) {
+ for (int i = 0; i < n; ++i) {
a[i] = b[i] + 1;
foo();
// CHECK: invoke void [[FOO:.+]](
More information about the llvm-branch-commits
mailing list