summaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-09-03 07:15:37 +0000
committerChris Lattner <sabre@nondot.org>2006-09-03 07:15:37 +0000
commit5e50349070972ca4e590f6211184df1d4ec28ac8 (patch)
treee9a11f8fa7b8db68fc38cd055e4ca2e3261a34b0 /lib/CodeGen
parent6cfca76349963d8aa8122157c02c4c156b852744 (diff)
downloadllvm-5e50349070972ca4e590f6211184df1d4ec28ac8.tar.gz
llvm-5e50349070972ca4e590f6211184df1d4ec28ac8.tar.bz2
llvm-5e50349070972ca4e590f6211184df1d4ec28ac8.tar.xz
Fix Regression/CodeGen/Generic/2006-09-02-LocalAllocCrash.ll on X86.
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
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/RegAllocLocal.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp
index c435c34f49..e3f3ab6fa3 100644
--- a/lib/CodeGen/RegAllocLocal.cpp
+++ b/lib/CodeGen/RegAllocLocal.cpp
@@ -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])) {
@@ -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;
}
}