Skip to content

Commit 46b66df

Browse files
authored
[flang][NFC] use tablegen to create StackArrays constructor (#90038)
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.
1 parent 08dc03c commit 46b66df

File tree

4 files changed

+2
-7
lines changed

4 files changed

+2
-7
lines changed

flang/include/flang/Optimizer/Transforms/Passes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ namespace fir {
4747
#define GEN_PASS_DECL_POLYMORPHICOPCONVERSION
4848
#define GEN_PASS_DECL_OPENACCDATAOPERANDCONVERSION
4949
#define GEN_PASS_DECL_ADDDEBUGINFO
50+
#define GEN_PASS_DECL_STACKARRAYS
5051
#define GEN_PASS_DECL_LOOPVERSIONING
5152
#include "flang/Optimizer/Transforms/Passes.h.inc"
5253

@@ -59,7 +60,6 @@ createExternalNameConversionPass(bool appendUnderscore);
5960
std::unique_ptr<mlir::Pass> createMemDataFlowOptPass();
6061
std::unique_ptr<mlir::Pass> createPromoteToAffinePass();
6162
std::unique_ptr<mlir::Pass> createMemoryAllocationPass();
62-
std::unique_ptr<mlir::Pass> createStackArraysPass();
6363
std::unique_ptr<mlir::Pass> createAliasTagsPass();
6464
std::unique_ptr<mlir::Pass>
6565
createAddDebugInfoPass(fir::AddDebugInfoOptions options = {});

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ def StackArrays : Pass<"stack-arrays", "mlir::ModuleOp"> {
257257
allocations.
258258
}];
259259
let dependentDialects = [ "fir::FIROpsDialect" ];
260-
let constructor = "::fir::createStackArraysPass()";
261260
}
262261

263262
def AddAliasTags : Pass<"fir-add-alias-tags", "mlir::ModuleOp"> {

flang/include/flang/Tools/CLOptions.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ inline void createDefaultFIROptimizerPassPipeline(
258258
pm.addPass(mlir::createCSEPass());
259259

260260
if (pc.StackArrays)
261-
pm.addPass(fir::createStackArraysPass());
261+
pm.addPass(fir::createStackArrays());
262262
else
263263
fir::addMemoryAllocationOpt(pm);
264264

flang/lib/Optimizer/Transforms/StackArrays.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,3 @@ void StackArraysPass::runOnFunc(mlir::Operation *func) {
776776
signalPassFailure();
777777
}
778778
}
779-
780-
std::unique_ptr<mlir::Pass> fir::createStackArraysPass() {
781-
return std::make_unique<StackArraysPass>();
782-
}

0 commit comments

Comments
 (0)