[llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp VirtRegMap.cpp VirtRegMap.h
Evan Cheng
evan.cheng at apple.com
Sun Apr 30 01:42:00 PDT 2006
Changes in directory llvm/lib/CodeGen:
LiveIntervalAnalysis.cpp updated: 1.154 -> 1.155
VirtRegMap.cpp updated: 1.60 -> 1.61
VirtRegMap.h updated: 1.18 -> 1.19
---
Log message:
Local spiller kills a store if the folded restore is turned into a copy.
But this is incorrect if the spilled value live range extends beyond the
current BB.
It is currently controlled by a temporary option -spiller-check-liveout.
---
Diffs of the changes: (+21 -10)
LiveIntervalAnalysis.cpp | 7 ++++---
VirtRegMap.cpp | 20 +++++++++++++++-----
VirtRegMap.h | 4 ++--
3 files changed, 21 insertions(+), 10 deletions(-)
Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.154 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.155
--- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.154 Sun Jan 22 17:41:00 2006
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Sun Apr 30 03:41:47 2006
@@ -271,14 +271,15 @@
// can do this, we don't need to insert spill code.
if (lv_)
lv_->instructionChanged(MI, fmi);
- vrm.virtFolded(li.reg, MI, i, fmi);
+ MachineBasicBlock &MBB = *MI->getParent();
+ bool LiveOut = li.liveAt(getInstructionIndex(&MBB.back()) +
+ InstrSlots::NUM);
+ vrm.virtFolded(li.reg, MI, i, fmi, LiveOut);
mi2iMap_.erase(MI);
i2miMap_[index/InstrSlots::NUM] = fmi;
mi2iMap_[fmi] = index;
- MachineBasicBlock &MBB = *MI->getParent();
MI = MBB.insert(MBB.erase(MI), fmi);
++numFolded;
-
// Folding the load/store can completely change the instruction in
// unpredictable ways, rescan it from the beginning.
goto for_operand;
Index: llvm/lib/CodeGen/VirtRegMap.cpp
diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.60 llvm/lib/CodeGen/VirtRegMap.cpp:1.61
--- llvm/lib/CodeGen/VirtRegMap.cpp:1.60 Thu Apr 27 23:43:18 2006
+++ llvm/lib/CodeGen/VirtRegMap.cpp Sun Apr 30 03:41:47 2006
@@ -50,6 +50,10 @@
clEnumVal(local, " local spiller"),
clEnumValEnd),
cl::init(local));
+
+ // TEMPORARY option to test a fix.
+ cl::opt<bool>
+ SpillerCheckLiveOut("spiller-check-liveout", cl::Hidden);
}
//===----------------------------------------------------------------------===//
@@ -81,7 +85,8 @@
}
void VirtRegMap::virtFolded(unsigned VirtReg, MachineInstr *OldMI,
- unsigned OpNo, MachineInstr *NewMI) {
+ unsigned OpNo, MachineInstr *NewMI,
+ bool LiveOut) {
// Move previous memory references folded to new instruction.
MI2VirtMapTy::iterator IP = MI2VirtMap.lower_bound(NewMI);
for (MI2VirtMapTy::iterator I = MI2VirtMap.lower_bound(OldMI),
@@ -96,6 +101,7 @@
MRInfo = isRef;
} else {
MRInfo = OldMI->getOperand(OpNo).isUse() ? isModRef : isMod;
+ if (LiveOut) MRInfo = (ModRef)(MRInfo | isLiveOut);
}
// add new memory reference
@@ -727,10 +733,14 @@
MaybeDeadStores.erase(MDSI);
else {
// If we get here, the store is dead, nuke it now.
- assert(MR == VirtRegMap::isMod && "Can't be modref!");
- MBB.erase(MDSI->second);
- MaybeDeadStores.erase(MDSI);
- ++NumDSE;
+ assert(!(MR & VirtRegMap::isRef) && "Can't be modref!");
+ // Don't nuke it if the value is needed in another block.
+ if (!SpillerCheckLiveOut || !(MR & VirtRegMap::isLiveOut)) {
+ DEBUG(std::cerr << " Killed store:\t" << *MDSI->second);
+ MBB.erase(MDSI->second);
+ MaybeDeadStores.erase(MDSI);
+ ++NumDSE;
+ }
}
}
Index: llvm/lib/CodeGen/VirtRegMap.h
diff -u llvm/lib/CodeGen/VirtRegMap.h:1.18 llvm/lib/CodeGen/VirtRegMap.h:1.19
--- llvm/lib/CodeGen/VirtRegMap.h:1.18 Thu Apr 21 17:33:49 2005
+++ llvm/lib/CodeGen/VirtRegMap.h Sun Apr 30 03:41:47 2006
@@ -26,7 +26,7 @@
class VirtRegMap {
public:
- enum ModRef { isRef = 1, isMod = 2, isModRef = 3 };
+ enum ModRef { isRef = 1, isMod = 2, isModRef = 3, isLiveOut = 4 };
typedef std::multimap<MachineInstr*,
std::pair<unsigned, ModRef> > MI2VirtMapTy;
@@ -128,7 +128,7 @@
/// folded into newMI machine instruction. The OpNum argument indicates the
/// operand number of OldMI that is folded.
void virtFolded(unsigned VirtReg, MachineInstr *OldMI, unsigned OpNum,
- MachineInstr *NewMI);
+ MachineInstr *NewMI, bool LiveOut);
/// @brief returns the virtual registers' values folded in memory
/// operands of this instruction
More information about the llvm-commits
mailing list