X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FInterferenceCache.cpp;h=fd5749bfefa069391ee36d25bdbba5966ac6ff97;hb=027a9f45617c2a9ecb809e6b28aac12bdc2d08ec;hp=1541bf0c85122bb543bb4a22b2638ebc56f265fb;hpb=042888db2bb195c86bf34afbb6907d70855d2830;p=oota-llvm.git diff --git a/lib/CodeGen/InterferenceCache.cpp b/lib/CodeGen/InterferenceCache.cpp index 1541bf0c851..fd5749bfefa 100644 --- a/lib/CodeGen/InterferenceCache.cpp +++ b/lib/CodeGen/InterferenceCache.cpp @@ -11,16 +11,34 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "regalloc" #include "InterferenceCache.h" -#include "llvm/Target/TargetRegisterInfo.h" -#include "llvm/Support/ErrorHandling.h" #include "llvm/CodeGen/LiveIntervalAnalysis.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Target/TargetRegisterInfo.h" using namespace llvm; +#define DEBUG_TYPE "regalloc" + // Static member used for null interference cursors. -InterferenceCache::BlockInterference InterferenceCache::Cursor::NoInterference; +const InterferenceCache::BlockInterference + InterferenceCache::Cursor::NoInterference; + +// Initializes PhysRegEntries (instead of a SmallVector, PhysRegEntries is a +// buffer of size NumPhysRegs to speed up alloc/clear for targets with large +// reg files). Calloced memory is used for good form, and quites tools like +// Valgrind too, but zero initialized memory is not required by the algorithm: +// this is because PhysRegEntries works like a SparseSet and its entries are +// only valid when there is a corresponding CacheEntries assignment. There is +// also support for when pass managers are reused for targets with different +// numbers of PhysRegs: in this case PhysRegEntries is freed and reinitialized. +void InterferenceCache::reinitPhysRegEntries() { + if (PhysRegEntriesCount == TRI->getNumRegs()) return; + free(PhysRegEntries); + PhysRegEntriesCount = TRI->getNumRegs(); + PhysRegEntries = (unsigned char*) + calloc(PhysRegEntriesCount, sizeof(unsigned char)); +} void InterferenceCache::init(MachineFunction *mf, LiveIntervalUnion *liuarray, @@ -30,7 +48,7 @@ void InterferenceCache::init(MachineFunction *mf, MF = mf; LIUArray = liuarray; TRI = tri; - PhysRegEntries.assign(TRI->getNumRegs(), 0); + reinitPhysRegEntries(); for (unsigned i = 0; i != CacheEntries; ++i) Entries[i].clear(mf, indexes, lis); } @@ -105,7 +123,7 @@ bool InterferenceCache::Entry::valid(LiveIntervalUnion *LIUArray, void InterferenceCache::Entry::update(unsigned MBBNum) { SlotIndex Start, Stop; - tie(Start, Stop) = Indexes->getMBBRange(MBBNum); + std::tie(Start, Stop) = Indexes->getMBBRange(MBBNum); // Use advanceTo only when possible. if (PrevPos != Start) { @@ -182,7 +200,7 @@ void InterferenceCache::Entry::update(unsigned MBBNum) { BI = &Blocks[MBBNum]; if (BI->Tag == Tag) return; - tie(Start, Stop) = Indexes->getMBBRange(MBBNum); + std::tie(Start, Stop) = Indexes->getMBBRange(MBBNum); } // Check for last interference in block. @@ -204,11 +222,11 @@ void InterferenceCache::Entry::update(unsigned MBBNum) { // Fixed interference. for (unsigned i = 0, e = RegUnits.size(); i != e; ++i) { LiveInterval::iterator &I = RegUnits[i].FixedI; - LiveInterval *LI = RegUnits[i].Fixed; - if (I == LI->end() || I->start >= Stop) + LiveRange *LR = RegUnits[i].Fixed; + if (I == LR->end() || I->start >= Stop) continue; - I = LI->advanceTo(I, Stop); - bool Backup = I == LI->end() || I->start >= Stop; + I = LR->advanceTo(I, Stop); + bool Backup = I == LR->end() || I->start >= Stop; if (Backup) --I; SlotIndex StopI = I->end;