[flang][OpenMP] Set isNewBlock directly on OpenMP constructs (#144593)
When the PFT builder decides that an evaluation needs a new block it checks if the evaluation has nested evaluations. In such case it sets the flag on the first nested evaluation. This works under the assuption that such an evaluation only serves as a container, and does not, by itself, generate any code. This fails for OpenMP constructs that contain nested evaluations because the top-level evaluation does generate code that wraps the code from the nested evaluations. In such cases, the code for the top-level evaluation may be emitted in a wrong place. When setting the `isNewBlock` flag, recognize OpenMP directives, and treat them accordingly. This fixes https://github.com/llvm/llvm-project/issues/139071
This commit is contained in:
committed by
GitHub
parent
9a6a87da6e
commit
fb209929e1
@@ -1096,7 +1096,9 @@ private:
|
||||
|
||||
// The first executable statement in the subprogram is preceded by a
|
||||
// branch to the entry point, so it starts a new block.
|
||||
if (initialEval->hasNestedEvaluations())
|
||||
// OpenMP directives can generate code around the nested evaluations.
|
||||
if (initialEval->hasNestedEvaluations() &&
|
||||
!initialEval->isOpenMPDirective())
|
||||
initialEval = &initialEval->getFirstNestedEvaluation();
|
||||
else if (initialEval->isA<Fortran::parser::EntryStmt>())
|
||||
initialEval = initialEval->lexicalSuccessor;
|
||||
|
||||
Reference in New Issue
Block a user