Skip to content

Commit

Permalink
[flang][NFC] use tablegen to create StackArrays constructor (#90038)
Browse files Browse the repository at this point in the history
Stack arrays needs to stay running only on func.func because it needs to
know which block terminators can end the function (rather than just
branch between unstructured control flow). A similar concept does not
exist at the more abstract level of "any top level mlir operation".

For example, it currently looks for func::ReturnOp and
fir::UnreachableOp as points when execution can end. If this were to be
run on omp.declare_reduction, it would also need to understand
omp.YieldOp (perhaps only when omp.declare_reduction is the parent).
There isn't a generic concept in MLIR for this.
  • Loading branch information
tblah committed Apr 26, 2024
1 parent 08dc03c commit 46b66df
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion flang/include/flang/Optimizer/Transforms/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace fir {
#define GEN_PASS_DECL_POLYMORPHICOPCONVERSION
#define GEN_PASS_DECL_OPENACCDATAOPERANDCONVERSION
#define GEN_PASS_DECL_ADDDEBUGINFO
#define GEN_PASS_DECL_STACKARRAYS
#define GEN_PASS_DECL_LOOPVERSIONING
#include "flang/Optimizer/Transforms/Passes.h.inc"

Expand All @@ -59,7 +60,6 @@ createExternalNameConversionPass(bool appendUnderscore);
std::unique_ptr<mlir::Pass> createMemDataFlowOptPass();
std::unique_ptr<mlir::Pass> createPromoteToAffinePass();
std::unique_ptr<mlir::Pass> createMemoryAllocationPass();
std::unique_ptr<mlir::Pass> createStackArraysPass();
std::unique_ptr<mlir::Pass> createAliasTagsPass();
std::unique_ptr<mlir::Pass>
createAddDebugInfoPass(fir::AddDebugInfoOptions options = {});
Expand Down
1 change: 0 additions & 1 deletion flang/include/flang/Optimizer/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ def StackArrays : Pass<"stack-arrays", "mlir::ModuleOp"> {
allocations.
}];
let dependentDialects = [ "fir::FIROpsDialect" ];
let constructor = "::fir::createStackArraysPass()";
}

def AddAliasTags : Pass<"fir-add-alias-tags", "mlir::ModuleOp"> {
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Tools/CLOptions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ inline void createDefaultFIROptimizerPassPipeline(
pm.addPass(mlir::createCSEPass());

if (pc.StackArrays)
pm.addPass(fir::createStackArraysPass());
pm.addPass(fir::createStackArrays());
else
fir::addMemoryAllocationOpt(pm);

Expand Down
4 changes: 0 additions & 4 deletions flang/lib/Optimizer/Transforms/StackArrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,3 @@ void StackArraysPass::runOnFunc(mlir::Operation *func) {
signalPassFailure();
}
}

std::unique_ptr<mlir::Pass> fir::createStackArraysPass() {
return std::make_unique<StackArraysPass>();
}

0 comments on commit 46b66df

Please sign in to comment.