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. llvm-svn: 28809
This commit is contained in:
		
							parent
							
								
									cb29586ce4
								
							
						
					
					
						commit
						4ff6c1646f
					
				| 
						 | 
					@ -491,6 +491,26 @@ void RA::AllocateBasicBlock(MachineBasicBlock &MBB) {
 | 
				
			||||||
  // loop over each instruction
 | 
					  // loop over each instruction
 | 
				
			||||||
  MachineBasicBlock::iterator MII = MBB.begin();
 | 
					  MachineBasicBlock::iterator MII = MBB.begin();
 | 
				
			||||||
  const TargetInstrInfo &TII = *TM->getInstrInfo();
 | 
					  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()) {
 | 
					  while (MII != MBB.end()) {
 | 
				
			||||||
    MachineInstr *MI = MII++;
 | 
					    MachineInstr *MI = MII++;
 | 
				
			||||||
    const TargetInstrDescriptor &TID = TII.get(MI->getOpcode());
 | 
					    const TargetInstrDescriptor &TID = TII.get(MI->getOpcode());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue