Reapply ARM: Do not spill CSR to stack on entry to noreturn functions
authorTim Northover <tnorthover@apple.com>
Sat, 7 Apr 2018 10:57:03 +0000 (10:57 +0000)
committerTim Northover <tnorthover@apple.com>
Sat, 7 Apr 2018 10:57:03 +0000 (10:57 +0000)
commite25e458d5233ef829f90110e1197aa3e1588faf4
tree2b917151fc8ad32f7574c9463a83843a411430a9
parent61061d69eacfb546283f33cba053c29bb1c1ef7e
Reapply ARM: Do not spill CSR to stack on entry to noreturn functions

Should fix UBSan bot by also checking there's no "uwtable" attribute
before skipping. Otherwise the unwind table will be useless since its
moves expect CSRs to actually be preserved.

A noreturn nounwind function can be expected to never return in any way, and by
never returning it will also never have to restore any callee-saved registers
for its caller. This makes it possible to skip spills of those registers during
function entry, saving some stack space and time in the process. This is rather
useful for embedded targets with limited stack space.

Should fix PR9970.

Patch mostly by myeisha (pmb).

llvm-svn: 329494
llvm/include/llvm/CodeGen/TargetFrameLowering.h
llvm/lib/CodeGen/TargetFrameLoweringImpl.cpp
llvm/lib/Target/ARM/ARMFrameLowering.cpp
llvm/lib/Target/ARM/ARMFrameLowering.h
llvm/test/CodeGen/AArch64/arm64-shrink-wrapping.ll
llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
llvm/test/CodeGen/ARM/noreturn-csr-skip.mir [new file with mode: 0644]
llvm/test/CodeGen/PowerPC/ppc-shrink-wrapping.ll
llvm/test/CodeGen/Thumb/thumb-shrink-wrapping.ll
llvm/test/CodeGen/X86/2010-02-19-TailCallRetAddrBug.ll
llvm/test/CodeGen/X86/x86-shrink-wrapping.ll