[flang-commits] [flang] [flang][StackArrays] run in parallel on different functions (PR #108842)
via flang-commits
flang-commits at lists.llvm.org
Mon Sep 16 08:22:52 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Tom Eccles (tblah)
<details>
<summary>Changes</summary>
Since #<!-- -->108562, StackArrays no longer has to create function declarations at the module level to use stacksave/stackrestore LLVM intrinsics. This will allow it to run in parallel on multiple functions at the same time.
---
Full diff: https://github.com/llvm/llvm-project/pull/108842.diff
2 Files Affected:
- (modified) flang/include/flang/Optimizer/Transforms/Passes.td (+1-1)
- (modified) flang/lib/Optimizer/Transforms/StackArrays.cpp (+1-8)
``````````diff
diff --git a/flang/include/flang/Optimizer/Transforms/Passes.td b/flang/include/flang/Optimizer/Transforms/Passes.td
index 49bd4f5349a754..925ada0f9d3507 100644
--- a/flang/include/flang/Optimizer/Transforms/Passes.td
+++ b/flang/include/flang/Optimizer/Transforms/Passes.td
@@ -278,7 +278,7 @@ def ConstantArgumentGlobalisationOpt : Pass<"constant-argument-globalisation-opt
let dependentDialects = [ "fir::FIROpsDialect" ];
}
-def StackArrays : Pass<"stack-arrays", "mlir::ModuleOp"> {
+def StackArrays : Pass<"stack-arrays", "mlir::func::FuncOp"> {
let summary = "Move local array allocations from heap memory into stack memory";
let description = [{
Convert heap allocations for arrays, even those of unknown size, into stack
diff --git a/flang/lib/Optimizer/Transforms/StackArrays.cpp b/flang/lib/Optimizer/Transforms/StackArrays.cpp
index 1b929928dc7164..d9e7bd684d4600 100644
--- a/flang/lib/Optimizer/Transforms/StackArrays.cpp
+++ b/flang/lib/Optimizer/Transforms/StackArrays.cpp
@@ -225,7 +225,6 @@ class StackArraysPass : public fir::impl::StackArraysBase<StackArraysPass> {
llvm::StringRef getDescription() const override;
void runOnOperation() override;
- void runOnFunc(mlir::Operation *func);
private:
Statistic runCount{this, "stackArraysRunCount",
@@ -766,13 +765,7 @@ llvm::StringRef StackArraysPass::getDescription() const {
}
void StackArraysPass::runOnOperation() {
- mlir::ModuleOp mod = getOperation();
-
- mod.walk([this](mlir::func::FuncOp func) { runOnFunc(func); });
-}
-
-void StackArraysPass::runOnFunc(mlir::Operation *func) {
- assert(mlir::isa<mlir::func::FuncOp>(func));
+ mlir::func::FuncOp func = getOperation();
auto &analysis = getAnalysis<StackArraysAnalysisWrapper>();
const StackArraysAnalysisWrapper::AllocMemMap *candidateOps =
``````````
</details>
https://github.com/llvm/llvm-project/pull/108842
More information about the flang-commits
mailing list