diff options
Diffstat (limited to 'gnu/llvm/lib/CodeGen/StackSlotColoring.cpp')
| -rw-r--r-- | gnu/llvm/lib/CodeGen/StackSlotColoring.cpp | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/gnu/llvm/lib/CodeGen/StackSlotColoring.cpp b/gnu/llvm/lib/CodeGen/StackSlotColoring.cpp index 51f4d0e6817..d996714a414 100644 --- a/gnu/llvm/lib/CodeGen/StackSlotColoring.cpp +++ b/gnu/llvm/lib/CodeGen/StackSlotColoring.cpp @@ -107,7 +107,7 @@ namespace { bool OverlapWithAssignments(LiveInterval *li, int Color) const; int ColorSlot(LiveInterval *li); bool ColorSlots(MachineFunction &MF); - void RewriteInstruction(MachineInstr *MI, SmallVectorImpl<int> &SlotMapping, + void RewriteInstruction(MachineInstr &MI, SmallVectorImpl<int> &SlotMapping, MachineFunction &MF); bool RemoveDeadStores(MachineBasicBlock* MBB); }; @@ -145,9 +145,9 @@ void StackSlotColoring::ScanForSpillSlotRefs(MachineFunction &MF) { MachineBasicBlock *MBB = &*MBBI; for (MachineBasicBlock::iterator MII = MBB->begin(), EE = MBB->end(); MII != EE; ++MII) { - MachineInstr *MI = &*MII; - for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - MachineOperand &MO = MI->getOperand(i); + MachineInstr &MI = *MII; + for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI.getOperand(i); if (!MO.isFI()) continue; int FI = MO.getIndex(); @@ -156,11 +156,12 @@ void StackSlotColoring::ScanForSpillSlotRefs(MachineFunction &MF) { if (!LS->hasInterval(FI)) continue; LiveInterval &li = LS->getInterval(FI); - if (!MI->isDebugValue()) + if (!MI.isDebugValue()) li.weight += LiveIntervals::getSpillWeight(false, true, MBFI, MI); } - for (MachineInstr::mmo_iterator MMOI = MI->memoperands_begin(), - EE = MI->memoperands_end(); MMOI != EE; ++MMOI) { + for (MachineInstr::mmo_iterator MMOI = MI.memoperands_begin(), + EE = MI.memoperands_end(); + MMOI != EE; ++MMOI) { MachineMemOperand *MMO = *MMOI; if (const FixedStackPseudoSourceValue *FSV = dyn_cast_or_null<FixedStackPseudoSourceValue>( @@ -325,13 +326,10 @@ bool StackSlotColoring::ColorSlots(MachineFunction &MF) { } // Rewrite all MO_FrameIndex operands. Look for dead stores. - for (MachineFunction::iterator MBBI = MF.begin(), E = MF.end(); - MBBI != E; ++MBBI) { - MachineBasicBlock *MBB = &*MBBI; - for (MachineBasicBlock::iterator MII = MBB->begin(), EE = MBB->end(); - MII != EE; ++MII) - RewriteInstruction(MII, SlotMapping, MF); - RemoveDeadStores(MBB); + for (MachineBasicBlock &MBB : MF) { + for (MachineInstr &MI : MBB) + RewriteInstruction(MI, SlotMapping, MF); + RemoveDeadStores(&MBB); } // Delete unused stack slots. @@ -346,12 +344,12 @@ bool StackSlotColoring::ColorSlots(MachineFunction &MF) { /// RewriteInstruction - Rewrite specified instruction by replacing references /// to old frame index with new one. -void StackSlotColoring::RewriteInstruction(MachineInstr *MI, +void StackSlotColoring::RewriteInstruction(MachineInstr &MI, SmallVectorImpl<int> &SlotMapping, MachineFunction &MF) { // Update the operands. - for (unsigned i = 0, ee = MI->getNumOperands(); i != ee; ++i) { - MachineOperand &MO = MI->getOperand(i); + for (unsigned i = 0, ee = MI.getNumOperands(); i != ee; ++i) { + MachineOperand &MO = MI.getOperand(i); if (!MO.isFI()) continue; int OldFI = MO.getIndex(); @@ -385,12 +383,11 @@ bool StackSlotColoring::RemoveDeadStores(MachineBasicBlock* MBB) { break; int FirstSS, SecondSS; - if (TII->isStackSlotCopy(I, FirstSS, SecondSS) && - FirstSS == SecondSS && + if (TII->isStackSlotCopy(*I, FirstSS, SecondSS) && FirstSS == SecondSS && FirstSS != -1) { ++NumDead; changed = true; - toErase.push_back(I); + toErase.push_back(&*I); continue; } @@ -399,8 +396,10 @@ bool StackSlotColoring::RemoveDeadStores(MachineBasicBlock* MBB) { unsigned LoadReg = 0; unsigned StoreReg = 0; - if (!(LoadReg = TII->isLoadFromStackSlot(I, FirstSS))) continue; - if (!(StoreReg = TII->isStoreToStackSlot(NextMI, SecondSS))) continue; + if (!(LoadReg = TII->isLoadFromStackSlot(*I, FirstSS))) + continue; + if (!(StoreReg = TII->isStoreToStackSlot(*NextMI, SecondSS))) + continue; if (FirstSS != SecondSS || LoadReg != StoreReg || FirstSS == -1) continue; ++NumDead; @@ -408,10 +407,10 @@ bool StackSlotColoring::RemoveDeadStores(MachineBasicBlock* MBB) { if (NextMI->findRegisterUseOperandIdx(LoadReg, true, nullptr) != -1) { ++NumDead; - toErase.push_back(I); + toErase.push_back(&*I); } - toErase.push_back(NextMI); + toErase.push_back(&*NextMI); ++I; } |
