Don't add or sub zero to sp.

llvm-svn: 33142
This commit is contained in:
Lauro Ramos Venancio 2007-01-12 20:52:27 +00:00
parent c4235e5521
commit 901d9e65f6
2 changed files with 20 additions and 6 deletions

View File

@ -206,9 +206,11 @@ void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
MFI->setStackSize(NumBytes); MFI->setStackSize(NumBytes);
if (NumBytes) {
//sub sp, sp, #NumBytes //sub sp, sp, #NumBytes
splitInstructionWithImmediate(MBB, MBBI, TII.get(ARM::SUB), ARM::R13, splitInstructionWithImmediate(MBB, MBBI, TII.get(ARM::SUB), ARM::R13,
ARM::R13, NumBytes); ARM::R13, NumBytes);
}
if (HasFP) { if (HasFP) {
@ -234,9 +236,11 @@ void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
BuildMI(MBB, MBBI, TII.get(ARM::LDR), ARM::R11).addReg(ARM::R13).addImm(0); BuildMI(MBB, MBBI, TII.get(ARM::LDR), ARM::R11).addReg(ARM::R13).addImm(0);
} }
if (NumBytes){
//add sp, sp, #NumBytes //add sp, sp, #NumBytes
splitInstructionWithImmediate(MBB, MBBI, TII.get(ARM::ADD), ARM::R13, splitInstructionWithImmediate(MBB, MBBI, TII.get(ARM::ADD), ARM::R13,
ARM::R13, NumBytes); ARM::R13, NumBytes);
}
} }

View File

@ -0,0 +1,10 @@
; RUN: llvm-upgrade < %s | llvm-as | llc -f -march=arm -o %t.s &&
; RUN: not grep "add r13, r13, #0" < %t.s &&
; RUN: not grep "sub r13, r13, #0" < %t.s
int %f() {
entry:
ret int 1
}