Prologue and epilogue bugs for non-Darwin targets.
llvm-svn: 33390
This commit is contained in:
		
							parent
							
								
									aa24f08926
								
							
						
					
					
						commit
						a9af4be5ac
					
				| 
						 | 
					@ -484,6 +484,7 @@ void ARMRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II) const{
 | 
				
			||||||
    // There is alloca()'s in this function, must reference off the frame
 | 
					    // There is alloca()'s in this function, must reference off the frame
 | 
				
			||||||
    // pointer instead.
 | 
					    // pointer instead.
 | 
				
			||||||
    FrameReg = getFrameRegister(MF);
 | 
					    FrameReg = getFrameRegister(MF);
 | 
				
			||||||
 | 
					    if (STI.isTargetDarwin())
 | 
				
			||||||
      Offset -= AFI->getFramePtrSpillOffset();
 | 
					      Offset -= AFI->getFramePtrSpillOffset();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -724,6 +725,14 @@ processFunctionBeforeCalleeSavedScan(MachineFunction &MF) const {
 | 
				
			||||||
      if (Spilled) {
 | 
					      if (Spilled) {
 | 
				
			||||||
        NumGPRSpills++;
 | 
					        NumGPRSpills++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!STI.isTargetDarwin()) {
 | 
				
			||||||
 | 
					          if (Reg == ARM::LR)
 | 
				
			||||||
 | 
					            LRSpilled = true;
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            CS1Spilled = true;
 | 
				
			||||||
 | 
					          continue;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Keep track if LR and any of R4, R5, R6, and R7 is spilled.
 | 
					        // Keep track if LR and any of R4, R5, R6, and R7 is spilled.
 | 
				
			||||||
        switch (Reg) {
 | 
					        switch (Reg) {
 | 
				
			||||||
        case ARM::LR:
 | 
					        case ARM::LR:
 | 
				
			||||||
| 
						 | 
					@ -739,6 +748,11 @@ processFunctionBeforeCalleeSavedScan(MachineFunction &MF) const {
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      } else { 
 | 
					      } else { 
 | 
				
			||||||
 | 
					        if (!STI.isTargetDarwin()) {
 | 
				
			||||||
 | 
					          UnspilledCS1GPRs.push_back(Reg);
 | 
				
			||||||
 | 
					          continue;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        switch (Reg) {
 | 
					        switch (Reg) {
 | 
				
			||||||
        case ARM::R4:
 | 
					        case ARM::R4:
 | 
				
			||||||
        case ARM::R5:
 | 
					        case ARM::R5:
 | 
				
			||||||
| 
						 | 
					@ -768,17 +782,21 @@ processFunctionBeforeCalleeSavedScan(MachineFunction &MF) const {
 | 
				
			||||||
                                    UnspilledCS1GPRs.end(), (unsigned)ARM::LR));
 | 
					                                    UnspilledCS1GPRs.end(), (unsigned)ARM::LR));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // If stack and double are 8-byte aligned and we are spilling a odd number
 | 
					    if (STI.isTargetDarwin()) {
 | 
				
			||||||
 | 
					      MF.changePhyRegUsed(FramePtr, true);
 | 
				
			||||||
 | 
					      NumGPRSpills++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // If stack and double are 8-byte aligned and we are spilling an odd number
 | 
				
			||||||
    // of GPRs. Spill one extra callee save GPR so we won't have to pad between
 | 
					    // of GPRs. Spill one extra callee save GPR so we won't have to pad between
 | 
				
			||||||
    // the integer and double callee save areas.
 | 
					    // the integer and double callee save areas.
 | 
				
			||||||
    unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment();
 | 
					    unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment();
 | 
				
			||||||
    if (TargetAlign == 8 && (NumGPRSpills & 1)) {
 | 
					    if (TargetAlign == 8 && (NumGPRSpills & 1)) {
 | 
				
			||||||
      if (CS1Spilled && !UnspilledCS1GPRs.empty())
 | 
					      if (CS1Spilled && !UnspilledCS1GPRs.empty())
 | 
				
			||||||
        MF.changePhyRegUsed(UnspilledCS1GPRs.front(), true);
 | 
					        MF.changePhyRegUsed(UnspilledCS1GPRs.front(), true);
 | 
				
			||||||
      else
 | 
					      else if (!UnspilledCS2GPRs.empty())
 | 
				
			||||||
        MF.changePhyRegUsed(UnspilledCS2GPRs.front(), true);
 | 
					        MF.changePhyRegUsed(UnspilledCS2GPRs.front(), true);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    MF.changePhyRegUsed(FramePtr, true);
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -871,16 +889,19 @@ void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (Align == 8 && (GPRCS1Size & 7) != 0)
 | 
				
			||||||
 | 
					      // Pad CS1 to ensure proper alignment.
 | 
				
			||||||
 | 
					      GPRCS1Size += 4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!isThumb) {
 | 
					    if (!isThumb) {
 | 
				
			||||||
      // Build the new SUBri to adjust SP for integer callee-save spill area 1.
 | 
					      // Build the new SUBri to adjust SP for integer callee-save spill area 1.
 | 
				
			||||||
      emitSPUpdate(MBB, MBBI, -GPRCS1Size, isThumb, TII);
 | 
					      emitSPUpdate(MBB, MBBI, -GPRCS1Size, isThumb, TII);
 | 
				
			||||||
      movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 1, STI);
 | 
					      movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 1, STI);
 | 
				
			||||||
    } else {
 | 
					    } else if (MBBI != MBB.end() && MBBI->getOpcode() == ARM::tPUSH)
 | 
				
			||||||
      if (MBBI != MBB.end() && MBBI->getOpcode() == ARM::tPUSH)
 | 
					 | 
				
			||||||
      ++MBBI;
 | 
					      ++MBBI;
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Point FP to the stack slot that contains the previous FP.
 | 
					    // Point FP to the stack slot that contains the previous FP.
 | 
				
			||||||
 | 
					    if (STI.isTargetDarwin())
 | 
				
			||||||
      BuildMI(MBB, MBBI, TII.get(isThumb ? ARM::tADDrSPi : ARM::ADDri), FramePtr)
 | 
					      BuildMI(MBB, MBBI, TII.get(isThumb ? ARM::tADDrSPi : ARM::ADDri), FramePtr)
 | 
				
			||||||
        .addFrameIndex(FramePtrSpillFI).addImm(0);
 | 
					        .addFrameIndex(FramePtrSpillFI).addImm(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -977,6 +998,7 @@ void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
 | 
				
			||||||
    if (isThumb)
 | 
					    if (isThumb)
 | 
				
			||||||
      emitSPUpdate(MBB, MBBI, -NumBytes, isThumb, TII);
 | 
					      emitSPUpdate(MBB, MBBI, -NumBytes, isThumb, TII);
 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
 | 
					      if (STI.isTargetDarwin()) {
 | 
				
			||||||
        NumBytes = AFI->getFramePtrSpillOffset() - NumBytes;
 | 
					        NumBytes = AFI->getFramePtrSpillOffset() - NumBytes;
 | 
				
			||||||
        // Reset SP based on frame pointer only if the stack frame extends beyond
 | 
					        // Reset SP based on frame pointer only if the stack frame extends beyond
 | 
				
			||||||
        // frame pointer stack slot.
 | 
					        // frame pointer stack slot.
 | 
				
			||||||
| 
						 | 
					@ -987,8 +1009,10 @@ void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
 | 
				
			||||||
            BuildMI(MBB, MBBI, TII.get(ARM::SUBri), ARM::SP).addReg(FramePtr)
 | 
					            BuildMI(MBB, MBBI, TII.get(ARM::SUBri), ARM::SP).addReg(FramePtr)
 | 
				
			||||||
              .addImm(NumBytes);
 | 
					              .addImm(NumBytes);
 | 
				
			||||||
          else
 | 
					          else
 | 
				
			||||||
          BuildMI(MBB, MBBI, TII.get(isThumb ? ARM::tMOVrr : ARM::MOVrr),
 | 
					            BuildMI(MBB, MBBI, TII.get(ARM::MOVrr), ARM::SP).addReg(FramePtr);
 | 
				
			||||||
                  ARM::SP).addReg(FramePtr);
 | 
					      } else if (NumBytes) {
 | 
				
			||||||
 | 
					        emitSPUpdate(MBB, MBBI, NumBytes, false, TII);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // Move SP to start of integer callee save spill area 2.
 | 
					      // Move SP to start of integer callee save spill area 2.
 | 
				
			||||||
      movePastCSLoadStoreOps(MBB, MBBI, ARM::FLDD, 3, STI);
 | 
					      movePastCSLoadStoreOps(MBB, MBBI, ARM::FLDD, 3, STI);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue