Skip to content

Commit e51c435

Browse files
committed
LivePhysRegs: Skip reserved regs in computeLiveIns; NFCI
Re-commit r303937 + r303949 as they were not the cause for the build failures. We do not track liveness of reserved registers so adding them to the liveins list in computeLiveIns() was completely unnecessary. llvm-svn: 303970
1 parent 3250ae3 commit e51c435

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

llvm/include/llvm/CodeGen/LivePhysRegs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ inline raw_ostream &operator<<(raw_ostream &OS, const LivePhysRegs& LR) {
163163
/// lists are up-to-date. Uses the given LivePhysReg instance \p LiveRegs; This
164164
/// is just here to avoid repeated heap allocations when calling this multiple
165165
/// times in a pass.
166-
void computeLiveIns(LivePhysRegs &LiveRegs, const TargetRegisterInfo &TRI,
166+
void computeLiveIns(LivePhysRegs &LiveRegs, const MachineRegisterInfo &MRI,
167167
MachineBasicBlock &MBB);
168168

169169
} // end namespace llvm

llvm/lib/CodeGen/BranchFolding.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,14 @@ bool BranchFolder::OptimizeFunction(MachineFunction &MF,
153153

154154
TriedMerging.clear();
155155

156+
MachineRegisterInfo &MRI = MF.getRegInfo();
156157
AfterBlockPlacement = AfterPlacement;
157158
TII = tii;
158159
TRI = tri;
159160
MMI = mmi;
160161
MLI = mli;
162+
this->MRI = &MRI;
161163

162-
MachineRegisterInfo &MRI = MF.getRegInfo();
163164
UpdateLiveIns = MRI.tracksLiveness() && TRI->trackLivenessAfterRegAlloc(MF);
164165
if (!UpdateLiveIns)
165166
MRI.invalidateLiveness();
@@ -351,7 +352,7 @@ void BranchFolder::ReplaceTailWithBranchTo(MachineBasicBlock::iterator OldInst,
351352

352353
if (UpdateLiveIns) {
353354
NewDest->clearLiveIns();
354-
computeLiveIns(LiveRegs, *TRI, *NewDest);
355+
computeLiveIns(LiveRegs, *MRI, *NewDest);
355356
}
356357

357358
++NumTailMerge;
@@ -388,7 +389,7 @@ MachineBasicBlock *BranchFolder::SplitMBBAt(MachineBasicBlock &CurMBB,
388389
MBBFreqInfo.setBlockFreq(NewMBB, MBBFreqInfo.getBlockFreq(&CurMBB));
389390

390391
if (UpdateLiveIns)
391-
computeLiveIns(LiveRegs, *TRI, *NewMBB);
392+
computeLiveIns(LiveRegs, *MRI, *NewMBB);
392393

393394
// Add the new block to the funclet.
394395
const auto &FuncletI = FuncletMembership.find(&CurMBB);

llvm/lib/CodeGen/BranchFolding.h

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ namespace llvm {
108108
bool UpdateLiveIns;
109109
unsigned MinCommonTailLength;
110110
const TargetInstrInfo *TII;
111+
const MachineRegisterInfo *MRI;
111112
const TargetRegisterInfo *TRI;
112113
MachineModuleInfo *MMI;
113114
MachineLoopInfo *MLI;

llvm/lib/CodeGen/BranchRelaxation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ MachineBasicBlock *BranchRelaxation::splitBlockBeforeInstr(MachineInstr &MI,
259259

260260
// Need to fix live-in lists if we track liveness.
261261
if (TRI->trackLivenessAfterRegAlloc(*MF))
262-
computeLiveIns(LiveRegs, *TRI, *NewBB);
262+
computeLiveIns(LiveRegs, MF->getRegInfo(), *NewBB);
263263

264264
++NumSplit;
265265

llvm/lib/CodeGen/LivePhysRegs.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -200,19 +200,23 @@ void LivePhysRegs::addLiveIns(const MachineBasicBlock &MBB) {
200200
addBlockLiveIns(MBB);
201201
}
202202

203-
void llvm::computeLiveIns(LivePhysRegs &LiveRegs, const TargetRegisterInfo &TRI,
203+
void llvm::computeLiveIns(LivePhysRegs &LiveRegs,
204+
const MachineRegisterInfo &MRI,
204205
MachineBasicBlock &MBB) {
206+
const TargetRegisterInfo &TRI = *MRI.getTargetRegisterInfo();
205207
assert(MBB.livein_empty());
206208
LiveRegs.init(TRI);
207209
LiveRegs.addLiveOutsNoPristines(MBB);
208210
for (MachineInstr &MI : make_range(MBB.rbegin(), MBB.rend()))
209211
LiveRegs.stepBackward(MI);
210212

211213
for (unsigned Reg : LiveRegs) {
214+
if (MRI.isReserved(Reg))
215+
continue;
212216
// Skip the register if we are about to add one of its super registers.
213217
bool ContainsSuperReg = false;
214218
for (MCSuperRegIterator SReg(Reg, &TRI); SReg.isValid(); ++SReg) {
215-
if (LiveRegs.contains(*SReg)) {
219+
if (LiveRegs.contains(*SReg) && !MRI.isReserved(*SReg)) {
216220
ContainsSuperReg = true;
217221
break;
218222
}

0 commit comments

Comments
 (0)