diff options
Diffstat (limited to 'llvm/lib/CodeGen/RegAllocGreedy.cpp')
-rw-r--r-- | llvm/lib/CodeGen/RegAllocGreedy.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp index 4fa2bc7..b94992c 100644 --- a/llvm/lib/CodeGen/RegAllocGreedy.cpp +++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp @@ -140,7 +140,7 @@ static cl::opt<bool> GreedyReverseLocalAssignment( static cl::opt<unsigned> SplitThresholdForRegWithHint( "split-threshold-for-reg-with-hint", cl::desc("The threshold for splitting a virtual register with a hint, in " - "percentate"), + "percentage"), cl::init(75), cl::Hidden); static RegisterRegAlloc greedyRegAlloc("greedy", "greedy register allocator", @@ -376,6 +376,12 @@ unsigned DefaultPriorityAdvisor::getPriority(const LiveInterval &LI) const { return Prio; } +unsigned DummyPriorityAdvisor::getPriority(const LiveInterval &LI) const { + // Prioritize by virtual register number, lowest first. + Register Reg = LI.reg(); + return ~Reg.virtRegIndex(); +} + const LiveInterval *RAGreedy::dequeue() { return dequeue(Queue); } const LiveInterval *RAGreedy::dequeue(PQueue &CurQueue) { @@ -2029,6 +2035,9 @@ unsigned RAGreedy::tryLastChanceRecoloring(const LiveInterval &VirtReg, // available colors. Matrix->assign(VirtReg, PhysReg); + // VirtReg may be deleted during tryRecoloringCandidates, save a copy. + Register ThisVirtReg = VirtReg.reg(); + // Save the current recoloring state. // If we cannot recolor all the interferences, we will have to start again // at this point for the next physical register. @@ -2040,8 +2049,16 @@ unsigned RAGreedy::tryLastChanceRecoloring(const LiveInterval &VirtReg, NewVRegs.push_back(NewVReg); // Do not mess up with the global assignment process. // I.e., VirtReg must be unassigned. - Matrix->unassign(VirtReg); - return PhysReg; + if (VRM->hasPhys(ThisVirtReg)) { + Matrix->unassign(VirtReg); + return PhysReg; + } + + // It is possible VirtReg will be deleted during tryRecoloringCandidates. + LLVM_DEBUG(dbgs() << "tryRecoloringCandidates deleted a fixed register " + << printReg(ThisVirtReg) << '\n'); + FixedRegisters.erase(ThisVirtReg); + return 0; } LLVM_DEBUG(dbgs() << "Fail to assign: " << VirtReg << " to " |