Skip to content

Commit e3e7b0f

Browse files
authored
Merge pull request #233 from flang-compiler/ch-inlineprep
prep work so we can upstream a trivial inlining pass
2 parents f385b28 + 9558be5 commit e3e7b0f

File tree

4 files changed

+6
-24
lines changed

4 files changed

+6
-24
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@ std::unique_ptr<mlir::Pass> createFirToCfgPass();
4242
/// nodes as block arguments.
4343
std::unique_ptr<mlir::Pass> createMemToRegPass();
4444

45-
/// This pass will preform inlining on FIR.
46-
std::unique_ptr<mlir::Pass> createInlinerPass();
47-
48-
/// Is inlining enabled? Check this before instantiating the pass with
49-
/// createInlinerPass().
50-
bool inlinerIsEnabled();
45+
/// Support for inlining on FIR.
5146
bool canLegallyInline(mlir::Operation *op, mlir::Region *reg,
5247
mlir::BlockAndValueMapping &map);
5348

flang/lib/Optimizer/Transforms/Inliner.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,12 @@
1313
#include "llvm/Support/CommandLine.h"
1414

1515
static llvm::cl::opt<bool>
16-
enableInliningPass("enable-inlining",
17-
llvm::cl::desc("enable FIR inlining pass"),
16+
aggressivelyInline("inline-all",
17+
llvm::cl::desc("aggressively inline everything"),
1818
llvm::cl::init(false));
1919

2020
/// Should we inline the callable `op` into region `reg`?
2121
bool fir::canLegallyInline(mlir::Operation *op, mlir::Region *reg,
2222
mlir::BlockAndValueMapping &map) {
23-
// TODO: this should _not_ just return true.
24-
return true;
25-
}
26-
27-
/// Should an inlining pass be instantiated?
28-
bool fir::inlinerIsEnabled() { return enableInliningPass; }
29-
30-
/// Instantiate an inlining pass. NB: If inlining is disabled, the compiler will
31-
/// abort if an inlining pass is instantiated.
32-
std::unique_ptr<mlir::Pass> fir::createInlinerPass() {
33-
if (enableInliningPass)
34-
return mlir::createInlinerPass();
35-
llvm::report_fatal_error("inlining is disabled");
23+
return aggressivelyInline;
3624
}

flang/test/Fir/inline.fir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: tco --enable-inlining %s -o - | FileCheck %s
1+
// RUN: tco --inline-all %s -o - | FileCheck %s
22

33
// CHECK-LABEL: @add
44
func @add(%a : i32, %b : i32) -> i32 {

flang/tools/tco/tco.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ static int compileFIR(const mlir::PassPipelineCLParser &passPipeline) {
9393
// simplify the IR
9494
pm.addPass(mlir::createCanonicalizerPass());
9595
pm.addPass(fir::createCSEPass());
96-
if (fir::inlinerIsEnabled())
97-
pm.addPass(fir::createInlinerPass());
96+
pm.addPass(mlir::createInlinerPass());
9897
pm.addPass(mlir::createCSEPass());
9998

10099
// convert fir dialect to affine

0 commit comments

Comments
 (0)