PrologEpilogInserter.cpp revision ae73dc1448d25b02cabc7c64c86c64371453dda8
1//===-- PrologEpilogInserter.cpp - Insert Prolog/Epilog code in function --===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This pass is responsible for finalizing the functions frame layout, saving 11// callee saved registers, and for emitting prolog & epilog code for the 12// function. 13// 14// This pass must be run after register allocation. After this pass is 15// executed, it is illegal to construct MO_FrameIndex operands. 16// 17//===----------------------------------------------------------------------===// 18 19#include "llvm/CodeGen/Passes.h" 20#include "llvm/CodeGen/MachineFunctionPass.h" 21#include "llvm/CodeGen/MachineInstr.h" 22#include "llvm/CodeGen/MachineFrameInfo.h" 23#include "llvm/CodeGen/MachineModuleInfo.h" 24#include "llvm/CodeGen/MachineRegisterInfo.h" 25#include "llvm/CodeGen/RegisterScavenging.h" 26#include "llvm/Target/TargetMachine.h" 27#include "llvm/Target/TargetRegisterInfo.h" 28#include "llvm/Target/TargetFrameInfo.h" 29#include "llvm/Target/TargetInstrInfo.h" 30#include "llvm/Support/Compiler.h" 31#include "llvm/ADT/STLExtras.h" 32#include <climits> 33using namespace llvm; 34 35namespace { 36 struct VISIBILITY_HIDDEN PEI : public MachineFunctionPass { 37 static char ID; 38 PEI() : MachineFunctionPass(&ID) {} 39 40 const char *getPassName() const { 41 return "Prolog/Epilog Insertion & Frame Finalization"; 42 } 43 44 /// runOnMachineFunction - Insert prolog/epilog code and replace abstract 45 /// frame indexes with appropriate references. 46 /// 47 bool runOnMachineFunction(MachineFunction &Fn) { 48 const TargetRegisterInfo *TRI = Fn.getTarget().getRegisterInfo(); 49 RS = TRI->requiresRegisterScavenging(Fn) ? new RegScavenger() : NULL; 50 51 // Get MachineModuleInfo so that we can track the construction of the 52 // frame. 53 if (MachineModuleInfo *MMI = getAnalysisToUpdate<MachineModuleInfo>()) 54 Fn.getFrameInfo()->setMachineModuleInfo(MMI); 55 56 // Allow the target machine to make some adjustments to the function 57 // e.g. UsedPhysRegs before calculateCalleeSavedRegisters. 58 TRI->processFunctionBeforeCalleeSavedScan(Fn, RS); 59 60 // Scan the function for modified callee saved registers and insert spill 61 // code for any callee saved registers that are modified. Also calculate 62 // the MaxCallFrameSize and HasCalls variables for the function's frame 63 // information and eliminates call frame pseudo instructions. 64 calculateCalleeSavedRegisters(Fn); 65 66 // Add the code to save and restore the callee saved registers 67 saveCalleeSavedRegisters(Fn); 68 69 // Allow the target machine to make final modifications to the function 70 // before the frame layout is finalized. 71 TRI->processFunctionBeforeFrameFinalized(Fn); 72 73 // Calculate actual frame offsets for all of the abstract stack objects... 74 calculateFrameObjectOffsets(Fn); 75 76 // Add prolog and epilog code to the function. This function is required 77 // to align the stack frame as necessary for any stack variables or 78 // called functions. Because of this, calculateCalleeSavedRegisters 79 // must be called before this function in order to set the HasCalls 80 // and MaxCallFrameSize variables. 81 insertPrologEpilogCode(Fn); 82 83 // Replace all MO_FrameIndex operands with physical register references 84 // and actual offsets. 85 // 86 replaceFrameIndices(Fn); 87 88 delete RS; 89 return true; 90 } 91 92 private: 93 RegScavenger *RS; 94 95 // MinCSFrameIndex, MaxCSFrameIndex - Keeps the range of callee saved 96 // stack frame indexes. 97 unsigned MinCSFrameIndex, MaxCSFrameIndex; 98 99 void calculateCalleeSavedRegisters(MachineFunction &Fn); 100 void saveCalleeSavedRegisters(MachineFunction &Fn); 101 void calculateFrameObjectOffsets(MachineFunction &Fn); 102 void replaceFrameIndices(MachineFunction &Fn); 103 void insertPrologEpilogCode(MachineFunction &Fn); 104 }; 105 char PEI::ID = 0; 106} 107 108 109/// createPrologEpilogCodeInserter - This function returns a pass that inserts 110/// prolog and epilog code, and eliminates abstract frame references. 111/// 112FunctionPass *llvm::createPrologEpilogCodeInserter() { return new PEI(); } 113 114 115/// calculateCalleeSavedRegisters - Scan the function for modified callee saved 116/// registers. Also calculate the MaxCallFrameSize and HasCalls variables for 117/// the function's frame information and eliminates call frame pseudo 118/// instructions. 119/// 120void PEI::calculateCalleeSavedRegisters(MachineFunction &Fn) { 121 const TargetRegisterInfo *RegInfo = Fn.getTarget().getRegisterInfo(); 122 const TargetFrameInfo *TFI = Fn.getTarget().getFrameInfo(); 123 124 // Get the callee saved register list... 125 const unsigned *CSRegs = RegInfo->getCalleeSavedRegs(&Fn); 126 127 // Get the function call frame set-up and tear-down instruction opcode 128 int FrameSetupOpcode = RegInfo->getCallFrameSetupOpcode(); 129 int FrameDestroyOpcode = RegInfo->getCallFrameDestroyOpcode(); 130 131 // These are used to keep track the callee-save area. Initialize them. 132 MinCSFrameIndex = INT_MAX; 133 MaxCSFrameIndex = 0; 134 135 // Early exit for targets which have no callee saved registers and no call 136 // frame setup/destroy pseudo instructions. 137 if ((CSRegs == 0 || CSRegs[0] == 0) && 138 FrameSetupOpcode == -1 && FrameDestroyOpcode == -1) 139 return; 140 141 unsigned MaxCallFrameSize = 0; 142 bool HasCalls = false; 143 144 std::vector<MachineBasicBlock::iterator> FrameSDOps; 145 for (MachineFunction::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) 146 for (MachineBasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) 147 if (I->getOpcode() == FrameSetupOpcode || 148 I->getOpcode() == FrameDestroyOpcode) { 149 assert(I->getNumOperands() >= 1 && "Call Frame Setup/Destroy Pseudo" 150 " instructions should have a single immediate argument!"); 151 unsigned Size = I->getOperand(0).getImm(); 152 if (Size > MaxCallFrameSize) MaxCallFrameSize = Size; 153 HasCalls = true; 154 FrameSDOps.push_back(I); 155 } 156 157 MachineFrameInfo *FFI = Fn.getFrameInfo(); 158 FFI->setHasCalls(HasCalls); 159 FFI->setMaxCallFrameSize(MaxCallFrameSize); 160 161 for (unsigned i = 0, e = FrameSDOps.size(); i != e; ++i) { 162 MachineBasicBlock::iterator I = FrameSDOps[i]; 163 // If call frames are not being included as part of the stack frame, 164 // and there is no dynamic allocation (therefore referencing frame slots 165 // off sp), leave the pseudo ops alone. We'll eliminate them later. 166 if (RegInfo->hasReservedCallFrame(Fn) || RegInfo->hasFP(Fn)) 167 RegInfo->eliminateCallFramePseudoInstr(Fn, *I->getParent(), I); 168 } 169 170 // Now figure out which *callee saved* registers are modified by the current 171 // function, thus needing to be saved and restored in the prolog/epilog. 172 // 173 const TargetRegisterClass* const *CSRegClasses = 174 RegInfo->getCalleeSavedRegClasses(&Fn); 175 std::vector<CalleeSavedInfo> CSI; 176 for (unsigned i = 0; CSRegs[i]; ++i) { 177 unsigned Reg = CSRegs[i]; 178 if (Fn.getRegInfo().isPhysRegUsed(Reg)) { 179 // If the reg is modified, save it! 180 CSI.push_back(CalleeSavedInfo(Reg, CSRegClasses[i])); 181 } else { 182 for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg); 183 *AliasSet; ++AliasSet) { // Check alias registers too. 184 if (Fn.getRegInfo().isPhysRegUsed(*AliasSet)) { 185 CSI.push_back(CalleeSavedInfo(Reg, CSRegClasses[i])); 186 break; 187 } 188 } 189 } 190 } 191 192 if (CSI.empty()) 193 return; // Early exit if no callee saved registers are modified! 194 195 unsigned NumFixedSpillSlots; 196 const std::pair<unsigned,int> *FixedSpillSlots = 197 TFI->getCalleeSavedSpillSlots(NumFixedSpillSlots); 198 199 // Now that we know which registers need to be saved and restored, allocate 200 // stack slots for them. 201 for (unsigned i = 0, e = CSI.size(); i != e; ++i) { 202 unsigned Reg = CSI[i].getReg(); 203 const TargetRegisterClass *RC = CSI[i].getRegClass(); 204 205 // Check to see if this physreg must be spilled to a particular stack slot 206 // on this target. 207 const std::pair<unsigned,int> *FixedSlot = FixedSpillSlots; 208 while (FixedSlot != FixedSpillSlots+NumFixedSpillSlots && 209 FixedSlot->first != Reg) 210 ++FixedSlot; 211 212 int FrameIdx; 213 if (FixedSlot == FixedSpillSlots+NumFixedSpillSlots) { 214 // Nope, just spill it anywhere convenient. 215 unsigned Align = RC->getAlignment(); 216 unsigned StackAlign = TFI->getStackAlignment(); 217 // We may not be able to sastify the desired alignment specification of 218 // the TargetRegisterClass if the stack alignment is smaller. Use the min. 219 Align = std::min(Align, StackAlign); 220 FrameIdx = FFI->CreateStackObject(RC->getSize(), Align); 221 if ((unsigned)FrameIdx < MinCSFrameIndex) MinCSFrameIndex = FrameIdx; 222 if ((unsigned)FrameIdx > MaxCSFrameIndex) MaxCSFrameIndex = FrameIdx; 223 } else { 224 // Spill it to the stack where we must. 225 FrameIdx = FFI->CreateFixedObject(RC->getSize(), FixedSlot->second); 226 } 227 CSI[i].setFrameIdx(FrameIdx); 228 } 229 230 FFI->setCalleeSavedInfo(CSI); 231} 232 233/// saveCalleeSavedRegisters - Insert spill code for any callee saved registers 234/// that are modified in the function. 235/// 236void PEI::saveCalleeSavedRegisters(MachineFunction &Fn) { 237 // Get callee saved register information. 238 MachineFrameInfo *FFI = Fn.getFrameInfo(); 239 const std::vector<CalleeSavedInfo> &CSI = FFI->getCalleeSavedInfo(); 240 241 // Early exit if no callee saved registers are modified! 242 if (CSI.empty()) 243 return; 244 245 const TargetInstrInfo &TII = *Fn.getTarget().getInstrInfo(); 246 247 // Now that we have a stack slot for each register to be saved, insert spill 248 // code into the entry block. 249 MachineBasicBlock *MBB = Fn.begin(); 250 MachineBasicBlock::iterator I = MBB->begin(); 251 252 if (!TII.spillCalleeSavedRegisters(*MBB, I, CSI)) { 253 for (unsigned i = 0, e = CSI.size(); i != e; ++i) { 254 // Add the callee-saved register as live-in. It's killed at the spill. 255 MBB->addLiveIn(CSI[i].getReg()); 256 257 // Insert the spill to the stack frame. 258 TII.storeRegToStackSlot(*MBB, I, CSI[i].getReg(), true, 259 CSI[i].getFrameIdx(), CSI[i].getRegClass()); 260 } 261 } 262 263 // Add code to restore the callee-save registers in each exiting block. 264 for (MachineFunction::iterator FI = Fn.begin(), E = Fn.end(); FI != E; ++FI) 265 // If last instruction is a return instruction, add an epilogue. 266 if (!FI->empty() && FI->back().getDesc().isReturn()) { 267 MBB = FI; 268 I = MBB->end(); --I; 269 270 // Skip over all terminator instructions, which are part of the return 271 // sequence. 272 MachineBasicBlock::iterator I2 = I; 273 while (I2 != MBB->begin() && (--I2)->getDesc().isTerminator()) 274 I = I2; 275 276 bool AtStart = I == MBB->begin(); 277 MachineBasicBlock::iterator BeforeI = I; 278 if (!AtStart) 279 --BeforeI; 280 281 // Restore all registers immediately before the return and any terminators 282 // that preceed it. 283 if (!TII.restoreCalleeSavedRegisters(*MBB, I, CSI)) { 284 for (unsigned i = 0, e = CSI.size(); i != e; ++i) { 285 TII.loadRegFromStackSlot(*MBB, I, CSI[i].getReg(), 286 CSI[i].getFrameIdx(), 287 CSI[i].getRegClass()); 288 assert(I != MBB->begin() && 289 "loadRegFromStackSlot didn't insert any code!"); 290 // Insert in reverse order. loadRegFromStackSlot can insert multiple 291 // instructions. 292 if (AtStart) 293 I = MBB->begin(); 294 else { 295 I = BeforeI; 296 ++I; 297 } 298 } 299 } 300 } 301} 302 303 304/// calculateFrameObjectOffsets - Calculate actual frame offsets for all of the 305/// abstract stack objects. 306/// 307void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) { 308 const TargetFrameInfo &TFI = *Fn.getTarget().getFrameInfo(); 309 310 bool StackGrowsDown = 311 TFI.getStackGrowthDirection() == TargetFrameInfo::StackGrowsDown; 312 313 // Loop over all of the stack objects, assigning sequential addresses... 314 MachineFrameInfo *FFI = Fn.getFrameInfo(); 315 316 unsigned MaxAlign = FFI->getMaxAlignment(); 317 318 // Start at the beginning of the local area. 319 // The Offset is the distance from the stack top in the direction 320 // of stack growth -- so it's always nonnegative. 321 int64_t Offset = TFI.getOffsetOfLocalArea(); 322 if (StackGrowsDown) 323 Offset = -Offset; 324 assert(Offset >= 0 325 && "Local area offset should be in direction of stack growth"); 326 327 // If there are fixed sized objects that are preallocated in the local area, 328 // non-fixed objects can't be allocated right at the start of local area. 329 // We currently don't support filling in holes in between fixed sized objects, 330 // so we adjust 'Offset' to point to the end of last fixed sized 331 // preallocated object. 332 for (int i = FFI->getObjectIndexBegin(); i != 0; ++i) { 333 int64_t FixedOff; 334 if (StackGrowsDown) { 335 // The maximum distance from the stack pointer is at lower address of 336 // the object -- which is given by offset. For down growing stack 337 // the offset is negative, so we negate the offset to get the distance. 338 FixedOff = -FFI->getObjectOffset(i); 339 } else { 340 // The maximum distance from the start pointer is at the upper 341 // address of the object. 342 FixedOff = FFI->getObjectOffset(i) + FFI->getObjectSize(i); 343 } 344 if (FixedOff > Offset) Offset = FixedOff; 345 } 346 347 // First assign frame offsets to stack objects that are used to spill 348 // callee saved registers. 349 if (StackGrowsDown) { 350 for (unsigned i = MinCSFrameIndex; i <= MaxCSFrameIndex; ++i) { 351 // If stack grows down, we need to add size of find the lowest 352 // address of the object. 353 Offset += FFI->getObjectSize(i); 354 355 unsigned Align = FFI->getObjectAlignment(i); 356 // If the alignment of this object is greater than that of the stack, then 357 // increase the stack alignment to match. 358 MaxAlign = std::max(MaxAlign, Align); 359 // Adjust to alignment boundary 360 Offset = (Offset+Align-1)/Align*Align; 361 362 FFI->setObjectOffset(i, -Offset); // Set the computed offset 363 } 364 } else { 365 int MaxCSFI = MaxCSFrameIndex, MinCSFI = MinCSFrameIndex; 366 for (int i = MaxCSFI; i >= MinCSFI ; --i) { 367 unsigned Align = FFI->getObjectAlignment(i); 368 // If the alignment of this object is greater than that of the stack, then 369 // increase the stack alignment to match. 370 MaxAlign = std::max(MaxAlign, Align); 371 // Adjust to alignment boundary 372 Offset = (Offset+Align-1)/Align*Align; 373 374 FFI->setObjectOffset(i, Offset); 375 Offset += FFI->getObjectSize(i); 376 } 377 } 378 379 // Make sure the special register scavenging spill slot is closest to the 380 // frame pointer if a frame pointer is required. 381 const TargetRegisterInfo *RegInfo = Fn.getTarget().getRegisterInfo(); 382 if (RS && RegInfo->hasFP(Fn)) { 383 int SFI = RS->getScavengingFrameIndex(); 384 if (SFI >= 0) { 385 // If stack grows down, we need to add size of the lowest 386 // address of the object. 387 if (StackGrowsDown) 388 Offset += FFI->getObjectSize(SFI); 389 390 unsigned Align = FFI->getObjectAlignment(SFI); 391 // Adjust to alignment boundary 392 Offset = (Offset+Align-1)/Align*Align; 393 394 if (StackGrowsDown) { 395 FFI->setObjectOffset(SFI, -Offset); // Set the computed offset 396 } else { 397 FFI->setObjectOffset(SFI, Offset); 398 Offset += FFI->getObjectSize(SFI); 399 } 400 } 401 } 402 403 // Then assign frame offsets to stack objects that are not used to spill 404 // callee saved registers. 405 for (unsigned i = 0, e = FFI->getObjectIndexEnd(); i != e; ++i) { 406 if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex) 407 continue; 408 if (RS && (int)i == RS->getScavengingFrameIndex()) 409 continue; 410 if (FFI->isDeadObjectIndex(i)) 411 continue; 412 413 // If stack grows down, we need to add size of find the lowest 414 // address of the object. 415 if (StackGrowsDown) 416 Offset += FFI->getObjectSize(i); 417 418 unsigned Align = FFI->getObjectAlignment(i); 419 // If the alignment of this object is greater than that of the stack, then 420 // increase the stack alignment to match. 421 MaxAlign = std::max(MaxAlign, Align); 422 // Adjust to alignment boundary 423 Offset = (Offset+Align-1)/Align*Align; 424 425 if (StackGrowsDown) { 426 FFI->setObjectOffset(i, -Offset); // Set the computed offset 427 } else { 428 FFI->setObjectOffset(i, Offset); 429 Offset += FFI->getObjectSize(i); 430 } 431 } 432 433 // Make sure the special register scavenging spill slot is closest to the 434 // stack pointer. 435 if (RS && !RegInfo->hasFP(Fn)) { 436 int SFI = RS->getScavengingFrameIndex(); 437 if (SFI >= 0) { 438 // If stack grows down, we need to add size of find the lowest 439 // address of the object. 440 if (StackGrowsDown) 441 Offset += FFI->getObjectSize(SFI); 442 443 unsigned Align = FFI->getObjectAlignment(SFI); 444 // If the alignment of this object is greater than that of the 445 // stack, then increase the stack alignment to match. 446 MaxAlign = std::max(MaxAlign, Align); 447 // Adjust to alignment boundary 448 Offset = (Offset+Align-1)/Align*Align; 449 450 if (StackGrowsDown) { 451 FFI->setObjectOffset(SFI, -Offset); // Set the computed offset 452 } else { 453 FFI->setObjectOffset(SFI, Offset); 454 Offset += FFI->getObjectSize(SFI); 455 } 456 } 457 } 458 459 // Round up the size to a multiple of the alignment, but only if there are 460 // calls or alloca's in the function. This ensures that any calls to 461 // subroutines have their stack frames suitable aligned. 462 // Also do this if we need runtime alignment of the stack. In this case 463 // offsets will be relative to SP not FP; round up the stack size so this 464 // works. 465 if (!RegInfo->targetHandlesStackFrameRounding() && 466 (FFI->hasCalls() || FFI->hasVarSizedObjects() || 467 (RegInfo->needsStackRealignment(Fn) && 468 FFI->getObjectIndexEnd() != 0))) { 469 // If we have reserved argument space for call sites in the function 470 // immediately on entry to the current function, count it as part of the 471 // overall stack size. 472 if (RegInfo->hasReservedCallFrame(Fn)) 473 Offset += FFI->getMaxCallFrameSize(); 474 475 unsigned AlignMask = std::max(TFI.getStackAlignment(),MaxAlign) - 1; 476 Offset = (Offset + AlignMask) & ~uint64_t(AlignMask); 477 } 478 479 // Update frame info to pretend that this is part of the stack... 480 FFI->setStackSize(Offset+TFI.getOffsetOfLocalArea()); 481 482 // Remember the required stack alignment in case targets need it to perform 483 // dynamic stack alignment. 484 FFI->setMaxAlignment(MaxAlign); 485} 486 487 488/// insertPrologEpilogCode - Scan the function for modified callee saved 489/// registers, insert spill code for these callee saved registers, then add 490/// prolog and epilog code to the function. 491/// 492void PEI::insertPrologEpilogCode(MachineFunction &Fn) { 493 const TargetRegisterInfo *TRI = Fn.getTarget().getRegisterInfo(); 494 495 // Add prologue to the function... 496 TRI->emitPrologue(Fn); 497 498 // Add epilogue to restore the callee-save registers in each exiting block 499 for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) { 500 // If last instruction is a return instruction, add an epilogue 501 if (!I->empty() && I->back().getDesc().isReturn()) 502 TRI->emitEpilogue(Fn, *I); 503 } 504} 505 506 507/// replaceFrameIndices - Replace all MO_FrameIndex operands with physical 508/// register references and actual offsets. 509/// 510void PEI::replaceFrameIndices(MachineFunction &Fn) { 511 if (!Fn.getFrameInfo()->hasStackObjects()) return; // Nothing to do? 512 513 const TargetMachine &TM = Fn.getTarget(); 514 assert(TM.getRegisterInfo() && "TM::getRegisterInfo() must be implemented!"); 515 const TargetRegisterInfo &TRI = *TM.getRegisterInfo(); 516 const TargetFrameInfo *TFI = TM.getFrameInfo(); 517 bool StackGrowsDown = 518 TFI->getStackGrowthDirection() == TargetFrameInfo::StackGrowsDown; 519 int FrameSetupOpcode = TRI.getCallFrameSetupOpcode(); 520 int FrameDestroyOpcode = TRI.getCallFrameDestroyOpcode(); 521 522 for (MachineFunction::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) { 523 int SPAdj = 0; // SP offset due to call frame setup / destroy. 524 if (RS) RS->enterBasicBlock(BB); 525 for (MachineBasicBlock::iterator I = BB->begin(); I != BB->end(); ) { 526 MachineInstr *MI = I; 527 528 if (I->getOpcode() == TargetInstrInfo::DECLARE) { 529 // Ignore it. 530 ++I; 531 continue; 532 } 533 534 if (I->getOpcode() == FrameSetupOpcode || 535 I->getOpcode() == FrameDestroyOpcode) { 536 // Remember how much SP has been adjusted to create the call 537 // frame. 538 int Size = I->getOperand(0).getImm(); 539 540 if ((!StackGrowsDown && I->getOpcode() == FrameSetupOpcode) || 541 (StackGrowsDown && I->getOpcode() == FrameDestroyOpcode)) 542 Size = -Size; 543 544 SPAdj += Size; 545 546 MachineBasicBlock::iterator PrevI = prior(I); 547 TRI.eliminateCallFramePseudoInstr(Fn, *BB, I); 548 549 // Visit the instructions created by eliminateCallFramePseudoInstr(). 550 I = next(PrevI); 551 continue; 552 } 553 554 bool DoIncr = true; 555 556 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) 557 if (MI->getOperand(i).isFrameIndex()) { 558 // Some instructions (e.g. inline asm instructions) can have 559 // multiple frame indices and/or cause eliminateFrameIndex 560 // to insert more than one instruction. We need the register 561 // scavenger to go through all of these instructions so that 562 // it can update its register information. We keep the 563 // iterator at the point before insertion so that we can 564 // revisit them in full. 565 bool AtBeginning = (I == BB->begin()); 566 if (!AtBeginning) --I; 567 568 // If this instruction has a FrameIndex operand, we need to 569 // use that target machine register info object to eliminate 570 // it. 571 TRI.eliminateFrameIndex(MI, SPAdj, RS); 572 573 // Reset the iterator if we were at the beginning of the BB. 574 if (AtBeginning) { 575 I = BB->begin(); 576 DoIncr = false; 577 } 578 579 MI = 0; 580 break; 581 } 582 583 if (DoIncr) ++I; 584 585 // Update register states. 586 if (RS && MI) RS->forward(MI); 587 } 588 589 assert(SPAdj == 0 && "Unbalanced call frame setup / destroy pairs?"); 590 } 591} 592