diff --git a/llvm/lib/Target/ARM/ARMFrameLowering.cpp b/llvm/lib/Target/ARM/ARMFrameLowering.cpp --- a/llvm/lib/Target/ARM/ARMFrameLowering.cpp +++ b/llvm/lib/Target/ARM/ARMFrameLowering.cpp @@ -142,27 +142,6 @@ return hasReservedCallFrame(MF) || MF.getFrameInfo().hasVarSizedObjects(); } -static bool isCSRestore(MachineInstr &MI, const ARMBaseInstrInfo &TII, - const MCPhysReg *CSRegs) { - // Integer spill area is handled with "pop". - if (isPopOpcode(MI.getOpcode())) { - // The first two operands are predicates. The last two are - // imp-def and imp-use of SP. Check everything in between. - for (int i = 5, e = MI.getNumOperands(); i != e; ++i) - if (!isCalleeSavedRegister(MI.getOperand(i).getReg(), CSRegs)) - return false; - return true; - } - if ((MI.getOpcode() == ARM::LDR_POST_IMM || - MI.getOpcode() == ARM::LDR_POST_REG || - MI.getOpcode() == ARM::t2LDR_POST) && - isCalleeSavedRegister(MI.getOperand(0).getReg(), CSRegs) && - MI.getOperand(1).getReg() == ARM::SP) - return true; - - return false; -} - static void emitRegPlusImmediate( bool isARM, MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, const ARMBaseInstrInfo &TII, unsigned DestReg, @@ -796,12 +775,12 @@ emitSPUpdate(isARM, MBB, MBBI, dl, TII, NumBytes - ArgRegsSaveSize); } else { // Unwind MBBI to point to first LDR / VLDRD. - const MCPhysReg *CSRegs = RegInfo->getCalleeSavedRegs(&MF); if (MBBI != MBB.begin()) { do { --MBBI; - } while (MBBI != MBB.begin() && isCSRestore(*MBBI, TII, CSRegs)); - if (!isCSRestore(*MBBI, TII, CSRegs)) + } while (MBBI != MBB.begin() && + MBBI->getFlag(MachineInstr::FrameDestroy)); + if (!MBBI->getFlag(MachineInstr::FrameDestroy)) ++MBBI; } @@ -1119,7 +1098,8 @@ if (Regs.size() > 1 || LdrOpc == 0) { MachineInstrBuilder MIB = BuildMI(MBB, MI, DL, TII.get(LdmOpc), ARM::SP) .addReg(ARM::SP) - .add(predOps(ARMCC::AL)); + .add(predOps(ARMCC::AL)) + .setMIFlags(MachineInstr::FrameDestroy); for (unsigned i = 0, e = Regs.size(); i < e; ++i) MIB.addReg(Regs[i], getDefRegState(true)); if (DeleteRet) { @@ -1137,7 +1117,8 @@ MachineInstrBuilder MIB = BuildMI(MBB, MI, DL, TII.get(LdrOpc), Regs[0]) .addReg(ARM::SP, RegState::Define) - .addReg(ARM::SP); + .addReg(ARM::SP) + .setMIFlags(MachineInstr::FrameDestroy); // ARM mode needs an extra reg0 here due to addrmode2. Will go away once // that refactoring is complete (eventually). if (LdrOpc == ARM::LDR_POST_REG || LdrOpc == ARM::LDR_POST_IMM) {