-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flang][openacc] Use OpenACC terminator instead of fir.unreachable after Stop stmt #66325
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ter Stop stmt This follow an update made on OpenMP https://reviews.llvm.org/D129969 and was not possible on OpenACC until the unstructured construct was supported.
llvmbot
added
flang
Flang issues not falling into any other category
flang:fir-hlfir
openacc
labels
Sep 14, 2023
@llvm/pr-subscribers-flang-fir-hlfir ChangesThis follow an update made on OpenMP https://reviews.llvm.org/D129969 and was not possible on OpenACC until the unstructured construct was supported. -- Full diff: https://github.com//pull/66325.diff5 Files Affected:
diff --git a/flang/include/flang/Lower/OpenACC.h b/flang/include/flang/Lower/OpenACC.h index 429b548cc22bd47..b342e4a4704dab1 100644 --- a/flang/include/flang/Lower/OpenACC.h +++ b/flang/include/flang/Lower/OpenACC.h @@ -103,6 +103,9 @@ void attachDeclarePreDeallocAction(AbstractConverter &, fir::FirOpBuilder &, void attachDeclarePostDeallocAction(AbstractConverter &, fir::FirOpBuilder &, const Fortran::semantics::Symbol &); +void genOpenACCTerminator(fir::FirOpBuilder &, mlir::Operation *, + mlir::Location); + } // namespace lower } // namespace Fortran diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index 180c077d39c9ee2..04078d739ea78c4 100644 --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -3299,3 +3299,12 @@ void Fortran::lower::attachDeclarePostDeallocAction( /*preAlloc=*/{}, /*postAlloc=*/{}, /*preDealloc=*/{}, /*postDealloc=*/builder.getSymbolRefAttr(fctName.str()))); } + +void Fortran::lower::genOpenACCTerminator(fir::FirOpBuilder &builder, + mlir::Operation *op, + mlir::Location loc) { + if (mlir::isa<mlir::acc::ParallelOp, mlir::acc::LoopOp>(op)) + builder.create<mlir::acc::YieldOp>(loc); + else + builder.create<mlir::acc::TerminatorOp>(loc); +} diff --git a/flang/lib/Lower/Runtime.cpp b/flang/lib/Lower/Runtime.cpp index 11cb56c72d75932..2cf1e522d330d4c 100644 --- a/flang/lib/Lower/Runtime.cpp +++ b/flang/lib/Lower/Runtime.cpp @@ -8,6 +8,7 @@ #include "flang/Lower/Runtime.h" #include "flang/Lower/Bridge.h" +#include "flang/Lower/OpenACC.h" #include "flang/Lower/OpenMP.h" #include "flang/Lower/StatementContext.h" #include "flang/Optimizer/Builder/FIRBuilder.h" @@ -21,6 +22,7 @@ #include "flang/Runtime/stop.h" #include "flang/Runtime/time-intrinsic.h" #include "flang/Semantics/tools.h" +#include "mlir/Dialect/OpenACC/OpenACC.h" #include "mlir/Dialect/OpenMP/OpenMPDialect.h" #include "llvm/Support/Debug.h" #include <optional> @@ -37,6 +39,9 @@ static void genUnreachable(fir::FirOpBuilder &builder, mlir::Location loc) { if (parentOp->getDialect()->getNamespace() == mlir::omp::OpenMPDialect::getDialectNamespace()) Fortran::lower::genOpenMPTerminator(builder, parentOp, loc); + else if (parentOp->getDialect()->getNamespace() == + mlir::acc::OpenACCDialect::getDialectNamespace()) + Fortran::lower::genOpenACCTerminator(builder, parentOp, loc); else builder.create<fir::UnreachableOp>(loc); mlir::Block *newBlock = curBlock->splitBlock(builder.getInsertionPoint()); diff --git a/flang/test/Lower/OpenACC/acc-unstructured.f90 b/flang/test/Lower/OpenACC/acc-unstructured.f90 index bd9f3284d9fc25c..4ce474241a4bec7 100644 --- a/flang/test/Lower/OpenACC/acc-unstructured.f90 +++ b/flang/test/Lower/OpenACC/acc-unstructured.f90 @@ -57,7 +57,7 @@ subroutine test_unstructured2(a, b, c) ! CHECK: acc.parallel ! CHECK: acc.loop ! CHECK: fir.call @_FortranAStopStatementText -! CHECK: fir.unreachable +! CHECK: acc.yield ! CHECK: acc.yield ! CHECK: acc.yield @@ -80,7 +80,7 @@ subroutine test_unstructured3(a, b, c) ! CHECK-LABEL: func.func @_QPtest_unstructured3 ! CHECK: acc.parallel ! CHECK: fir.call @_FortranAStopStatementText -! CHECK: fir.unreachable +! CHECK: acc.yield ! CHECK: acc.yield end subroutine diff --git a/flang/test/Lower/OpenACC/stop-stmt-in-region.f90 b/flang/test/Lower/OpenACC/stop-stmt-in-region.f90 index bec9d53b54c0f1d..4b3e5632650f1cf 100644 --- a/flang/test/Lower/OpenACC/stop-stmt-in-region.f90 +++ b/flang/test/Lower/OpenACC/stop-stmt-in-region.f90 @@ -29,7 +29,7 @@ subroutine test_stop_in_region1() ! CHECK: %[[VAL_2:.*]] = arith.constant false ! CHECK: %[[VAL_3:.*]] = arith.constant false ! CHECK: %[[VAL_4:.*]] = fir.call @_FortranAStopStatement(%[[VAL_1]], %[[VAL_2]], %[[VAL_3]]) {{.*}} : (i32, i1, i1) -> none -! CHECK: fir.unreachable +! CHECK: acc.yield ! CHECK: } ! CHECK: return ! CHECK: } |
vzakhari
approved these changes
Sep 14, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
kstoimenov
pushed a commit
to kstoimenov/llvm-project
that referenced
this pull request
Sep 14, 2023
…ter Stop stmt (llvm#66325) This follow an update made on OpenMP https://reviews.llvm.org/D129969 and was not possible on OpenACC until the unstructured construct was supported.
This was referenced Sep 14, 2023
ZijunZhaoCCK
pushed a commit
to ZijunZhaoCCK/llvm-project
that referenced
this pull request
Sep 19, 2023
…ter Stop stmt (llvm#66325) This follow an update made on OpenMP https://reviews.llvm.org/D129969 and was not possible on OpenACC until the unstructured construct was supported.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This follow an update made on OpenMP https://reviews.llvm.org/D129969 and was not possible on OpenACC until the unstructured construct was supported.