MFI->setStackSize(NumBytes);
- //sub sp, sp, #NumBytes
- splitInstructionWithImmediate(MBB, MBBI, TII.get(ARM::SUB), ARM::R13,
- ARM::R13, NumBytes);
+ if (NumBytes) {
+ //sub sp, sp, #NumBytes
+ splitInstructionWithImmediate(MBB, MBBI, TII.get(ARM::SUB), ARM::R13,
+ ARM::R13, NumBytes);
+ }
if (HasFP) {
BuildMI(MBB, MBBI, TII.get(ARM::LDR), ARM::R11).addReg(ARM::R13).addImm(0);
}
- //add sp, sp, #NumBytes
- splitInstructionWithImmediate(MBB, MBBI, TII.get(ARM::ADD), ARM::R13,
- ARM::R13, NumBytes);
+ if (NumBytes){
+ //add sp, sp, #NumBytes
+ splitInstructionWithImmediate(MBB, MBBI, TII.get(ARM::ADD), ARM::R13,
+ ARM::R13, NumBytes);
+ }
}
--- /dev/null
+; 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
+}
+
+