r246757 - [OPENMP] Fix for http://llvm.org/PR24687: ICE on compilation of R package TPmsm.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 3 03:21:47 PDT 2015
Author: abataev
Date: Thu Sep 3 05:21:46 2015
New Revision: 246757
URL: http://llvm.org/viewvc/llvm-project?rev=246757&view=rev
Log:
[OPENMP] Fix for http://llvm.org/PR24687: ICE on compilation of R package TPmsm.
Fixed capturing of VLAs in 'private' clause of the OpenMP directives.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=246757&r1=246756&r2=246757&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Sep 3 05:21:46 2015
@@ -13000,21 +13000,6 @@ bool Sema::tryCaptureVariable(
if (isVariableAlreadyCapturedInScopeInfo(CSI, Var, Nested, CaptureType,
DeclRefType))
break;
- if (getLangOpts().OpenMP) {
- if (auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
- // OpenMP private variables should not be captured in outer scope, so
- // just break here.
- if (RSI->CapRegionKind == CR_OpenMP) {
- if (isOpenMPPrivateVar(Var, OpenMPLevel)) {
- Nested = true;
- DeclRefType = DeclRefType.getUnqualifiedType();
- CaptureType = Context.getLValueReferenceType(DeclRefType);
- break;
- }
- ++OpenMPLevel;
- }
- }
- }
// If we are instantiating a generic lambda call operator body,
// we do not want to capture new variables. What was captured
// during either a lambdas transformation or initial parsing
@@ -13160,6 +13145,21 @@ bool Sema::tryCaptureVariable(
} while (!QTy.isNull() && QTy->isVariablyModifiedType());
}
+ if (getLangOpts().OpenMP) {
+ if (auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
+ // OpenMP private variables should not be captured in outer scope, so
+ // just break here.
+ if (RSI->CapRegionKind == CR_OpenMP) {
+ if (isOpenMPPrivateVar(Var, OpenMPLevel)) {
+ Nested = true;
+ DeclRefType = DeclRefType.getUnqualifiedType();
+ CaptureType = Context.getLValueReferenceType(DeclRefType);
+ break;
+ }
+ ++OpenMPLevel;
+ }
+ }
+ }
if (CSI->ImpCaptureStyle == CapturingScopeInfo::ImpCap_None && !Explicit) {
// No capture-default, and this is not an explicit capture
// so cannot capture this variable.
Modified: cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_codegen.cpp?rev=246757&r1=246756&r2=246757&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/parallel_for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_codegen.cpp Thu Sep 3 05:21:46 2015
@@ -378,8 +378,9 @@ int foo() {return 0;};
// TERM_DEBUG-LABEL: parallel_for
// CLEANUP: parallel_for
-void parallel_for(float *a) {
-#pragma omp parallel for schedule(static, 5)
+void parallel_for(float *a, int n) {
+ float arr[n];
+#pragma omp parallel for schedule(static, 5) private(arr)
// TERM_DEBUG-NOT: __kmpc_global_thread_num
// TERM_DEBUG: call void @__kmpc_for_static_init_4u({{.+}}), !dbg [[DBG_LOC_START:![0-9]+]]
// TERM_DEBUG: invoke i32 {{.*}}foo{{.*}}()
@@ -395,7 +396,7 @@ void parallel_for(float *a) {
// CLEANUP: call void @__kmpc_for_static_fini({{.+}})
// CLEANUP: call {{.+}} @__kmpc_barrier({{.+}})
for (unsigned i = 131071; i <= 2147483647; i += 127)
- a[i] += foo();
+ a[i] += foo() + arr[i];
}
// Check source line corresponds to "#pragma omp parallel for schedule(static, 5)" above:
// TERM_DEBUG-DAG: [[DBG_LOC_START]] = !DILocation(line: [[@LINE-4]],
More information about the cfe-commits
mailing list