Fix epilogue codegen to avoid leaving the stack pointer in an invalid
authorEvan Cheng <evan.cheng@apple.com>
Mon, 22 Nov 2010 18:12:04 +0000 (18:12 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Mon, 22 Nov 2010 18:12:04 +0000 (18:12 +0000)
commitab5c703fdb0b07c6d89271519fd1cca7105b3eae
tree52b8ff64598ea781f1e347405867c74989a11920
parent4d5a29979000e1d5afc6c31239fe12d888027f4c
Fix epilogue codegen to avoid leaving the stack pointer in an invalid
state. Previously Thumb2 would restore sp from fp like this:
mov sp, r7
sub, sp, #4
If an interrupt is taken after the 'mov' but before the 'sub', callee-saved
registers might be clobbered by the interrupt handler. Instead, try
restoring directly from sp:
add sp, #4
Or, if necessary (with VLA, etc.) use a scratch register to compute sp and
then restore it:
sub.w r4, r7, #8
mov sp, r7
rdar://8465407

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119977 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMBaseRegisterInfo.cpp
lib/Target/ARM/ARMFrameInfo.cpp
lib/Target/ARM/Thumb1FrameInfo.cpp
test/CodeGen/ARM/hello.ll
test/CodeGen/Thumb/dyn-stackalloc.ll
test/CodeGen/Thumb/large-stack.ll
test/CodeGen/Thumb2/2009-08-06-SpDecBug.ll
test/CodeGen/Thumb2/2010-08-10-VarSizedAllocaBug.ll
test/CodeGen/Thumb2/2010-11-22-EpilogueBug.ll [new file with mode: 0644]