Skip to content

Commit d7213de

Browse files
committed
Convert as many LivePhysRegs uses to LiveRegUnits
Additionally, remove unused #include "llvm/CodeGen/LivePhysRegs.h"
1 parent d95e6d0 commit d7213de

File tree

6 files changed

+32
-51
lines changed

6 files changed

+32
-51
lines changed

llvm/lib/CodeGen/MachineOutliner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,15 +768,15 @@ MachineFunction *MachineOutliner::createOutlinedFunction(
768768
for (auto &Cand : OF.Candidates) {
769769
// Figure out live-ins at the first instruction.
770770
MachineBasicBlock &OutlineBB = *Cand.front().getParent();
771-
LivePhysRegs CandLiveIns(TRI);
771+
LiveRegUnits CandLiveIns(TRI);
772772
CandLiveIns.addLiveOuts(OutlineBB);
773773
for (const MachineInstr &MI :
774774
reverse(make_range(Cand.begin(), OutlineBB.end())))
775775
CandLiveIns.stepBackward(MI);
776776

777777
// The live-in set for the outlined function is the union of the live-ins
778778
// from all the outlining points.
779-
for (MCPhysReg Reg : CandLiveIns)
779+
for (MCPhysReg Reg : CandLiveIns.getBitVector().set_bits())
780780
LiveIns.addReg(Reg);
781781
}
782782
addLiveIns(MBB, LiveIns);

llvm/lib/CodeGen/ReachingDefAnalysis.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "llvm/ADT/SmallSet.h"
10-
#include "llvm/ADT/SetOperations.h"
11-
#include "llvm/CodeGen/LivePhysRegs.h"
129
#include "llvm/CodeGen/ReachingDefAnalysis.h"
10+
#include "llvm/ADT/SetOperations.h"
11+
#include "llvm/ADT/SmallSet.h"
12+
#include "llvm/CodeGen/LiveRegUnits.h"
1313
#include "llvm/CodeGen/TargetRegisterInfo.h"
1414
#include "llvm/CodeGen/TargetSubtargetInfo.h"
1515
#include "llvm/Support/Debug.h"
@@ -421,9 +421,9 @@ void ReachingDefAnalysis::getLiveOuts(MachineBasicBlock *MBB,
421421
return;
422422

423423
VisitedBBs.insert(MBB);
424-
LivePhysRegs LiveRegs(*TRI);
424+
LiveRegUnits LiveRegs(*TRI);
425425
LiveRegs.addLiveOuts(*MBB);
426-
if (LiveRegs.available(MBB->getParent()->getRegInfo(), PhysReg))
426+
if (LiveRegs.available(PhysReg))
427427
return;
428428

429429
if (auto *Def = getLocalLiveOutMIDef(MBB, PhysReg))
@@ -469,19 +469,19 @@ MachineInstr *ReachingDefAnalysis::getMIOperand(MachineInstr *MI,
469469
bool ReachingDefAnalysis::isRegUsedAfter(MachineInstr *MI,
470470
MCRegister PhysReg) const {
471471
MachineBasicBlock *MBB = MI->getParent();
472-
LivePhysRegs LiveRegs(*TRI);
472+
LiveRegUnits LiveRegs(*TRI);
473473
LiveRegs.addLiveOuts(*MBB);
474474

475475
// Yes if the register is live out of the basic block.
476-
if (!LiveRegs.available(MBB->getParent()->getRegInfo(), PhysReg))
476+
if (!LiveRegs.available(PhysReg))
477477
return true;
478478

479479
// Walk backwards through the block to see if the register is live at some
480480
// point.
481481
for (MachineInstr &Last :
482482
instructionsWithoutDebug(MBB->instr_rbegin(), MBB->instr_rend())) {
483483
LiveRegs.stepBackward(Last);
484-
if (!LiveRegs.available(MBB->getParent()->getRegInfo(), PhysReg))
484+
if (!LiveRegs.available(PhysReg))
485485
return InstIds.lookup(&Last) > InstIds.lookup(MI);
486486
}
487487
return false;
@@ -504,9 +504,9 @@ bool ReachingDefAnalysis::isRegDefinedAfter(MachineInstr *MI,
504504
bool ReachingDefAnalysis::isReachingDefLiveOut(MachineInstr *MI,
505505
MCRegister PhysReg) const {
506506
MachineBasicBlock *MBB = MI->getParent();
507-
LivePhysRegs LiveRegs(*TRI);
507+
LiveRegUnits LiveRegs(*TRI);
508508
LiveRegs.addLiveOuts(*MBB);
509-
if (LiveRegs.available(MBB->getParent()->getRegInfo(), PhysReg))
509+
if (LiveRegs.available(PhysReg))
510510
return false;
511511

512512
auto Last = MBB->getLastNonDebugInstr();
@@ -525,9 +525,9 @@ bool ReachingDefAnalysis::isReachingDefLiveOut(MachineInstr *MI,
525525
MachineInstr *
526526
ReachingDefAnalysis::getLocalLiveOutMIDef(MachineBasicBlock *MBB,
527527
MCRegister PhysReg) const {
528-
LivePhysRegs LiveRegs(*TRI);
528+
LiveRegUnits LiveRegs(*TRI);
529529
LiveRegs.addLiveOuts(*MBB);
530-
if (LiveRegs.available(MBB->getParent()->getRegInfo(), PhysReg))
530+
if (LiveRegs.available(PhysReg))
531531
return nullptr;
532532

533533
auto Last = MBB->getLastNonDebugInstr();

llvm/lib/Target/AArch64/AArch64FrameLowering.cpp

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
#include "llvm/ADT/SmallVector.h"
198198
#include "llvm/ADT/Statistic.h"
199199
#include "llvm/CodeGen/LivePhysRegs.h"
200+
#include "llvm/CodeGen/LiveRegUnits.h"
200201
#include "llvm/CodeGen/MachineBasicBlock.h"
201202
#include "llvm/CodeGen/MachineFrameInfo.h"
202203
#include "llvm/CodeGen/MachineFunction.h"
@@ -988,16 +989,6 @@ void AArch64FrameLowering::emitZeroCallUsedRegs(BitVector RegsToZero,
988989
}
989990
}
990991

991-
static void getLiveRegsForEntryMBB(LivePhysRegs &LiveRegs,
992-
const MachineBasicBlock &MBB) {
993-
const MachineFunction *MF = MBB.getParent();
994-
LiveRegs.addLiveIns(MBB);
995-
// Mark callee saved registers as used so we will not choose them.
996-
const MCPhysReg *CSRegs = MF->getRegInfo().getCalleeSavedRegs();
997-
for (unsigned i = 0; CSRegs[i]; ++i)
998-
LiveRegs.addReg(CSRegs[i]);
999-
}
1000-
1001992
// Find a scratch register that we can use at the start of the prologue to
1002993
// re-align the stack pointer. We avoid using callee-save registers since they
1003994
// may appear to be free when this is called from canUseAsPrologue (during
@@ -1018,16 +1009,15 @@ static Register findScratchNonCalleeSaveRegister(MachineBasicBlock *MBB) {
10181009

10191010
const AArch64Subtarget &Subtarget = MF->getSubtarget<AArch64Subtarget>();
10201011
const AArch64RegisterInfo &TRI = *Subtarget.getRegisterInfo();
1021-
LivePhysRegs LiveRegs(TRI);
1022-
getLiveRegsForEntryMBB(LiveRegs, *MBB);
1012+
LiveRegUnits LiveRegs(TRI);
1013+
LiveRegs.addLiveIns(*MBB);
10231014

10241015
// Prefer X9 since it was historically used for the prologue scratch reg.
1025-
const MachineRegisterInfo &MRI = MF->getRegInfo();
1026-
if (LiveRegs.available(MRI, AArch64::X9))
1016+
if (LiveRegs.available(AArch64::X9))
10271017
return AArch64::X9;
10281018

1029-
for (unsigned Reg : AArch64::GPR64RegClass) {
1030-
if (LiveRegs.available(MRI, Reg))
1019+
for (Register Reg : AArch64::GPR64RegClass) {
1020+
if (LiveRegs.available(Reg))
10311021
return Reg;
10321022
}
10331023
return AArch64::NoRegister;
@@ -1044,13 +1034,11 @@ bool AArch64FrameLowering::canUseAsPrologue(
10441034

10451035
if (AFI->hasSwiftAsyncContext()) {
10461036
const AArch64RegisterInfo &TRI = *Subtarget.getRegisterInfo();
1047-
const MachineRegisterInfo &MRI = MF->getRegInfo();
1048-
LivePhysRegs LiveRegs(TRI);
1049-
getLiveRegsForEntryMBB(LiveRegs, MBB);
1037+
LiveRegUnits LiveRegs(TRI);
1038+
LiveRegs.addLiveIns(MBB);
10501039
// The StoreSwiftAsyncContext clobbers X16 and X17. Make sure they are
10511040
// available.
1052-
if (!LiveRegs.available(MRI, AArch64::X16) ||
1053-
!LiveRegs.available(MRI, AArch64::X17))
1041+
if (!LiveRegs.available(AArch64::X16) || !LiveRegs.available(AArch64::X17))
10541042
return false;
10551043
}
10561044

llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
1212
#include "SIRegisterInfo.h"
1313
#include "llvm/ADT/SmallVector.h"
14-
#include "llvm/CodeGen/LivePhysRegs.h"
14+
#include "llvm/CodeGen/LiveRegUnits.h"
1515
#include "llvm/CodeGen/MachineFunctionPass.h"
1616
#include "llvm/CodeGen/MachineOperand.h"
1717
#include "llvm/CodeGen/TargetRegisterInfo.h"
@@ -313,7 +313,7 @@ MachineBasicBlock::reverse_iterator SIOptimizeExecMasking::findExecCopy(
313313
return E;
314314
}
315315

316-
// XXX - Seems LivePhysRegs doesn't work correctly since it will incorrectly
316+
// XXX - Seems LiveRegUnits doesn't work correctly since it will incorrectly
317317
// report the register as unavailable because a super-register with a lane mask
318318
// is unavailable.
319319
static bool isLiveOut(const MachineBasicBlock &MBB, unsigned Reg) {
@@ -383,7 +383,7 @@ bool SIOptimizeExecMasking::isRegisterInUseBetween(MachineInstr &Stop,
383383
MCRegister Reg,
384384
bool UseLiveOuts,
385385
bool IgnoreStart) const {
386-
LivePhysRegs LR(*TRI);
386+
LiveRegUnits LR(*TRI);
387387
if (UseLiveOuts)
388388
LR.addLiveOuts(*Stop.getParent());
389389

llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "llvm/ADT/Statistic.h"
3232
#include "llvm/ADT/iterator_range.h"
3333
#include "llvm/Analysis/AliasAnalysis.h"
34-
#include "llvm/CodeGen/LivePhysRegs.h"
34+
#include "llvm/CodeGen/LiveRegUnits.h"
3535
#include "llvm/CodeGen/MachineBasicBlock.h"
3636
#include "llvm/CodeGen/MachineDominators.h"
3737
#include "llvm/CodeGen/MachineFrameInfo.h"
@@ -109,7 +109,7 @@ namespace {
109109
const ARMSubtarget *STI;
110110
const TargetLowering *TL;
111111
ARMFunctionInfo *AFI;
112-
LivePhysRegs LiveRegs;
112+
LiveRegUnits LiveRegs;
113113
RegisterClassInfo RegClassInfo;
114114
MachineBasicBlock::const_iterator LiveRegPos;
115115
bool LiveRegsValid;
@@ -589,7 +589,7 @@ unsigned ARMLoadStoreOpt::findFreeReg(const TargetRegisterClass &RegClass) {
589589
}
590590

591591
for (unsigned Reg : RegClassInfo.getOrder(&RegClass))
592-
if (LiveRegs.available(MF->getRegInfo(), Reg))
592+
if (LiveRegs.available(Reg))
593593
return Reg;
594594
return 0;
595595
}

llvm/lib/Target/ARM/Thumb1FrameLowering.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -601,11 +601,11 @@ bool Thumb1FrameLowering::needPopSpecialFixUp(const MachineFunction &MF) const {
601601

602602
static void findTemporariesForLR(const BitVector &GPRsNoLRSP,
603603
const BitVector &PopFriendly,
604-
const LivePhysRegs &UsedRegs, unsigned &PopReg,
604+
const LiveRegUnits &UsedRegs, unsigned &PopReg,
605605
unsigned &TmpReg, MachineRegisterInfo &MRI) {
606606
PopReg = TmpReg = 0;
607607
for (auto Reg : GPRsNoLRSP.set_bits()) {
608-
if (UsedRegs.available(MRI, Reg)) {
608+
if (UsedRegs.available(Reg)) {
609609
// Remember the first pop-friendly register and exit.
610610
if (PopFriendly.test(Reg)) {
611611
PopReg = Reg;
@@ -673,15 +673,8 @@ bool Thumb1FrameLowering::emitPopSpecialFixUp(MachineBasicBlock &MBB,
673673
// Look for a temporary register to use.
674674
// First, compute the liveness information.
675675
const TargetRegisterInfo &TRI = *STI.getRegisterInfo();
676-
LivePhysRegs UsedRegs(TRI);
676+
LiveRegUnits UsedRegs(TRI);
677677
UsedRegs.addLiveOuts(MBB);
678-
// The semantic of pristines changed recently and now,
679-
// the callee-saved registers that are touched in the function
680-
// are not part of the pristines set anymore.
681-
// Add those callee-saved now.
682-
const MCPhysReg *CSRegs = TRI.getCalleeSavedRegs(&MF);
683-
for (unsigned i = 0; CSRegs[i]; ++i)
684-
UsedRegs.addReg(CSRegs[i]);
685678

686679
DebugLoc dl = DebugLoc();
687680
if (MBBI != MBB.end()) {

0 commit comments

Comments
 (0)