[llvm] r262151 - CodeGen: Update LiveIntervalAnalysis API to use MachineInstr&, NFC
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 27 12:14:29 PST 2016
Author: dexonsmith
Date: Sat Feb 27 14:14:29 2016
New Revision: 262151
URL: http://llvm.org/viewvc/llvm-project?rev=262151&view=rev
Log:
CodeGen: Update LiveIntervalAnalysis API to use MachineInstr&, NFC
These parameters aren't expected to be null, so take them by reference.
Modified:
llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h
llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp
llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
llvm/trunk/lib/CodeGen/MachineScheduler.cpp
llvm/trunk/lib/CodeGen/StackSlotColoring.cpp
llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp
llvm/trunk/lib/Target/AMDGPU/SIMachineScheduler.cpp
Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=262151&r1=262150&r2=262151&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Sat Feb 27 14:14:29 2016
@@ -105,7 +105,7 @@ extern cl::opt<bool> UseSegmentSetForPhy
// Calculate the spill weight to assign to a single instruction.
static float getSpillWeight(bool isDef, bool isUse,
const MachineBlockFrequencyInfo *MBFI,
- const MachineInstr *Instr);
+ const MachineInstr &Instr);
LiveInterval &getInterval(unsigned Reg) {
if (hasInterval(Reg))
@@ -288,7 +288,7 @@ extern cl::opt<bool> UseSegmentSetForPhy
/// are not supported.
///
/// \param UpdateFlags Update live intervals for nonallocatable physregs.
- void handleMove(MachineInstr* MI, bool UpdateFlags = false);
+ void handleMove(MachineInstr &MI, bool UpdateFlags = false);
/// moveIntoBundle - Update intervals for operands of MI so that they
/// begin/end on the SlotIndex for BundleStart.
@@ -298,7 +298,7 @@ extern cl::opt<bool> UseSegmentSetForPhy
/// Requires MI and BundleStart to have SlotIndexes, and assumes
/// existing liveness is accurate. BundleStart should be the first
/// instruction in the Bundle.
- void handleMoveIntoBundle(MachineInstr* MI, MachineInstr* BundleStart,
+ void handleMoveIntoBundle(MachineInstr &MI, MachineInstr &BundleStart,
bool UpdateFlags = false);
/// repairIntervalsInRange - Update live intervals for instructions in a
Modified: llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp?rev=262151&r1=262150&r2=262151&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp (original)
+++ llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp Sat Feb 27 14:14:29 2016
@@ -170,8 +170,7 @@ VirtRegAuxInfo::calculateSpillWeightAndH
// Calculate instr weight.
bool reads, writes;
std::tie(reads, writes) = mi->readsWritesVirtualRegister(li.reg);
- weight = LiveIntervals::getSpillWeight(
- writes, reads, &MBFI, mi);
+ weight = LiveIntervals::getSpillWeight(writes, reads, &MBFI, *mi);
// Give extra weight to what looks like a loop induction variable update.
if (writes && isExiting && LIS.isLiveOutOfMBB(li, mbb))
Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=262151&r1=262150&r2=262151&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Sat Feb 27 14:14:29 2016
@@ -841,11 +841,10 @@ LiveIntervals::hasPHIKill(const LiveInte
return false;
}
-float
-LiveIntervals::getSpillWeight(bool isDef, bool isUse,
- const MachineBlockFrequencyInfo *MBFI,
- const MachineInstr *MI) {
- BlockFrequency Freq = MBFI->getBlockFreq(MI->getParent());
+float LiveIntervals::getSpillWeight(bool isDef, bool isUse,
+ const MachineBlockFrequencyInfo *MBFI,
+ const MachineInstr &MI) {
+ BlockFrequency Freq = MBFI->getBlockFreq(MI.getParent());
const float Scale = 1.0f / MBFI->getEntryFreq();
return (isDef + isUse) * (Freq.getFrequency() * Scale);
}
@@ -1391,26 +1390,26 @@ private:
}
};
-void LiveIntervals::handleMove(MachineInstr* MI, bool UpdateFlags) {
- assert(!MI->isBundled() && "Can't handle bundled instructions yet.");
- SlotIndex OldIndex = Indexes->getInstructionIndex(*MI);
- Indexes->removeMachineInstrFromMaps(*MI);
- SlotIndex NewIndex = Indexes->insertMachineInstrInMaps(*MI);
- assert(getMBBStartIdx(MI->getParent()) <= OldIndex &&
- OldIndex < getMBBEndIdx(MI->getParent()) &&
+void LiveIntervals::handleMove(MachineInstr &MI, bool UpdateFlags) {
+ assert(!MI.isBundled() && "Can't handle bundled instructions yet.");
+ SlotIndex OldIndex = Indexes->getInstructionIndex(MI);
+ Indexes->removeMachineInstrFromMaps(MI);
+ SlotIndex NewIndex = Indexes->insertMachineInstrInMaps(MI);
+ assert(getMBBStartIdx(MI.getParent()) <= OldIndex &&
+ OldIndex < getMBBEndIdx(MI.getParent()) &&
"Cannot handle moves across basic block boundaries.");
HMEditor HME(*this, *MRI, *TRI, OldIndex, NewIndex, UpdateFlags);
- HME.updateAllRanges(MI);
+ HME.updateAllRanges(&MI);
}
-void LiveIntervals::handleMoveIntoBundle(MachineInstr* MI,
- MachineInstr* BundleStart,
+void LiveIntervals::handleMoveIntoBundle(MachineInstr &MI,
+ MachineInstr &BundleStart,
bool UpdateFlags) {
- SlotIndex OldIndex = Indexes->getInstructionIndex(*MI);
- SlotIndex NewIndex = Indexes->getInstructionIndex(*BundleStart);
+ SlotIndex OldIndex = Indexes->getInstructionIndex(MI);
+ SlotIndex NewIndex = Indexes->getInstructionIndex(BundleStart);
HMEditor HME(*this, *MRI, *TRI, OldIndex, NewIndex, UpdateFlags);
- HME.updateAllRanges(MI);
+ HME.updateAllRanges(&MI);
}
void LiveIntervals::repairOldRegInRange(const MachineBasicBlock::iterator Begin,
@@ -1427,18 +1426,19 @@ void LiveIntervals::repairOldRegInRange(
for (MachineBasicBlock::iterator I = End; I != Begin;) {
--I;
- MachineInstr *MI = I;
- if (MI->isDebugValue())
+ MachineInstr &MI = *I;
+ if (MI.isDebugValue())
continue;
- SlotIndex instrIdx = getInstructionIndex(*MI);
+ SlotIndex instrIdx = getInstructionIndex(MI);
bool isStartValid = getInstructionFromIndex(LII->start);
bool isEndValid = getInstructionFromIndex(LII->end);
// FIXME: This doesn't currently handle early-clobber or multiple removed
// defs inside of the region to repair.
- for (MachineInstr::mop_iterator OI = MI->operands_begin(),
- OE = MI->operands_end(); OI != OE; ++OI) {
+ for (MachineInstr::mop_iterator OI = MI.operands_begin(),
+ OE = MI.operands_end();
+ OI != OE; ++OI) {
const MachineOperand &MO = *OI;
if (!MO.isReg() || MO.getReg() != Reg)
continue;
@@ -1523,11 +1523,12 @@ LiveIntervals::repairIntervalsInRange(Ma
for (MachineBasicBlock::iterator I = End; I != Begin;) {
--I;
- MachineInstr *MI = I;
- if (MI->isDebugValue())
+ MachineInstr &MI = *I;
+ if (MI.isDebugValue())
continue;
- for (MachineInstr::const_mop_iterator MOI = MI->operands_begin(),
- MOE = MI->operands_end(); MOI != MOE; ++MOI) {
+ for (MachineInstr::const_mop_iterator MOI = MI.operands_begin(),
+ MOE = MI.operands_end();
+ MOI != MOE; ++MOI) {
if (MOI->isReg() &&
TargetRegisterInfo::isVirtualRegister(MOI->getReg()) &&
!hasInterval(MOI->getReg())) {
Modified: llvm/trunk/lib/CodeGen/MachineScheduler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineScheduler.cpp?rev=262151&r1=262150&r2=262151&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineScheduler.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineScheduler.cpp Sat Feb 27 14:14:29 2016
@@ -651,7 +651,7 @@ void ScheduleDAGMI::moveInstruction(
// Update LiveIntervals
if (LIS)
- LIS->handleMove(MI, /*UpdateFlags=*/true);
+ LIS->handleMove(*MI, /*UpdateFlags=*/true);
// Recede RegionBegin if an instruction moves above the first.
if (RegionBegin == InsertPos)
Modified: llvm/trunk/lib/CodeGen/StackSlotColoring.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackSlotColoring.cpp?rev=262151&r1=262150&r2=262151&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/StackSlotColoring.cpp (original)
+++ llvm/trunk/lib/CodeGen/StackSlotColoring.cpp Sat Feb 27 14:14:29 2016
@@ -145,9 +145,9 @@ void StackSlotColoring::ScanForSpillSlot
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::ScanForSpillSlot
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>(
Modified: llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp?rev=262151&r1=262150&r2=262151&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp (original)
+++ llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Sat Feb 27 14:14:29 2016
@@ -306,7 +306,7 @@ sink3AddrInstruction(MachineInstr *MI, u
MBB->insert(KillPos, MI);
if (LIS)
- LIS->handleMove(MI);
+ LIS->handleMove(*MI);
++Num3AddrSunk;
return true;
@@ -957,7 +957,7 @@ rescheduleMIBelowKill(MachineBasicBlock:
MachineInstr *CopyMI = MBBI;
++MBBI;
MBB->splice(InsertPos, MBB, CopyMI);
- LIS->handleMove(CopyMI);
+ LIS->handleMove(*CopyMI);
InsertPos = CopyMI;
}
End = std::next(MachineBasicBlock::iterator(MI));
@@ -969,7 +969,7 @@ rescheduleMIBelowKill(MachineBasicBlock:
// Update live variables
if (LIS) {
- LIS->handleMove(MI);
+ LIS->handleMove(*MI);
} else {
LV->removeVirtualRegisterKilled(Reg, KillMI);
LV->addVirtualRegisterKilled(Reg, MI);
@@ -1137,7 +1137,7 @@ rescheduleKillAboveMI(MachineBasicBlock:
// Update live variables
if (LIS) {
- LIS->handleMove(KillMI);
+ LIS->handleMove(*KillMI);
} else {
LV->removeVirtualRegisterKilled(Reg, KillMI);
LV->addVirtualRegisterKilled(Reg, MI);
Modified: llvm/trunk/lib/Target/AMDGPU/SIMachineScheduler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIMachineScheduler.cpp?rev=262151&r1=262150&r2=262151&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIMachineScheduler.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIMachineScheduler.cpp Sat Feb 27 14:14:29 2016
@@ -1224,7 +1224,7 @@ void SIScheduleBlockCreator::scheduleIns
// is the most cpu intensive operation of the scheduler.
// It would gain a lot if there was a way to recompute the
// LiveIntervals for the entire scheduling region.
- DAG->getLIS()->handleMove(MI, /*UpdateFlags=*/true);
+ DAG->getLIS()->handleMove(*MI, /*UpdateFlags=*/true);
PosNew.push_back(CurrentTopFastSched);
}
}
@@ -1250,7 +1250,7 @@ void SIScheduleBlockCreator::scheduleIns
DAG->getBB()->splice(POld, DAG->getBB(), PNew);
// Update LiveIntervals.
- DAG->getLIS()->handleMove(POld, /*UpdateFlags=*/true);
+ DAG->getLIS()->handleMove(*POld, /*UpdateFlags=*/true);
}
}
More information about the llvm-commits
mailing list