Revert r135074 and r135080. They broke clamscan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135096 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen 2011-07-13 22:20:09 +00:00
parent d986bc66bc
commit 54c74e906a
2 changed files with 28 additions and 34 deletions

View File

@ -127,14 +127,10 @@ public:
Entry *CacheEntry; Entry *CacheEntry;
BlockInterference *Current; BlockInterference *Current;
public: public:
/// Cursor - Create a dangling cursor. /// Cursor - Create a cursor for the interference allocated to PhysReg and
Cursor() : CacheEntry(0), Current(0) {} /// all its aliases.
Cursor(InterferenceCache &Cache, unsigned PhysReg)
/// setPhysReg - Point this cursor to PhysReg's interference. : CacheEntry(Cache.get(PhysReg)), Current(0) {}
void setPhysReg(InterferenceCache &Cache, unsigned PhysReg) {
CacheEntry = Cache.get(PhysReg);
Current = 0;
}
/// moveTo - Move cursor to basic block MBBNum. /// moveTo - Move cursor to basic block MBBNum.
void moveToBlock(unsigned MBBNum) { void moveToBlock(unsigned MBBNum) {

View File

@ -160,13 +160,11 @@ class RAGreedy : public MachineFunctionPass,
/// Global live range splitting candidate info. /// Global live range splitting candidate info.
struct GlobalSplitCandidate { struct GlobalSplitCandidate {
unsigned PhysReg; unsigned PhysReg;
InterferenceCache::Cursor Intf;
BitVector LiveBundles; BitVector LiveBundles;
SmallVector<unsigned, 8> ActiveBlocks; SmallVector<unsigned, 8> ActiveBlocks;
void reset(InterferenceCache &Cache, unsigned Reg) { void reset(unsigned Reg) {
PhysReg = Reg; PhysReg = Reg;
Intf.setPhysReg(Cache, Reg);
LiveBundles.clear(); LiveBundles.clear();
ActiveBlocks.clear(); ActiveBlocks.clear();
} }
@ -208,8 +206,8 @@ private:
float calcSpillCost(); float calcSpillCost();
bool addSplitConstraints(InterferenceCache::Cursor, float&); bool addSplitConstraints(InterferenceCache::Cursor, float&);
void addThroughConstraints(InterferenceCache::Cursor, ArrayRef<unsigned>); void addThroughConstraints(InterferenceCache::Cursor, ArrayRef<unsigned>);
void growRegion(GlobalSplitCandidate &Cand); void growRegion(GlobalSplitCandidate &Cand, InterferenceCache::Cursor);
float calcGlobalSplitCost(GlobalSplitCandidate&); float calcGlobalSplitCost(GlobalSplitCandidate&, InterferenceCache::Cursor);
void splitAroundRegion(LiveInterval&, GlobalSplitCandidate&, void splitAroundRegion(LiveInterval&, GlobalSplitCandidate&,
SmallVectorImpl<LiveInterval*>&); SmallVectorImpl<LiveInterval*>&);
void calcGapWeights(unsigned, SmallVectorImpl<float>&); void calcGapWeights(unsigned, SmallVectorImpl<float>&);
@ -722,7 +720,8 @@ void RAGreedy::addThroughConstraints(InterferenceCache::Cursor Intf,
SpillPlacer->addLinks(ArrayRef<unsigned>(TBS, T)); SpillPlacer->addLinks(ArrayRef<unsigned>(TBS, T));
} }
void RAGreedy::growRegion(GlobalSplitCandidate &Cand) { void RAGreedy::growRegion(GlobalSplitCandidate &Cand,
InterferenceCache::Cursor Intf) {
// Keep track of through blocks that have not been added to SpillPlacer. // Keep track of through blocks that have not been added to SpillPlacer.
BitVector Todo = SA->getThroughBlocks(); BitVector Todo = SA->getThroughBlocks();
SmallVectorImpl<unsigned> &ActiveBlocks = Cand.ActiveBlocks; SmallVectorImpl<unsigned> &ActiveBlocks = Cand.ActiveBlocks;
@ -754,7 +753,7 @@ void RAGreedy::growRegion(GlobalSplitCandidate &Cand) {
// Any new blocks to add? // Any new blocks to add?
if (ActiveBlocks.size() == AddedTo) if (ActiveBlocks.size() == AddedTo)
break; break;
addThroughConstraints(Cand.Intf, addThroughConstraints(Intf,
ArrayRef<unsigned>(ActiveBlocks).slice(AddedTo)); ArrayRef<unsigned>(ActiveBlocks).slice(AddedTo));
AddedTo = ActiveBlocks.size(); AddedTo = ActiveBlocks.size();
@ -795,7 +794,8 @@ float RAGreedy::calcSpillCost() {
/// pattern in LiveBundles. This cost should be added to the local cost of the /// pattern in LiveBundles. This cost should be added to the local cost of the
/// interference pattern in SplitConstraints. /// interference pattern in SplitConstraints.
/// ///
float RAGreedy::calcGlobalSplitCost(GlobalSplitCandidate &Cand) { float RAGreedy::calcGlobalSplitCost(GlobalSplitCandidate &Cand,
InterferenceCache::Cursor Intf) {
float GlobalCost = 0; float GlobalCost = 0;
const BitVector &LiveBundles = Cand.LiveBundles; const BitVector &LiveBundles = Cand.LiveBundles;
ArrayRef<SplitAnalysis::BlockInfo> UseBlocks = SA->getUseBlocks(); ArrayRef<SplitAnalysis::BlockInfo> UseBlocks = SA->getUseBlocks();
@ -822,8 +822,8 @@ float RAGreedy::calcGlobalSplitCost(GlobalSplitCandidate &Cand) {
continue; continue;
if (RegIn && RegOut) { if (RegIn && RegOut) {
// We need double spill code if this block has interference. // We need double spill code if this block has interference.
Cand.Intf.moveToBlock(Number); Intf.moveToBlock(Number);
if (Cand.Intf.hasInterference()) if (Intf.hasInterference())
GlobalCost += 2*SpillPlacer->getBlockFrequency(Number); GlobalCost += 2*SpillPlacer->getBlockFrequency(Number);
continue; continue;
} }
@ -853,7 +853,7 @@ void RAGreedy::splitAroundRegion(LiveInterval &VirtReg,
dbgs() << ".\n"; dbgs() << ".\n";
}); });
InterferenceCache::Cursor &Intf = Cand.Intf; InterferenceCache::Cursor Intf(IntfCache, Cand.PhysReg);
LiveRangeEdit LREdit(VirtReg, NewVRegs, this); LiveRangeEdit LREdit(VirtReg, NewVRegs, this);
SE->reset(LREdit); SE->reset(LREdit);
@ -1243,18 +1243,17 @@ unsigned RAGreedy::tryRegionSplit(LiveInterval &VirtReg, AllocationOrder &Order,
DEBUG(dbgs() << "Cost of isolating all blocks = " << BestCost << '\n'); DEBUG(dbgs() << "Cost of isolating all blocks = " << BestCost << '\n');
const unsigned NoCand = ~0u; const unsigned NoCand = ~0u;
unsigned BestCand = NoCand; unsigned BestCand = NoCand;
unsigned NumCands = 0;
Order.rewind(); Order.rewind();
while (unsigned PhysReg = Order.next()) { for (unsigned Cand = 0; unsigned PhysReg = Order.next(); ++Cand) {
if (GlobalCand.size() <= NumCands) if (GlobalCand.size() <= Cand)
GlobalCand.resize(NumCands+1); GlobalCand.resize(Cand+1);
GlobalSplitCandidate &Cand = GlobalCand[NumCands]; GlobalCand[Cand].reset(PhysReg);
Cand.reset(IntfCache, PhysReg);
SpillPlacer->prepare(Cand.LiveBundles); SpillPlacer->prepare(GlobalCand[Cand].LiveBundles);
float Cost; float Cost;
if (!addSplitConstraints(Cand.Intf, Cost)) { InterferenceCache::Cursor Intf(IntfCache, PhysReg);
if (!addSplitConstraints(Intf, Cost)) {
DEBUG(dbgs() << PrintReg(PhysReg, TRI) << "\tno positive bundles\n"); DEBUG(dbgs() << PrintReg(PhysReg, TRI) << "\tno positive bundles\n");
continue; continue;
} }
@ -1269,29 +1268,28 @@ unsigned RAGreedy::tryRegionSplit(LiveInterval &VirtReg, AllocationOrder &Order,
}); });
continue; continue;
} }
growRegion(Cand); growRegion(GlobalCand[Cand], Intf);
SpillPlacer->finish(); SpillPlacer->finish();
// No live bundles, defer to splitSingleBlocks(). // No live bundles, defer to splitSingleBlocks().
if (!Cand.LiveBundles.any()) { if (!GlobalCand[Cand].LiveBundles.any()) {
DEBUG(dbgs() << " no bundles.\n"); DEBUG(dbgs() << " no bundles.\n");
continue; continue;
} }
Cost += calcGlobalSplitCost(Cand); Cost += calcGlobalSplitCost(GlobalCand[Cand], Intf);
DEBUG({ DEBUG({
dbgs() << ", total = " << Cost << " with bundles"; dbgs() << ", total = " << Cost << " with bundles";
for (int i = Cand.LiveBundles.find_first(); i>=0; for (int i = GlobalCand[Cand].LiveBundles.find_first(); i>=0;
i = Cand.LiveBundles.find_next(i)) i = GlobalCand[Cand].LiveBundles.find_next(i))
dbgs() << " EB#" << i; dbgs() << " EB#" << i;
dbgs() << ".\n"; dbgs() << ".\n";
}); });
if (Cost < BestCost) { if (Cost < BestCost) {
BestCand = NumCands; BestCand = Cand;
BestCost = Hysteresis * Cost; // Prevent rounding effects. BestCost = Hysteresis * Cost; // Prevent rounding effects.
} }
++NumCands;
} }
if (BestCand == NoCand) if (BestCand == NoCand)