forked from OSchip/llvm-project
LivePhysRegs: Fix live-outs of return blocks
I realized that the live-out set computed for the return block is missing the callee saved registers (the non-pristine ones to be exact). This only affects the liveness computed for instructions inside the function epilogue which currently none of the LivePhysRegs users in llvm cares about, so this is just a drive-by fix without a testcase. Differential Revision: http://reviews.llvm.org/D13180 llvm-svn: 248636
This commit is contained in:
parent
cc8c7773c5
commit
93ab942c24
|
@ -122,9 +122,9 @@ public:
|
||||||
void addLiveIns(const MachineBasicBlock *MBB, bool AddPristines = false);
|
void addLiveIns(const MachineBasicBlock *MBB, bool AddPristines = false);
|
||||||
|
|
||||||
/// \brief Adds all live-out registers of basic block @p MBB; After prologue/
|
/// \brief Adds all live-out registers of basic block @p MBB; After prologue/
|
||||||
/// epilogue insertion \p AddPristines should be set to true to insert the
|
/// epilogue insertion \p AddPristinesAndCSRs should be set to true.
|
||||||
/// pristine registers.
|
void addLiveOuts(const MachineBasicBlock *MBB,
|
||||||
void addLiveOuts(const MachineBasicBlock *MBB, bool AddPristines = false);
|
bool AddPristinesAndCSRs = false);
|
||||||
|
|
||||||
typedef SparseSet<unsigned>::const_iterator const_iterator;
|
typedef SparseSet<unsigned>::const_iterator const_iterator;
|
||||||
const_iterator begin() const { return LiveRegs.begin(); }
|
const_iterator begin() const { return LiveRegs.begin(); }
|
||||||
|
|
|
@ -147,11 +147,19 @@ static void addPristines(LivePhysRegs &LiveRegs, const MachineFunction &MF,
|
||||||
}
|
}
|
||||||
|
|
||||||
void LivePhysRegs::addLiveOuts(const MachineBasicBlock *MBB,
|
void LivePhysRegs::addLiveOuts(const MachineBasicBlock *MBB,
|
||||||
bool AddPristines) {
|
bool AddPristinesAndCSRs) {
|
||||||
if (AddPristines) {
|
if (AddPristinesAndCSRs) {
|
||||||
const MachineFunction &MF = *MBB->getParent();
|
const MachineFunction &MF = *MBB->getParent();
|
||||||
addPristines(*this, MF, *TRI);
|
addPristines(*this, MF, *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.
|
||||||
|
for (const MCPhysReg *I = TRI->getCalleeSavedRegs(&MF); *I; ++I)
|
||||||
|
addReg(*I);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To get the live-outs we simply merge the live-ins of all successors.
|
||||||
for (const MachineBasicBlock *Succ : MBB->successors())
|
for (const MachineBasicBlock *Succ : MBB->successors())
|
||||||
::addLiveIns(*this, *Succ);
|
::addLiveIns(*this, *Succ);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue