[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. llvm-svn: 246757
This commit is contained in:
parent
5055685cda
commit
b500101e1c
|
@ -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.
|
||||
|
|
|
@ -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]],
|
||||
|
|
Loading…
Reference in New Issue