aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/VirtRegMap.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-04-30 08:41:47 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-04-30 08:41:47 +0000
commit200370fb5617a1719f0054804b412469ce486ebd (patch)
treed987158809ec13a1df29169325f6d356dcc631b5 /lib/CodeGen/VirtRegMap.cpp
parent10a59ce7018d7e4c32c801f9ed3d2ab18751d9d6 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28024 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/VirtRegMap.cpp')
-rw-r--r--lib/CodeGen/VirtRegMap.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp
index f0dd40d1e1..6122dc1bb4 100644
--- a/lib/CodeGen/VirtRegMap.cpp
+++ b/lib/CodeGen/VirtRegMap.cpp
@@ -50,6 +50,10 @@ namespace {
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::assignVirt2StackSlot(unsigned virtReg, int frameIndex) {
}
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 @@ void VirtRegMap::virtFolded(unsigned VirtReg, MachineInstr *OldMI,
MRInfo = isRef;
} else {
MRInfo = OldMI->getOperand(OpNo).isUse() ? isModRef : isMod;
+ if (LiveOut) MRInfo = (ModRef)(MRInfo | isLiveOut);
}
// add new memory reference
@@ -727,10 +733,14 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, const VirtRegMap &VRM) {
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;
+ }
}
}