[flang-commits] [flang] [flang][Lower] Emit exiting branches from within constructs (PR #92455)
via flang-commits
flang-commits at lists.llvm.org
Mon May 20 09:18:01 PDT 2024
vdonaldson wrote:
I believe the issue here is that individual directives sometimes act like action statements, sometimes like construct statements, and sometimes like constructs. The "simple2" test case can be resolved by treating the `OpenMPConstruct` directive like a construct, and the `OmpEndLoopDirective` directive like a construct statement, possibly with the following change.
One alternative to the first diff group below would be to instead add `OmpEndLoopDirective` to the `isExecutableDirective` group. Other variants might also be possible.
There may or may not be additional directive cases that should also be managed with similar changes. OpenMP and OpenACC directives are already given special treatment in various places. I think that special treatment should be extended to handle problems such as this one.
```
diff --git a/flang/lib/Lower/PFTBuilder.cpp b/flang/lib/Lower/PFTBuilder.cpp
index f196b9c5a0cb..e11329010cb9 100644
--- a/flang/lib/Lower/PFTBuilder.cpp
+++ b/flang/lib/Lower/PFTBuilder.cpp
@@ -467,7 +467,9 @@ private:
evaluationListStack.back()->emplace_back(std::move(eval));
lower::pft::Evaluation *p = &evaluationListStack.back()->back();
if (p->isActionStmt() || p->isConstructStmt() || p->isEndStmt() ||
- p->isExecutableDirective()) {
+ p->isExecutableDirective() ||
+ p->isA<Fortran::parser::OmpEndLoopDirective>()) {
+
if (lastLexicalEvaluation) {
lastLexicalEvaluation->lexicalSuccessor = p;
p->printIndex = lastLexicalEvaluation->printIndex + 1;
@@ -1024,6 +1026,9 @@ private:
},
[&](const parser::WhereConstruct &) { setConstructExit(eval); },
+ // Directives - set (unstructured) directive exit targets
+ [&](const parser::OpenMPConstruct &) { setConstructExit(eval); },
+
// Default - Common analysis for IO statements; otherwise nop.
[&](const auto &stmt) {
using A = std::decay_t<decltype(stmt)>;
```
https://github.com/llvm/llvm-project/pull/92455
More information about the flang-commits
mailing list