diff options
author | Valentin Clement (バレンタイン クレメン) <clementval@gmail.com> | 2023-11-14 14:42:11 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-14 14:42:11 -0800 |
commit | a3700cc29da8fc48361256609bc0903ff94106c7 (patch) | |
tree | 2c14cd56008da21bcdf5467af63322fc9155410a /flang/lib/Lower/Bridge.cpp | |
parent | 70150d5d068d4808facf045e26b688ca6721d611 (diff) | |
download | llvm-a3700cc29da8fc48361256609bc0903ff94106c7.zip llvm-a3700cc29da8fc48361256609bc0903ff94106c7.tar.gz llvm-a3700cc29da8fc48361256609bc0903ff94106c7.tar.bz2 |
[flang][openacc] Make implicit declare region unstructured (#71591)
Using an op with a region cause some issue with unstructured code. This
patch make use of acc.declare_enter and acc.declare_exit to represent
the implicit declare region.
Diffstat (limited to 'flang/lib/Lower/Bridge.cpp')
-rw-r--r-- | flang/lib/Lower/Bridge.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp index 59906c6..872bf6b 100644 --- a/flang/lib/Lower/Bridge.cpp +++ b/flang/lib/Lower/Bridge.cpp @@ -1431,6 +1431,7 @@ private: resultRef = builder->createConvert(loc, resultRefType, resultRef); return builder->create<fir::LoadOp>(loc, resultRef); }); + bridge.openAccCtx().finalizeAndPop(); bridge.fctCtx().finalizeAndPop(); builder->create<mlir::func::ReturnOp>(loc, resultVal); } @@ -1458,9 +1459,11 @@ private: } else if (Fortran::semantics::HasAlternateReturns(symbol)) { mlir::Value retval = builder->create<fir::LoadOp>( toLocation(), getAltReturnResult(symbol)); + bridge.openAccCtx().finalizeAndPop(); bridge.fctCtx().finalizeAndPop(); builder->create<mlir::func::ReturnOp>(toLocation(), retval); } else { + bridge.openAccCtx().finalizeAndPop(); bridge.fctCtx().finalizeAndPop(); genExitRoutine(); } @@ -2388,7 +2391,8 @@ private: void genFIR(const Fortran::parser::OpenACCDeclarativeConstruct &accDecl) { genOpenACCDeclarativeConstruct(*this, bridge.getSemanticsContext(), - bridge.fctCtx(), accDecl, accRoutineInfos); + bridge.openAccCtx(), accDecl, + accRoutineInfos); for (Fortran::lower::pft::Evaluation &e : getEval().getNestedEvaluations()) genFIR(e); } @@ -4204,6 +4208,7 @@ private: void startNewFunction(Fortran::lower::pft::FunctionLikeUnit &funit) { assert(!builder && "expected nullptr"); bridge.fctCtx().pushScope(); + bridge.openAccCtx().pushScope(); const Fortran::semantics::Scope &scope = funit.getScope(); LLVM_DEBUG(llvm::dbgs() << "\n[bridge - startNewFunction]"; if (auto *sym = scope.symbol()) llvm::dbgs() << " " << *sym; @@ -4444,6 +4449,7 @@ private: void endNewFunction(Fortran::lower::pft::FunctionLikeUnit &funit) { setCurrentPosition(Fortran::lower::pft::stmtSourceLoc(funit.endStmt)); if (funit.isMainProgram()) { + bridge.openAccCtx().finalizeAndPop(); bridge.fctCtx().finalizeAndPop(); genExitRoutine(); } else { |