forked from OSchip/llvm-project
[OPENMP] Fix possible assert for target regions with incorrect inner
teams region. If the inner teams region is not correct, it may cause an assertion when processing outer target region. Patch fixes this problem. llvm-svn: 319450
This commit is contained in:
parent
de38b3d22f
commit
ceabd41cf7
|
@ -2674,7 +2674,6 @@ static bool checkNestingOfRegions(Sema &SemaRef, DSAStackTy *Stack,
|
|||
NestingProhibited = ParentRegion != OMPD_target;
|
||||
OrphanSeen = ParentRegion == OMPD_unknown;
|
||||
Recommend = ShouldBeInTargetRegion;
|
||||
Stack->setParentTeamsRegionLoc(Stack->getConstructLoc());
|
||||
}
|
||||
if (!NestingProhibited &&
|
||||
!isOpenMPTargetExecutionDirective(CurrentRegion) &&
|
||||
|
@ -6569,6 +6568,8 @@ StmtResult Sema::ActOnOpenMPTeamsDirective(ArrayRef<OMPClause *> Clauses,
|
|||
|
||||
getCurFunction()->setHasBranchProtectedScope();
|
||||
|
||||
DSAStack->setParentTeamsRegionLoc(StartLoc);
|
||||
|
||||
return OMPTeamsDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt);
|
||||
}
|
||||
|
||||
|
@ -7071,6 +7072,9 @@ StmtResult Sema::ActOnOpenMPTeamsDistributeDirective(
|
|||
"omp teams distribute loop exprs were not built");
|
||||
|
||||
getCurFunction()->setHasBranchProtectedScope();
|
||||
|
||||
DSAStack->setParentTeamsRegionLoc(StartLoc);
|
||||
|
||||
return OMPTeamsDistributeDirective::Create(
|
||||
Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
|
||||
}
|
||||
|
@ -7119,6 +7123,9 @@ StmtResult Sema::ActOnOpenMPTeamsDistributeSimdDirective(
|
|||
return StmtError();
|
||||
|
||||
getCurFunction()->setHasBranchProtectedScope();
|
||||
|
||||
DSAStack->setParentTeamsRegionLoc(StartLoc);
|
||||
|
||||
return OMPTeamsDistributeSimdDirective::Create(
|
||||
Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
|
||||
}
|
||||
|
@ -7167,6 +7174,9 @@ StmtResult Sema::ActOnOpenMPTeamsDistributeParallelForSimdDirective(
|
|||
return StmtError();
|
||||
|
||||
getCurFunction()->setHasBranchProtectedScope();
|
||||
|
||||
DSAStack->setParentTeamsRegionLoc(StartLoc);
|
||||
|
||||
return OMPTeamsDistributeParallelForSimdDirective::Create(
|
||||
Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
|
||||
}
|
||||
|
@ -7213,6 +7223,9 @@ StmtResult Sema::ActOnOpenMPTeamsDistributeParallelForDirective(
|
|||
"omp for loop exprs were not built");
|
||||
|
||||
getCurFunction()->setHasBranchProtectedScope();
|
||||
|
||||
DSAStack->setParentTeamsRegionLoc(StartLoc);
|
||||
|
||||
return OMPTeamsDistributeParallelForDirective::Create(
|
||||
Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B,
|
||||
DSAStack->isCancelRegion());
|
||||
|
|
|
@ -689,6 +689,9 @@ void test_loop_eh() {
|
|||
void g() { throw 0; }
|
||||
};
|
||||
}
|
||||
#pragma omp target
|
||||
#pragma omp teams distribute
|
||||
f; // expected-error {{use of undeclared identifier 'f'}}
|
||||
}
|
||||
|
||||
void test_loop_firstprivate_lastprivate() {
|
||||
|
|
|
@ -9,6 +9,9 @@ static int pvt;
|
|||
#pragma omp teams distribute parallel for // expected-error {{unexpected OpenMP directive '#pragma omp teams distribute parallel for'}}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#pragma omp target
|
||||
#pragma omp teams distribute parallel for
|
||||
f; // expected-error {{use of undeclared identifier 'f'}}
|
||||
#pragma omp target
|
||||
#pragma omp teams distribute parallel for { // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
|
||||
for (int i = 0; i < argc; ++i)
|
||||
|
|
|
@ -9,6 +9,9 @@ static int pvt;
|
|||
#pragma omp teams distribute parallel for simd // expected-error {{unexpected OpenMP directive '#pragma omp teams distribute parallel for simd'}}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#pragma omp target
|
||||
#pragma omp teams distribute parallel for simd
|
||||
f; // expected-error {{use of undeclared identifier 'f'}}
|
||||
#pragma omp target
|
||||
#pragma omp teams distribute parallel for simd { // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}}
|
||||
for (int i = 0; i < argc; ++i)
|
||||
|
|
|
@ -9,6 +9,9 @@ static int pvt;
|
|||
#pragma omp teams distribute simd // expected-error {{unexpected OpenMP directive '#pragma omp teams distribute simd'}}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#pragma omp target
|
||||
#pragma omp teams distribute simd
|
||||
f; // expected-error {{use of undeclared identifier 'f'}}
|
||||
#pragma omp target
|
||||
#pragma omp teams distribute simd { // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
|
||||
for (int i = 0; i < argc; ++i)
|
||||
|
|
|
@ -6,6 +6,9 @@ void foo() {
|
|||
#pragma omp teams // expected-error {{unexpected OpenMP directive '#pragma omp teams'}}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#pragma omp target
|
||||
#pragma omp teams
|
||||
f; // expected-error {{use of undeclared identifier 'f'}}
|
||||
#pragma omp target
|
||||
#pragma omp teams { // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
|
||||
foo();
|
||||
|
|
Loading…
Reference in New Issue