[flang-commits] [flang] 1f63a56 - [flang][CodeGen] Run PreCGRewrite on omp reduction declare ops (#84954)
via flang-commits
flang-commits at lists.llvm.org
Wed Mar 20 02:52:07 PDT 2024
Author: Tom Eccles
Date: 2024-03-20T09:52:04Z
New Revision: 1f63a56cede85bcd5f4fea3663bd3a47b801a396
URL: https://github.com/llvm/llvm-project/commit/1f63a56cede85bcd5f4fea3663bd3a47b801a396
DIFF: https://github.com/llvm/llvm-project/commit/1f63a56cede85bcd5f4fea3663bd3a47b801a396.diff
LOG: [flang][CodeGen] Run PreCGRewrite on omp reduction declare ops (#84954)
OpenMP reduction declare operations can contain FIR code which needs to
be lowered to LLVM. With array reductions, these regions can contain
more complicated operations which need PreCGRewriting. A similar extra
case was already needed for fir::GlobalOp.
OpenMP array reductions 3/6
Previous PR: https://github.com/llvm/llvm-project/pull/84953
Next PR: https://github.com/llvm/llvm-project/pull/84955
Added:
Modified:
flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
Removed:
################################################################################
diff --git a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
index 9d48a2f08aba03..665bf09b8fc33b 100644
--- a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
+++ b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
@@ -283,7 +283,9 @@ class DeclareOpConversion : public mlir::OpRewritePattern<fir::DeclareOp> {
class CodeGenRewrite : public fir::impl::CodeGenRewriteBase<CodeGenRewrite> {
public:
- void runOn(mlir::Operation *op, mlir::Region ®ion) {
+ void runOnOperation() override final {
+ mlir::ModuleOp mod = getOperation();
+
auto &context = getContext();
mlir::ConversionTarget target(context);
target.addLegalDialect<mlir::arith::ArithDialect, fir::FIROpsDialect,
@@ -300,7 +302,7 @@ class CodeGenRewrite : public fir::impl::CodeGenRewriteBase<CodeGenRewrite> {
mlir::RewritePatternSet patterns(&context);
fir::populatePreCGRewritePatterns(patterns);
if (mlir::failed(
- mlir::applyPartialConversion(op, target, std::move(patterns)))) {
+ mlir::applyPartialConversion(mod, target, std::move(patterns)))) {
mlir::emitError(mlir::UnknownLoc::get(&context),
"error in running the pre-codegen conversions");
signalPassFailure();
@@ -308,16 +310,7 @@ class CodeGenRewrite : public fir::impl::CodeGenRewriteBase<CodeGenRewrite> {
}
// Erase any residual (fir.shape, fir.slice...).
mlir::IRRewriter rewriter(&context);
- (void)mlir::runRegionDCE(rewriter, op->getRegions());
- }
-
- void runOnOperation() override final {
- // Call runOn on all top level regions that may contain emboxOp/arrayCoorOp.
- auto mod = getOperation();
- for (auto func : mod.getOps<mlir::func::FuncOp>())
- runOn(func, func.getBody());
- for (auto global : mod.getOps<fir::GlobalOp>())
- runOn(global, global.getRegion());
+ (void)mlir::runRegionDCE(rewriter, mod->getRegions());
}
};
More information about the flang-commits
mailing list