Skip to content

Commit e8bc77e

Browse files
committed
[MachineOutliner] Fix label outlining regression introduced in D125072
Due to a change in the APIs used to determine what instructions can be outlined, the check for label outling was never hit. Instead, all labels were considered invisible, which is the opposite of the intended behavior and causes obscure crashes down the line. We now replicate the original behavior more closely, with explicit checks for known-good and known-bad instruction types. Reviewed by: paquette Differential Revision: https://reviews.llvm.org/D147178
1 parent a590d86 commit e8bc77e

File tree

2 files changed

+64
-4
lines changed

2 files changed

+64
-4
lines changed

llvm/lib/CodeGen/TargetInstrInfo.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,10 +1579,6 @@ outliner::InstrType TargetInstrInfo::getOutliningType(
15791579
// Just go right to the target implementation.
15801580
return getOutliningTypeImpl(MIT, Flags);
15811581

1582-
// Don't allow instructions that don't materialize to impact analysis.
1583-
if (MI.isMetaInstruction())
1584-
return outliner::InstrType::Invisible;
1585-
15861582
// Be conservative about inline assembly.
15871583
if (MI.isInlineAsm())
15881584
return outliner::InstrType::Illegal;
@@ -1591,6 +1587,21 @@ outliner::InstrType TargetInstrInfo::getOutliningType(
15911587
if (MI.isLabel())
15921588
return outliner::InstrType::Illegal;
15931589

1590+
// Don't let debug instructions impact analysis.
1591+
if (MI.isDebugInstr())
1592+
return outliner::InstrType::Invisible;
1593+
1594+
// Some other special cases.
1595+
switch (MI.getOpcode()) {
1596+
case TargetOpcode::IMPLICIT_DEF:
1597+
case TargetOpcode::KILL:
1598+
case TargetOpcode::LIFETIME_START:
1599+
case TargetOpcode::LIFETIME_END:
1600+
return outliner::InstrType::Invisible;
1601+
default:
1602+
break;
1603+
}
1604+
15941605
// Is this a terminator for a basic block?
15951606
if (MI.isTerminator()) {
15961607
// If this is a branch to another block, we can't outline it.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# RUN: llc -mtriple aarch64 -run-pass=machine-outliner -verify-machineinstrs %s -o - | FileCheck %s
2+
# CHECK-NOT: OUTLINED_FUNCTION
3+
4+
...
5+
---
6+
name: foo1
7+
tracksRegLiveness: true
8+
machineFunctionInfo:
9+
hasRedZone: false
10+
body: |
11+
bb.0:
12+
liveins: $x0
13+
$x0 = ADDXri $x0, 0, 0
14+
EH_LABEL <mcsymbol .Ltmp0>
15+
EH_LABEL <mcsymbol .Ltmp1>
16+
EH_LABEL <mcsymbol .Ltmp2>
17+
EH_LABEL <mcsymbol .Ltmp3>
18+
RET_ReallyLR implicit $x0
19+
...
20+
---
21+
name: foo2
22+
tracksRegLiveness: true
23+
machineFunctionInfo:
24+
hasRedZone: false
25+
body: |
26+
bb.0:
27+
liveins: $x0
28+
$x0 = ADDXri $x0, 0, 0
29+
EH_LABEL <mcsymbol .Ltmp0>
30+
EH_LABEL <mcsymbol .Ltmp1>
31+
EH_LABEL <mcsymbol .Ltmp2>
32+
EH_LABEL <mcsymbol .Ltmp3>
33+
RET_ReallyLR implicit $x0
34+
...
35+
---
36+
name: foo3
37+
tracksRegLiveness: true
38+
machineFunctionInfo:
39+
hasRedZone: false
40+
body: |
41+
bb.0:
42+
liveins: $x0
43+
$x0 = ADDXri $x0, 0, 0
44+
EH_LABEL <mcsymbol .Ltmp0>
45+
EH_LABEL <mcsymbol .Ltmp1>
46+
EH_LABEL <mcsymbol .Ltmp2>
47+
EH_LABEL <mcsymbol .Ltmp3>
48+
RET_ReallyLR implicit $x0
49+
...

0 commit comments

Comments
 (0)