diff options
Diffstat (limited to 'lib/Target/MSP430/MSP430FrameLowering.cpp')
-rw-r--r-- | lib/Target/MSP430/MSP430FrameLowering.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/lib/Target/MSP430/MSP430FrameLowering.cpp b/lib/Target/MSP430/MSP430FrameLowering.cpp index eb720809e47c..29555f99e23d 100644 --- a/lib/Target/MSP430/MSP430FrameLowering.cpp +++ b/lib/Target/MSP430/MSP430FrameLowering.cpp @@ -22,7 +22,6 @@ #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Function.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Target/TargetOptions.h" using namespace llvm; @@ -224,9 +223,9 @@ MSP430FrameLowering::restoreCalleeSavedRegisters(MachineBasicBlock &MBB, return true; } -void MSP430FrameLowering:: -eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, - MachineBasicBlock::iterator I) const { +MachineBasicBlock::iterator MSP430FrameLowering::eliminateCallFramePseudoInstr( + MachineFunction &MF, MachineBasicBlock &MBB, + MachineBasicBlock::iterator I) const { const MSP430InstrInfo &TII = *static_cast<const MSP430InstrInfo *>(MF.getSubtarget().getInstrInfo()); unsigned StackAlign = getStackAlignment(); @@ -236,8 +235,8 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, // adjcallstackup instruction into a 'sub SP, <amt>' and the // adjcallstackdown instruction into 'add SP, <amt>' // TODO: consider using push / pop instead of sub + store / add - MachineInstr *Old = I; - uint64_t Amount = Old->getOperand(0).getImm(); + MachineInstr &Old = *I; + uint64_t Amount = Old.getOperand(0).getImm(); if (Amount != 0) { // We need to keep the stack aligned properly. To do this, we round the // amount of space needed for the outgoing arguments up to the next @@ -245,19 +244,21 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, Amount = (Amount+StackAlign-1)/StackAlign*StackAlign; MachineInstr *New = nullptr; - if (Old->getOpcode() == TII.getCallFrameSetupOpcode()) { - New = BuildMI(MF, Old->getDebugLoc(), - TII.get(MSP430::SUB16ri), MSP430::SP) - .addReg(MSP430::SP).addImm(Amount); + if (Old.getOpcode() == TII.getCallFrameSetupOpcode()) { + New = + BuildMI(MF, Old.getDebugLoc(), TII.get(MSP430::SUB16ri), MSP430::SP) + .addReg(MSP430::SP) + .addImm(Amount); } else { - assert(Old->getOpcode() == TII.getCallFrameDestroyOpcode()); + assert(Old.getOpcode() == TII.getCallFrameDestroyOpcode()); // factor out the amount the callee already popped. - uint64_t CalleeAmt = Old->getOperand(1).getImm(); + uint64_t CalleeAmt = Old.getOperand(1).getImm(); Amount -= CalleeAmt; if (Amount) - New = BuildMI(MF, Old->getDebugLoc(), - TII.get(MSP430::ADD16ri), MSP430::SP) - .addReg(MSP430::SP).addImm(Amount); + New = BuildMI(MF, Old.getDebugLoc(), TII.get(MSP430::ADD16ri), + MSP430::SP) + .addReg(MSP430::SP) + .addImm(Amount); } if (New) { @@ -272,10 +273,11 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, // If we are performing frame pointer elimination and if the callee pops // something off the stack pointer, add it back. if (uint64_t CalleeAmt = I->getOperand(1).getImm()) { - MachineInstr *Old = I; + MachineInstr &Old = *I; MachineInstr *New = - BuildMI(MF, Old->getDebugLoc(), TII.get(MSP430::SUB16ri), - MSP430::SP).addReg(MSP430::SP).addImm(CalleeAmt); + BuildMI(MF, Old.getDebugLoc(), TII.get(MSP430::SUB16ri), MSP430::SP) + .addReg(MSP430::SP) + .addImm(CalleeAmt); // The SRW implicit def is dead. New->getOperand(3).setIsDead(); @@ -283,7 +285,7 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, } } - MBB.erase(I); + return MBB.erase(I); } void |