[llvm] r248636 - LivePhysRegs: Fix live-outs of return blocks
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 16:50:54 PDT 2015
Author: matze
Date: Fri Sep 25 18:50:53 2015
New Revision: 248636
URL: http://llvm.org/viewvc/llvm-project?rev=248636&view=rev
Log:
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
Modified:
llvm/trunk/include/llvm/CodeGen/LivePhysRegs.h
llvm/trunk/lib/CodeGen/LivePhysRegs.cpp
Modified: llvm/trunk/include/llvm/CodeGen/LivePhysRegs.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LivePhysRegs.h?rev=248636&r1=248635&r2=248636&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/LivePhysRegs.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LivePhysRegs.h Fri Sep 25 18:50:53 2015
@@ -122,9 +122,9 @@ public:
void addLiveIns(const MachineBasicBlock *MBB, bool AddPristines = false);
/// \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
- /// pristine registers.
- void addLiveOuts(const MachineBasicBlock *MBB, bool AddPristines = false);
+ /// epilogue insertion \p AddPristinesAndCSRs should be set to true.
+ void addLiveOuts(const MachineBasicBlock *MBB,
+ bool AddPristinesAndCSRs = false);
typedef SparseSet<unsigned>::const_iterator const_iterator;
const_iterator begin() const { return LiveRegs.begin(); }
Modified: llvm/trunk/lib/CodeGen/LivePhysRegs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LivePhysRegs.cpp?rev=248636&r1=248635&r2=248636&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LivePhysRegs.cpp (original)
+++ llvm/trunk/lib/CodeGen/LivePhysRegs.cpp Fri Sep 25 18:50:53 2015
@@ -147,11 +147,19 @@ static void addPristines(LivePhysRegs &L
}
void LivePhysRegs::addLiveOuts(const MachineBasicBlock *MBB,
- bool AddPristines) {
- if (AddPristines) {
+ bool AddPristinesAndCSRs) {
+ if (AddPristinesAndCSRs) {
const MachineFunction &MF = *MBB->getParent();
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())
::addLiveIns(*this, *Succ);
}
More information about the llvm-commits
mailing list