aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-01-23 03:28:53 +0000
committerOwen Anderson <resistor@mac.com>2009-01-23 03:28:53 +0000
commit9ce499ab3663a3a5dda964c2d905e4ff05af976c (patch)
tree67932608ece3055ac0b3f4e1c6fd213c6186d411 /lib
parent8c08d8c77c45d4721e7d3ef746cca9e39b28e379 (diff)
downloadexternal_llvm-9ce499ab3663a3a5dda964c2d905e4ff05af976c.zip
external_llvm-9ce499ab3663a3a5dda964c2d905e4ff05af976c.tar.gz
external_llvm-9ce499ab3663a3a5dda964c2d905e4ff05af976c.tar.bz2
Stage two of fixing pre-alloc-splitting's code size issues: filter out restores that are just
going to be re-spilled again. This also helps performance. Pre-alloc-splitting now seems to be an overall win on SPEC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62834 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/PreAllocSplitting.cpp46
1 files changed, 37 insertions, 9 deletions
diff --git a/lib/CodeGen/PreAllocSplitting.cpp b/lib/CodeGen/PreAllocSplitting.cpp
index f07f070..8e86213 100644
--- a/lib/CodeGen/PreAllocSplitting.cpp
+++ b/lib/CodeGen/PreAllocSplitting.cpp
@@ -1388,7 +1388,7 @@ bool PreAllocSplitting::removeDeadSpills(SmallPtrSet<LiveInterval*, 8>& split) {
for (SmallPtrSet<LiveInterval*, 8>::iterator LI = split.begin(),
LE = split.end(); LI != LE; ++LI) {
- DenseMap<VNInfo*, unsigned > VNUseCount;
+ DenseMap<VNInfo*, SmallPtrSet<MachineInstr*, 4> > VNUseCount;
for (MachineRegisterInfo::use_iterator UI = MRI->use_begin((*LI)->reg),
UE = MRI->use_end(); UI != UE; ++UI) {
@@ -1396,27 +1396,55 @@ bool PreAllocSplitting::removeDeadSpills(SmallPtrSet<LiveInterval*, 8>& split) {
index = LiveIntervals::getUseIndex(index);
const LiveRange* LR = (*LI)->getLiveRangeContaining(index);
- VNUseCount[LR->valno]++;
+ VNUseCount[LR->valno].insert(&*UI);
}
for (LiveInterval::vni_iterator VI = (*LI)->vni_begin(),
VE = (*LI)->vni_end(); VI != VE; ++VI) {
VNInfo* CurrVN = *VI;
if (CurrVN->hasPHIKill) continue;
- if (VNUseCount[CurrVN] > 0) continue;
unsigned DefIdx = CurrVN->def;
if (DefIdx == ~0U || DefIdx == ~1U) continue;
-
+
MachineInstr* DefMI = LIs->getInstructionFromIndex(DefIdx);
int FrameIndex;
if (!TII->isLoadFromStackSlot(DefMI, FrameIndex)) continue;
- LIs->RemoveMachineInstrFromMaps(DefMI);
- (*LI)->removeValNo(CurrVN);
- DefMI->eraseFromParent();
- NumDeadSpills++;
- changed = true;
+ if (VNUseCount[CurrVN].size() == 0) {
+ LIs->RemoveMachineInstrFromMaps(DefMI);
+ (*LI)->removeValNo(CurrVN);
+ DefMI->eraseFromParent();
+ NumDeadSpills++;
+ changed = true;
+ } else {
+ bool NonRestore = false;
+ for (SmallPtrSet<MachineInstr*, 4>::iterator UI =
+ VNUseCount[CurrVN].begin(), UE = VNUseCount[CurrVN].end();
+ UI != UI; ++UI) {
+ int StoreFrameIndex;
+ unsigned StoreVReg = TII->isStoreToStackSlot(*UI, StoreFrameIndex);
+ if (StoreVReg != (*LI)->reg || StoreFrameIndex != FrameIndex) {
+ NonRestore = false;
+ break;
+ }
+ }
+
+ if (NonRestore) continue;
+
+ for (SmallPtrSet<MachineInstr*, 4>::iterator UI =
+ VNUseCount[CurrVN].begin(), UE = VNUseCount[CurrVN].end();
+ UI != UI; ++UI) {
+ LIs->RemoveMachineInstrFromMaps(*UI);
+ (*UI)->eraseFromParent();
+ }
+
+ LIs->RemoveMachineInstrFromMaps(DefMI);
+ (*LI)->removeValNo(CurrVN);
+ DefMI->eraseFromParent();
+ NumDeadSpills++;
+ changed = true;
+ }
}
}