diff options
| author | Chris Lattner <sabre@nondot.org> | 2003-08-23 23:49:42 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2003-08-23 23:49:42 +0000 | 
| commit | 41822c790f7f0502e604fa2fa26e8edb022fda8c (patch) | |
| tree | 74d0efa21f5737740be58bd03a108f543ec156a1 /lib/CodeGen/RegAllocLocal.cpp | |
| parent | ae1c1ffacd160666df0daafb5dcc62eb33dfbf19 (diff) | |
Fix bug: Jello/2003-08-23-RegisterAllocatePhysReg.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8095 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAllocLocal.cpp')
| -rw-r--r-- | lib/CodeGen/RegAllocLocal.cpp | 34 | 
1 files changed, 21 insertions, 13 deletions
diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp index e0d64cd899..331a291753 100644 --- a/lib/CodeGen/RegAllocLocal.cpp +++ b/lib/CodeGen/RegAllocLocal.cpp @@ -400,19 +400,27 @@ unsigned RA::getReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator &I,               "Couldn't find a register of the appropriate class!");        unsigned R = PhysRegsUseOrder[i]; -      // If the current register is compatible, use it. -      if (RegInfo->getRegClass(R) == RC) { -	PhysReg = R; -	break; -      } else { -	// If one of the registers aliased to the current register is -	// compatible, use it. -	if (const unsigned *AliasSet = RegInfo->getAliasSet(R)) -	  for (unsigned a = 0; AliasSet[a]; ++a) -	    if (RegInfo->getRegClass(AliasSet[a]) == RC) { -	      PhysReg = AliasSet[a];    // Take an aliased register -	      break; -	    } + +      // We can only use this register if it holds a virtual register (ie, it +      // can be spilled).  Do not use it if it is an explicitly allocated +      // physical register! +      assert(PhysRegsUsed.count(R) && +             "PhysReg in PhysRegsUseOrder, but is not allocated?"); +      if (PhysRegsUsed[R]) { +        // If the current register is compatible, use it. +        if (RegInfo->getRegClass(R) == RC) { +          PhysReg = R; +          break; +        } else { +          // If one of the registers aliased to the current register is +          // compatible, use it. +          if (const unsigned *AliasSet = RegInfo->getAliasSet(R)) +            for (unsigned a = 0; AliasSet[a]; ++a) +              if (RegInfo->getRegClass(AliasSet[a]) == RC) { +                PhysReg = AliasSet[a];    // Take an aliased register +                break; +              } +        }        }      }  | 
