Skip to content

Commit

Permalink
Fix Regression/CodeGen/Generic/2006-09-02-LocalAllocCrash.ll on X86.
Browse files Browse the repository at this point in the history
Just because an alias of a register is available, it doesn't mean that we
can arbitrarily evict the register.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30064 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Sep 3, 2006
1 parent 6cfca76 commit 5e50349
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/CodeGen/RegAllocLocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ namespace {
}

void MarkPhysRegRecentlyUsed(unsigned Reg) {
if(PhysRegsUseOrder.empty() ||
PhysRegsUseOrder.back() == Reg) return; // Already most recently used
if (PhysRegsUseOrder.empty() ||
PhysRegsUseOrder.back() == Reg) return; // Already most recently used

for (unsigned i = PhysRegsUseOrder.size(); i != 0; --i)
if (areRegsEqual(Reg, PhysRegsUseOrder[i-1])) {
Expand Down Expand Up @@ -408,10 +408,15 @@ unsigned RA::getReg(MachineBasicBlock &MBB, MachineInstr *I,
} else {
// If one of the registers aliased to the current register is
// compatible, use it.
for (const unsigned *AliasSet = RegInfo->getAliasSet(R);
*AliasSet; ++AliasSet) {
if (RC->contains(*AliasSet)) {
PhysReg = *AliasSet; // Take an aliased register
for (const unsigned *AliasIt = RegInfo->getAliasSet(R);
*AliasIt; ++AliasIt) {
if (RC->contains(*AliasIt) &&
// If this is pinned down for some reason, don't use it. For
// example, if CL is pinned, and we run across CH, don't use
// CH as justification for using scavenging ECX (which will
// fail).
PhysRegsUsed[*AliasIt] != 0) {
PhysReg = *AliasIt; // Take an aliased register
break;
}
}
Expand Down

0 comments on commit 5e50349

Please sign in to comment.