Skip to content

Commit 4ce9005

Browse files
committed
change pass option style
1 parent 1204bb2 commit 4ce9005

File tree

6 files changed

+36
-10
lines changed

6 files changed

+36
-10
lines changed

llvm/include/llvm/CodeGen/MachineBlockPlacement.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class MachineBlockPlacementPass
2323
: AllowTailMerge(AllowTailMerge) {}
2424
PreservedAnalyses run(MachineFunction &MF,
2525
MachineFunctionAnalysisManager &MFAM);
26+
static bool isRequired() { return true; }
27+
28+
void
29+
printPipeline(raw_ostream &OS,
30+
function_ref<StringRef(StringRef)> MapClassName2PassName) const;
2631
};
2732

2833
} // namespace llvm

llvm/include/llvm/Passes/MachinePassRegistry.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ MACHINE_FUNCTION_PASS_WITH_PARAMS(
200200
// Default is true.
201201
return MachineBlockPlacementPass(AllowTailMerge);
202202
},
203-
parseMachineBlockPlacementPassOptions, "no-tail-merge;enable-tail-merge")
203+
parseMachineBlockPlacementPassOptions, "no-tail-merge;tail-merge")
204204

205205
MACHINE_FUNCTION_PASS_WITH_PARAMS(
206206
"machine-sink", "MachineSinkingPass",

llvm/lib/CodeGen/MachineBlockPlacement.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3544,6 +3544,14 @@ MachineBlockPlacementPass::run(MachineFunction &MF,
35443544
return getMachineFunctionPassPreservedAnalyses();
35453545
}
35463546

3547+
void MachineBlockPlacementPass::printPipeline(
3548+
raw_ostream &OS,
3549+
function_ref<StringRef(StringRef)> MapClassName2PassName) const {
3550+
OS << MapClassName2PassName(name());
3551+
if (!AllowTailMerge)
3552+
OS << "<no-tail-merge>";
3553+
}
3554+
35473555
bool MachineBlockPlacement::run(MachineFunction &MF) {
35483556

35493557
// Check for single-block functions and skip them.

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,14 +1442,14 @@ Expected<bool> parseMachineSinkingPassOptions(StringRef Params) {
14421442

14431443
Expected<bool> parseMachineBlockPlacementPassOptions(StringRef Params) {
14441444
bool AllowTailMerge = true;
1445-
if (Params == "no-tail-merge")
1446-
AllowTailMerge = false;
1447-
else if (!Params.empty() && Params != "enable-tail-merge")
1448-
return make_error<StringError>(
1449-
formatv("invalid MachineBlockPlacementPass parameter '{0}' ", Params)
1450-
.str(),
1451-
inconvertibleErrorCode());
1452-
1445+
if (!Params.empty()) {
1446+
AllowTailMerge = !Params.consume_front("no-");
1447+
if (Params != "tail-merge")
1448+
return make_error<StringError>(
1449+
formatv("invalid MachineBlockPlacementPass parameter '{0}' ", Params)
1450+
.str(),
1451+
inconvertibleErrorCode());
1452+
}
14531453
return AllowTailMerge;
14541454
}
14551455

llvm/test/CodeGen/AMDGPU/loop_header_nopred.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# RUN: llc -mtriple=amdgcn -o - -run-pass=block-placement -mcpu=gfx1010 -mattr=-inst-fwd-prefetch-bug -verify-machineinstrs %s | FileCheck -check-prefixes=GFX10 %s
33
# RUN: llc -mtriple=amdgcn -o - -run-pass=block-placement -mcpu=gfx1100 -mattr=-inst-fwd-prefetch-bug -verify-machineinstrs %s | FileCheck -check-prefixes=GFX11 %s
44

5-
# RUN: llc -mtriple=amdgcn -o - -passes='require<profile-summary>,function(machine-function(block-placement<enable-tail-merge>))' -mcpu=gfx1100 -mattr=-inst-fwd-prefetch-bug -verify-machineinstrs %s | FileCheck -check-prefixes=GFX11 %s
5+
# RUN: llc -mtriple=amdgcn -o - -passes='require<profile-summary>,function(machine-function(block-placement<tail-merge>))' -mcpu=gfx1100 -mattr=-inst-fwd-prefetch-bug -verify-machineinstrs %s | FileCheck -check-prefixes=GFX11 %s
66

77
# Used to fail with
88
# Assertion `Out && "Header of loop has no predecessors from outside loop?"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# RUN: llc -mtriple=x86_64-unknown-linux-gnu -passes="block-placement<tail-merge>,block-placement<no-tail-merge>" -print-pipeline-passes -o /dev/null %s 2>&1 | FileCheck %s --check-prefix=CHECK
2+
3+
# RUN: not llc -mtriple=x86_64-unknown-linux-gnu -passes="block-placement<invalid-opt>" -print-pipeline-passes -o /dev/null %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOT
4+
5+
# CHECK: block-placement,block-placement<no-tail-merge>
6+
# CHECK-NOT: invalid MachineBlockPlacementPass parameter 'invalid-opt'
7+
8+
---
9+
name: f
10+
body: |
11+
bb.0:
12+
RET 0
13+
...

0 commit comments

Comments
 (0)