From 01a46c82e0b58f6c2d562282538556159806c4fe Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Sun, 20 Mar 2011 05:44:55 +0000 Subject: [PATCH] Change an argument to a LiveInterval instead of a register number to save some redundant lookups. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127964 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/InlineSpiller.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/CodeGen/InlineSpiller.cpp b/lib/CodeGen/InlineSpiller.cpp index 7f7c15ea014..3e2adfbe24b 100644 --- a/lib/CodeGen/InlineSpiller.cpp +++ b/lib/CodeGen/InlineSpiller.cpp @@ -124,7 +124,7 @@ private: void analyzeSiblingValues(); bool hoistSpill(LiveInterval &SpillLI, MachineInstr *CopyMI); - void eliminateRedundantSpills(unsigned Reg, VNInfo *VNI); + void eliminateRedundantSpills(LiveInterval &LI, VNInfo *VNI); bool reMaterializeFor(MachineBasicBlock::iterator MI); void reMaterializeAll(); @@ -444,7 +444,7 @@ bool InlineSpiller::hoistSpill(LiveInterval &SpillLI, MachineInstr *CopyMI) { // We are going to spill SVI.SpillVNI immediately after its def, so clear out // any later spills of the same value. - eliminateRedundantSpills(SVI.SpillReg, SVI.SpillVNI); + eliminateRedundantSpills(LIS.getInterval(SVI.SpillReg), SVI.SpillVNI); MachineBasicBlock *MBB = LIS.getMBBFromIndex(SVI.SpillVNI->def); MachineBasicBlock::iterator MII; @@ -463,15 +463,17 @@ bool InlineSpiller::hoistSpill(LiveInterval &SpillLI, MachineInstr *CopyMI) { return true; } -/// eliminateRedundantSpills - Reg:VNI is known to be on the stack. Remove any -/// redundant spills of this value in Reg and sibling copies. -void InlineSpiller::eliminateRedundantSpills(unsigned Reg, VNInfo *VNI) { - SmallVector, 8> WorkList; - WorkList.push_back(std::make_pair(Reg, VNI)); +/// eliminateRedundantSpills - SLI:VNI is known to be on the stack. Remove any +/// redundant spills of this value in SLI.reg and sibling copies. +void InlineSpiller::eliminateRedundantSpills(LiveInterval &SLI, VNInfo *VNI) { + SmallVector, 8> WorkList; + WorkList.push_back(std::make_pair(&SLI, VNI)); LiveInterval &StackInt = LSS.getInterval(StackSlot); do { - tie(Reg, VNI) = WorkList.pop_back_val(); + LiveInterval *LI; + tie(LI, VNI) = WorkList.pop_back_val(); + unsigned Reg = LI->reg; DEBUG(dbgs() << "Checking redundant spills for " << PrintReg(Reg) << ':' << VNI->id << '@' << VNI->def << '\n'); @@ -480,8 +482,7 @@ void InlineSpiller::eliminateRedundantSpills(unsigned Reg, VNInfo *VNI) { continue; // Add all of VNI's live range to StackInt. - LiveInterval &LI = LIS.getInterval(Reg); - StackInt.MergeValueInAsValue(LI, VNI, StackInt.getValNumInfo(0)); + StackInt.MergeValueInAsValue(*LI, VNI, StackInt.getValNumInfo(0)); DEBUG(dbgs() << "Merged to stack int: " << StackInt << '\n'); // Find all spills and copies of VNI. @@ -490,7 +491,7 @@ void InlineSpiller::eliminateRedundantSpills(unsigned Reg, VNInfo *VNI) { if (!MI->isCopy() && !MI->getDesc().mayStore()) continue; SlotIndex Idx = LIS.getInstructionIndex(MI); - if (LI.getVNInfoAt(Idx) != VNI) + if (LI->getVNInfoAt(Idx) != VNI) continue; // Follow sibling copies down the dominator tree. @@ -500,7 +501,7 @@ void InlineSpiller::eliminateRedundantSpills(unsigned Reg, VNInfo *VNI) { VNInfo *DstVNI = DstLI.getVNInfoAt(Idx.getDefIndex()); assert(DstVNI && "Missing defined value"); assert(DstVNI->def == Idx.getDefIndex() && "Wrong copy def slot"); - WorkList.push_back(std::make_pair(DstReg, DstVNI)); + WorkList.push_back(std::make_pair(&DstLI, DstVNI)); } continue; } @@ -841,7 +842,6 @@ void InlineSpiller::spill(LiveRangeEdit &edit) { Edit = &edit; assert(!TargetRegisterInfo::isStackSlot(edit.getReg()) && "Trying to spill a stack slot."); - // Share a stack slot among all descendants of Original. Original = VRM.getOriginal(edit.getReg()); StackSlot = VRM.getStackSlot(Original); -- 2.11.0