summaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegAllocLocal.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-06-15 22:21:53 +0000
committerChris Lattner <sabre@nondot.org>2006-06-15 22:21:53 +0000
commit44500e3d538a250d8591e708b62741cde0bdc249 (patch)
tree6c56ff45591639202bd3a771b6088d9655d215f4 /lib/CodeGen/RegAllocLocal.cpp
parent8e173de059ab86775d741a53431d8cb746ba7eeb (diff)
downloadllvm-44500e3d538a250d8591e708b62741cde0bdc249.tar.gz
llvm-44500e3d538a250d8591e708b62741cde0bdc249.tar.bz2
llvm-44500e3d538a250d8591e708b62741cde0bdc249.tar.xz
Teach the local allocator to know that live-in values (e.g. arguments) are
live at function entry. This prevents it from using arg registers for other purposes before the arguments are used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28809 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAllocLocal.cpp')
-rw-r--r--lib/CodeGen/RegAllocLocal.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp
index e3921e4ed3..55d412960c 100644
--- a/lib/CodeGen/RegAllocLocal.cpp
+++ b/lib/CodeGen/RegAllocLocal.cpp
@@ -491,6 +491,26 @@ void RA::AllocateBasicBlock(MachineBasicBlock &MBB) {
// loop over each instruction
MachineBasicBlock::iterator MII = MBB.begin();
const TargetInstrInfo &TII = *TM->getInstrInfo();
+
+ // If this is the first basic block in the machine function, add live-in
+ // registers as active.
+ if (&MBB == &*MF->begin()) {
+ for (MachineFunction::livein_iterator I = MF->livein_begin(),
+ E = MF->livein_end(); I != E; ++I) {
+ unsigned Reg = I->first;
+ PhysRegsEverUsed[Reg] = true;
+ PhysRegsUsed[Reg] = 0; // It is free and reserved now
+ PhysRegsUseOrder.push_back(Reg);
+ for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg);
+ *AliasSet; ++AliasSet) {
+ PhysRegsUseOrder.push_back(*AliasSet);
+ PhysRegsUsed[*AliasSet] = 0; // It is free and reserved now
+ PhysRegsEverUsed[*AliasSet] = true;
+ }
+ }
+ }
+
+ // Otherwise, sequentially allocate each instruction in the MBB.
while (MII != MBB.end()) {
MachineInstr *MI = MII++;
const TargetInstrDescriptor &TID = TII.get(MI->getOpcode());