Skip to content

Commit 1e64864

Browse files
authored
[flang][StackArrays] run in parallel on different functions (#108842)
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.
1 parent 88a9bca commit 1e64864

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

flang/include/flang/Optimizer/Transforms/Passes.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def ConstantArgumentGlobalisationOpt : Pass<"constant-argument-globalisation-opt
278278
let dependentDialects = [ "fir::FIROpsDialect" ];
279279
}
280280

281-
def StackArrays : Pass<"stack-arrays", "mlir::ModuleOp"> {
281+
def StackArrays : Pass<"stack-arrays", "mlir::func::FuncOp"> {
282282
let summary = "Move local array allocations from heap memory into stack memory";
283283
let description = [{
284284
Convert heap allocations for arrays, even those of unknown size, into stack

flang/lib/Optimizer/Transforms/StackArrays.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ class StackArraysPass : public fir::impl::StackArraysBase<StackArraysPass> {
225225
llvm::StringRef getDescription() const override;
226226

227227
void runOnOperation() override;
228-
void runOnFunc(mlir::Operation *func);
229228

230229
private:
231230
Statistic runCount{this, "stackArraysRunCount",
@@ -766,13 +765,7 @@ llvm::StringRef StackArraysPass::getDescription() const {
766765
}
767766

768767
void StackArraysPass::runOnOperation() {
769-
mlir::ModuleOp mod = getOperation();
770-
771-
mod.walk([this](mlir::func::FuncOp func) { runOnFunc(func); });
772-
}
773-
774-
void StackArraysPass::runOnFunc(mlir::Operation *func) {
775-
assert(mlir::isa<mlir::func::FuncOp>(func));
768+
mlir::func::FuncOp func = getOperation();
776769

777770
auto &analysis = getAnalysis<StackArraysAnalysisWrapper>();
778771
const StackArraysAnalysisWrapper::AllocMemMap *candidateOps =

0 commit comments

Comments
 (0)