Pass context pointers to LiveRangeCalc::reset().

Remove the same pointers from all the other LiveRangeCalc functions,
simplifying the interface.

llvm-svn: 157941
This commit is contained in:
Jakob Stoklund Olesen 2012-06-04 18:21:16 +00:00
parent c4d8a54531
commit 066df8f22f
3 changed files with 45 additions and 55 deletions

View File

@ -17,7 +17,15 @@
using namespace llvm;
void LiveRangeCalc::reset(const MachineFunction *MF) {
void LiveRangeCalc::reset(const MachineFunction *MF,
SlotIndexes *SI,
MachineDominatorTree *MDT,
VNInfo::Allocator *VNIA) {
MRI = &MF->getRegInfo();
Indexes = SI;
DomTree = MDT;
Alloc = VNIA;
unsigned N = MF->getNumBlockIDs();
Seen.clear();
Seen.resize(N);
@ -27,7 +35,7 @@ void LiveRangeCalc::reset(const MachineFunction *MF) {
// Transfer information from the LiveIn vector to the live ranges.
void LiveRangeCalc::updateLiveIns(VNInfo *OverrideVNI, SlotIndexes *Indexes) {
void LiveRangeCalc::updateLiveIns(VNInfo *OverrideVNI) {
for (SmallVectorImpl<LiveInBlock>::iterator I = LiveIn.begin(),
E = LiveIn.end(); I != E; ++I) {
if (!I->DomNode)
@ -55,10 +63,7 @@ void LiveRangeCalc::updateLiveIns(VNInfo *OverrideVNI, SlotIndexes *Indexes) {
void LiveRangeCalc::extend(LiveInterval *LI,
SlotIndex Kill,
SlotIndexes *Indexes,
MachineDominatorTree *DomTree,
VNInfo::Allocator *Alloc) {
SlotIndex Kill) {
assert(LI && "Missing live range");
assert(Kill.isValid() && "Invalid SlotIndex");
assert(Indexes && "Missing SlotIndexes");
@ -75,34 +80,30 @@ void LiveRangeCalc::extend(LiveInterval *LI,
// multiple values, and we may need to create even more phi-defs to preserve
// VNInfo SSA form. Perform a search for all predecessor blocks where we
// know the dominating VNInfo.
VNInfo *VNI = findReachingDefs(LI, KillMBB, Kill, Indexes, DomTree);
VNInfo *VNI = findReachingDefs(LI, KillMBB, Kill);
// When there were multiple different values, we may need new PHIs.
if (!VNI)
updateSSA(Indexes, DomTree, Alloc);
updateSSA();
updateLiveIns(VNI, Indexes);
updateLiveIns(VNI);
}
// This function is called by a client after using the low-level API to add
// live-out and live-in blocks. The unique value optimization is not
// available, SplitEditor::transferValues handles that case directly anyway.
void LiveRangeCalc::calculateValues(SlotIndexes *Indexes,
MachineDominatorTree *DomTree,
VNInfo::Allocator *Alloc) {
void LiveRangeCalc::calculateValues() {
assert(Indexes && "Missing SlotIndexes");
assert(DomTree && "Missing dominator tree");
updateSSA(Indexes, DomTree, Alloc);
updateLiveIns(0, Indexes);
updateSSA();
updateLiveIns(0);
}
VNInfo *LiveRangeCalc::findReachingDefs(LiveInterval *LI,
MachineBasicBlock *KillMBB,
SlotIndex Kill,
SlotIndexes *Indexes,
MachineDominatorTree *DomTree) {
SlotIndex Kill) {
// Blocks where LI should be live-in.
SmallVector<MachineBasicBlock*, 16> WorkList(1, KillMBB);
@ -168,9 +169,7 @@ VNInfo *LiveRangeCalc::findReachingDefs(LiveInterval *LI,
// This is essentially the same iterative algorithm that SSAUpdater uses,
// except we already have a dominator tree, so we don't have to recompute it.
void LiveRangeCalc::updateSSA(SlotIndexes *Indexes,
MachineDominatorTree *DomTree,
VNInfo::Allocator *Alloc) {
void LiveRangeCalc::updateSSA() {
assert(Indexes && "Missing SlotIndexes");
assert(DomTree && "Missing dominator tree");

View File

@ -34,6 +34,11 @@ template <class NodeT> class DomTreeNodeBase;
typedef DomTreeNodeBase<MachineBasicBlock> MachineDomTreeNode;
class LiveRangeCalc {
const MachineRegisterInfo *MRI;
SlotIndexes *Indexes;
MachineDominatorTree *DomTree;
VNInfo::Allocator *Alloc;
/// Seen - Bit vector of active entries in LiveOut, also used as a visited
/// set by findReachingDefs. One entry per basic block, indexed by block
/// number. This is kept as a separate bit vector because it can be cleared
@ -102,24 +107,22 @@ class LiveRangeCalc {
/// NULL is returned.
VNInfo *findReachingDefs(LiveInterval *LI,
MachineBasicBlock *KillMBB,
SlotIndex Kill,
SlotIndexes *Indexes,
MachineDominatorTree *DomTree);
SlotIndex Kill);
/// updateSSA - Compute the values that will be live in to all requested
/// blocks in LiveIn. Create PHI-def values as required to preserve SSA form.
///
/// Every live-in block must be jointly dominated by the added live-out
/// blocks. No values are read from the live ranges.
void updateSSA(SlotIndexes *Indexes,
MachineDominatorTree *DomTree,
VNInfo::Allocator *Alloc);
void updateSSA();
/// updateLiveIns - Add liveness as specified in the LiveIn vector, using VNI
/// as a wildcard value for LiveIn entries without a value.
void updateLiveIns(VNInfo *VNI, SlotIndexes*);
void updateLiveIns(VNInfo *VNI);
public:
LiveRangeCalc() : MRI(0), Indexes(0), DomTree(0), Alloc(0) {}
//===--------------------------------------------------------------------===//
// High-level interface.
//===--------------------------------------------------------------------===//
@ -132,14 +135,14 @@ public:
/// that may overlap a previously computed live range, and before the first
/// live range in a function. If live ranges are not known to be
/// non-overlapping, call reset before each.
void reset(const MachineFunction *MF);
void reset(const MachineFunction *MF,
SlotIndexes*,
MachineDominatorTree*,
VNInfo::Allocator*);
/// calculate - Calculate the live range of a virtual register from its defs
/// and uses. LI must be empty with no values.
void calculate(LiveInterval *LI,
MachineRegisterInfo *MRI,
SlotIndexes *Indexes,
VNInfo::Allocator *Alloc);
void calculate(LiveInterval *LI);
//===--------------------------------------------------------------------===//
// Mid-level interface.
@ -154,21 +157,13 @@ public:
/// Kill is not dominated by a single existing value, PHI-defs are inserted
/// as required to preserve SSA form. If Kill is known to be dominated by a
/// single existing value, Alloc may be null.
void extend(LiveInterval *LI,
SlotIndex Kill,
SlotIndexes *Indexes,
MachineDominatorTree *DomTree,
VNInfo::Allocator *Alloc);
void extend(LiveInterval *LI, SlotIndex Kill);
/// extendToUses - Extend the live range of LI to reach all uses.
///
/// All uses must be jointly dominated by existing liveness. PHI-defs are
/// inserted as needed to preserve SSA form.
void extendToUses(LiveInterval *LI,
MachineRegisterInfo *MRI,
SlotIndexes *Indexes,
MachineDominatorTree *DomTree,
VNInfo::Allocator *Alloc);
void extendToUses(LiveInterval *LI);
//===--------------------------------------------------------------------===//
// Low-level interface.
@ -216,9 +211,7 @@ public:
///
/// Every predecessor of a live-in block must have been given a value with
/// setLiveOutValue, the value may be null for live-trough blocks.
void calculateValues(SlotIndexes *Indexes,
MachineDominatorTree *DomTree,
VNInfo::Allocator *Alloc);
void calculateValues();
};
} // end namespace llvm

View File

@ -345,9 +345,11 @@ void SplitEditor::reset(LiveRangeEdit &LRE, ComplementSpillMode SM) {
Values.clear();
// Reset the LiveRangeCalc instances needed for this spill mode.
LRCalc[0].reset(&VRM.getMachineFunction());
LRCalc[0].reset(&VRM.getMachineFunction(), LIS.getSlotIndexes(), &MDT,
&LIS.getVNInfoAllocator());
if (SpillMode)
LRCalc[1].reset(&VRM.getMachineFunction());
LRCalc[1].reset(&VRM.getMachineFunction(), LIS.getSlotIndexes(), &MDT,
&LIS.getVNInfoAllocator());
// We don't need an AliasAnalysis since we will only be performing
// cheap-as-a-copy remats anyway.
@ -924,11 +926,9 @@ bool SplitEditor::transferValues() {
DEBUG(dbgs() << '\n');
}
LRCalc[0].calculateValues(LIS.getSlotIndexes(), &MDT,
&LIS.getVNInfoAllocator());
LRCalc[0].calculateValues();
if (SpillMode)
LRCalc[1].calculateValues(LIS.getSlotIndexes(), &MDT,
&LIS.getVNInfoAllocator());
LRCalc[1].calculateValues();
return Skipped;
}
@ -953,8 +953,7 @@ void SplitEditor::extendPHIKillRanges() {
if (Edit->getParent().liveAt(LastUse)) {
assert(RegAssign.lookup(LastUse) == RegIdx &&
"Different register assignment in phi predecessor");
LRC.extend(LI, End,
LIS.getSlotIndexes(), &MDT, &LIS.getVNInfoAllocator());
LRC.extend(LI, End);
}
}
}
@ -1004,8 +1003,7 @@ void SplitEditor::rewriteAssigned(bool ExtendRanges) {
} else
Idx = Idx.getRegSlot(true);
getLRCalc(RegIdx).extend(LI, Idx.getNextSlot(), LIS.getSlotIndexes(),
&MDT, &LIS.getVNInfoAllocator());
getLRCalc(RegIdx).extend(LI, Idx.getNextSlot());
}
}