void stepForward(const MachineInstr &MI,
SmallVectorImpl<std::pair<unsigned, const MachineOperand*>> &Clobbers);
- /// \brief Adds all live-in registers of basic block @p MBB; After prologue/
- /// epilogue insertion \p AddPristines should be set to true to insert the
+ /// Adds all live-in registers of basic block @p MBB.
+ /// Live in registers are the registers in the blocks live-in list and the
/// pristine registers.
- void addLiveIns(const MachineBasicBlock *MBB, bool AddPristines = false);
+ void addLiveIns(const MachineBasicBlock *MBB);
- /// \brief Adds all live-out registers of basic block @p MBB; After prologue/
- /// epilogue insertion \p AddPristinesAndCSRs should be set to true.
- void addLiveOuts(const MachineBasicBlock *MBB,
- bool AddPristinesAndCSRs = false);
+ /// Adds all live-out registers of basic block @p MBB.
+ /// Live out registers are the union of the live-in registers of the successor
+ /// blocks and pristine registers. Live out registers of the end block are the
+ /// callee saved registers.
+ void addLiveOuts(const MachineBasicBlock *MBB);
+
+ /// Like addLiveOuts() but does not add pristine registers/callee saved
+ /// registers.
+ void addLiveOutsNoPristines(const MachineBasicBlock *MBB);
typedef SparseSet<unsigned>::const_iterator const_iterator;
const_iterator begin() const { return LiveRegs.begin(); }
// Collect this block's live out register units.
LiveRegSet.init(TRI);
- LiveRegSet.addLiveOuts(MBB);
+ // We do not need to care about pristine registers as they are just preserved
+ // but not actually used in the function.
+ LiveRegSet.addLiveOutsNoPristines(MBB);
MachineInstr *UndefMI = UndefReads.back().first;
unsigned OpIdx = UndefReads.back().second;
/// Add pristine registers to the given \p LiveRegs. This function removes
/// actually saved callee save registers when \p InPrologueEpilogue is false.
static void addPristines(LivePhysRegs &LiveRegs, const MachineFunction &MF,
+ const MachineFrameInfo &MFI,
const TargetRegisterInfo &TRI) {
- const MachineFrameInfo &MFI = *MF.getFrameInfo();
- if (!MFI.isCalleeSavedInfoValid())
- return;
-
for (const MCPhysReg *CSR = TRI.getCalleeSavedRegs(&MF); CSR && *CSR; ++CSR)
LiveRegs.addReg(*CSR);
for (const CalleeSavedInfo &Info : MFI.getCalleeSavedInfo())
LiveRegs.removeReg(Info.getReg());
}
-void LivePhysRegs::addLiveOuts(const MachineBasicBlock *MBB,
- bool AddPristinesAndCSRs) {
- if (AddPristinesAndCSRs) {
- const MachineFunction &MF = *MBB->getParent();
- addPristines(*this, MF, *TRI);
+void LivePhysRegs::addLiveOutsNoPristines(const MachineBasicBlock *MBB) {
+ // To get the live-outs we simply merge the live-ins of all successors.
+ for (const MachineBasicBlock *Succ : MBB->successors())
+ ::addLiveIns(*this, *Succ);
+}
+
+void LivePhysRegs::addLiveOuts(const MachineBasicBlock *MBB) {
+ const MachineFunction &MF = *MBB->getParent();
+ const MachineFrameInfo &MFI = *MF.getFrameInfo();
+ if (MFI.isCalleeSavedInfoValid()) {
+ addPristines(*this, MF, MFI, *TRI);
if (MBB->isReturnBlock()) {
// The return block has no successors whose live-ins we could merge
// below. So instead we add the callee saved registers manually.
}
}
- // To get the live-outs we simply merge the live-ins of all successors.
- for (const MachineBasicBlock *Succ : MBB->successors())
- ::addLiveIns(*this, *Succ);
+ addLiveOutsNoPristines(MBB);
}
-void LivePhysRegs::addLiveIns(const MachineBasicBlock *MBB,
- bool AddPristines) {
- if (AddPristines) {
- const MachineFunction &MF = *MBB->getParent();
- addPristines(*this, MF, *TRI);
- }
+void LivePhysRegs::addLiveIns(const MachineBasicBlock *MBB) {
+ const MachineFunction &MF = *MBB->getParent();
+ const MachineFrameInfo &MFI = *MF.getFrameInfo();
+ if (MFI.isCalleeSavedInfoValid())
+ addPristines(*this, MF, MFI, *TRI);
::addLiveIns(*this, *MBB);
}
for (auto &MBB : MF) {
DEBUG(dbgs() << "****** BB " << MBB.getName() << " ******\n");
LiveRegs.init(TRI);
- LiveRegs.addLiveOuts(&MBB);
+ // FIXME: This should probably be addLiveOuts().
+ LiveRegs.addLiveOutsNoPristines(&MBB);
bool HasStackMap = false;
// Reverse iterate over all instructions and add the current live register
// set to an instruction if we encounter a patchpoint instruction.
MachineOperand &New = MI.getOperand(4);
LivePhysRegs LiveRegs(&TII->getRegisterInfo());
- LiveRegs.addLiveOuts(&MBB, /*AddPristinesAndCSRs=*/true);
+ LiveRegs.addLiveOuts(&MBB);
for (auto I = std::prev(MBB.end()); I != MBBI; --I)
LiveRegs.stepBackward(*I);
MachineOperand &NewHi = MI.getOperand(7);
LivePhysRegs LiveRegs(&TII->getRegisterInfo());
- LiveRegs.addLiveOuts(&MBB, /*AddPristinesAndCSRs=*/true);
+ LiveRegs.addLiveOuts(&MBB);
for (auto I = std::prev(MBB.end()); I != MBBI; --I)
LiveRegs.stepBackward(*I);
MachineOperand &New = MI.getOperand(4);
LivePhysRegs LiveRegs(&TII->getRegisterInfo());
- LiveRegs.addLiveOuts(&MBB, /*AddPristinesAndCSRs=*/true);
+ LiveRegs.addLiveOuts(&MBB);
for (auto I = std::prev(MBB.end()); I != MBBI; --I)
LiveRegs.stepBackward(*I);
unsigned DesiredHi = TRI->getSubReg(Desired.getReg(), ARM::gsub_1);
LivePhysRegs LiveRegs(&TII->getRegisterInfo());
- LiveRegs.addLiveOuts(&MBB, /*AddPristinesAndCSRs=*/true);
+ LiveRegs.addLiveOuts(&MBB);
for (auto I = std::prev(MBB.end()); I != MBBI; --I)
LiveRegs.stepBackward(*I);
// Initialize if we never queried in this block.
if (!LiveRegsValid) {
LiveRegs.init(TRI);
- LiveRegs.addLiveOuts(&MBB, true);
+ LiveRegs.addLiveOuts(&MBB);
LiveRegPos = MBB.end();
LiveRegsValid = true;
}
// Look for a temporary register to use.
// First, compute the liveness information.
LivePhysRegs UsedRegs(STI.getRegisterInfo());
- UsedRegs.addLiveOuts(&MBB, /*AddPristines*/ true);
+ UsedRegs.addLiveOuts(&MBB);
// The semantic of pristines changed recently and now,
// the callee-saved registers that are touched in the function
// are not part of the pristines set anymore.
// to update this for each instruction.
LiveRegs.clear();
// We run after PEI, so we need to AddPristinesAndCSRs.
- LiveRegs.addLiveOuts(&MBB, /*AddPristinesAndCSRs=*/true);
+ LiveRegs.addLiveOuts(&MBB);
for (auto I = MBB.rbegin(); I != MBB.rend(); ++I) {
MachineInstr *NewMI = nullptr;
// as this is usually wrong to read an undef value.
if (MachineBasicBlock::LQR_Unknown == LQR) {
LivePhysRegs LPR(&getRegisterInfo());
- LPR.addLiveOuts(&MBB, /*AddPristinesAndCSRs*/ true);
+ LPR.addLiveOuts(&MBB);
MachineBasicBlock::iterator I = MBB.end();
while (I != MI) {
--I;