Skip to content

Commit 9f64b69

Browse files
committed
Use MBB.liveouts()
1 parent e809e3b commit 9f64b69

File tree

5 files changed

+16
-36
lines changed

5 files changed

+16
-36
lines changed

llvm/include/llvm/CodeGen/LiveRegUnits.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,8 @@ class LiveRegUnits {
136136
/// Adds registers living out of block \p MBB.
137137
/// Live out registers are the union of the live-in registers of the successor
138138
/// blocks and pristine registers. Live out registers of the end block are the
139-
/// callee saved registers. If the target lowering information \p TLI is
140-
/// provided, runtime-defined live ins of successors will be excluded from the
141-
/// live outs.
142-
LLVM_ABI void addLiveOuts(const MachineBasicBlock &MBB,
143-
const TargetLowering *TLI = nullptr);
139+
/// callee saved registers.
140+
LLVM_ABI void addLiveOuts(const MachineBasicBlock &MBB);
144141

145142
/// Adds registers living into block \p MBB.
146143
LLVM_ABI void addLiveIns(const MachineBasicBlock &MBB);

llvm/include/llvm/CodeGen/MachineBasicBlock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,8 @@ class MachineBasicBlock
553553
LiveRegI = (*BlockI)->livein_begin();
554554
if (!advanceToValidPosition())
555555
return;
556-
if (LiveRegI->PhysReg == ExceptionPointer ||
557-
LiveRegI->PhysReg == ExceptionSelector)
556+
if ((*BlockI)->isEHPad() && (LiveRegI->PhysReg == ExceptionPointer ||
557+
LiveRegI->PhysReg == ExceptionSelector))
558558
++(*this);
559559
}
560560
}

llvm/lib/CodeGen/LiveRegUnits.cpp

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,16 @@ void LiveRegUnits::accumulate(const MachineInstr &MI) {
8787

8888
/// Add live-in registers of basic block \p MBB to \p LiveUnits.
8989
static void addBlockLiveIns(LiveRegUnits &LiveUnits,
90-
const MachineBasicBlock &MBB,
91-
MCPhysReg ExceptionPointer = {},
92-
MCPhysReg ExceptionSelector = {}) {
93-
for (const auto &LI : MBB.liveins()) {
94-
if (MBB.isEHPad() &&
95-
(LI.PhysReg == ExceptionPointer || LI.PhysReg == ExceptionSelector))
96-
continue;
90+
const MachineBasicBlock &MBB) {
91+
for (const auto &LI : MBB.liveins())
92+
LiveUnits.addRegMasked(LI.PhysReg, LI.LaneMask);
93+
}
94+
95+
/// Add live-out registers of basic block \p MBB to \p LiveUnits.
96+
static void addBlockLiveOuts(LiveRegUnits &LiveUnits,
97+
const MachineBasicBlock &MBB) {
98+
for (const auto &LI : MBB.liveouts())
9799
LiveUnits.addRegMasked(LI.PhysReg, LI.LaneMask);
98-
}
99100
}
100101

101102
/// Adds all callee saved registers to \p LiveUnits.
@@ -142,25 +143,10 @@ void LiveRegUnits::addPristines(const MachineFunction &MF) {
142143
addUnits(Pristine.getBitVector());
143144
}
144145

145-
void LiveRegUnits::addLiveOuts(const MachineBasicBlock &MBB,
146-
const TargetLowering *TLI) {
146+
void LiveRegUnits::addLiveOuts(const MachineBasicBlock &MBB) {
147147
const MachineFunction &MF = *MBB.getParent();
148-
149148
addPristines(MF);
150-
151-
MCPhysReg ExceptionPointer;
152-
MCPhysReg ExceptionSelector;
153-
154-
// Remove live-ins from successors that are defined by the runtime.
155-
if (TLI && MF.getFunction().hasPersonalityFn()) {
156-
auto PersonalityFn = MF.getFunction().getPersonalityFn();
157-
ExceptionPointer = TLI->getExceptionPointerRegister(PersonalityFn);
158-
ExceptionSelector = TLI->getExceptionSelectorRegister(PersonalityFn);
159-
}
160-
161-
// To get the live-outs we simply merge the live-ins of all successors.
162-
for (const MachineBasicBlock *Succ : MBB.successors())
163-
addBlockLiveIns(*this, *Succ, ExceptionPointer, ExceptionSelector);
149+
addBlockLiveOuts(*this, MBB);
164150

165151
// For the return block: Add all callee saved registers.
166152
if (MBB.isReturnBlock()) {

llvm/lib/CodeGen/MachineBasicBlock.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,9 +1781,6 @@ MachineBasicBlock::livein_iterator MachineBasicBlock::livein_begin() const {
17811781

17821782
MachineBasicBlock::liveout_iterator MachineBasicBlock::liveout_begin() const {
17831783
const MachineFunction &MF = *getParent();
1784-
assert(MF.getProperties().hasTracksLiveness() &&
1785-
"Liveness information is accurate");
1786-
17871784
const TargetLowering &TLI = *MF.getSubtarget().getTargetLowering();
17881785
MCRegister ExceptionPointer, ExceptionSelector;
17891786
if (MF.getFunction().hasPersonalityFn()) {

llvm/lib/Target/AArch64/MachineSMEABIPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ void MachineSMEABI::collectNeededZAStates(SMEAttrs SMEFnAttrs) {
277277
}
278278

279279
LiveRegUnits LiveUnits(*TRI);
280-
LiveUnits.addLiveOuts(MBB, Subtarget->getTargetLowering());
280+
LiveUnits.addLiveOuts(MBB);
281281

282282
auto GetPhysLiveRegs = [&] {
283283
LiveRegs PhysLiveRegs = LiveRegs::None;

0 commit comments

Comments
 (0)