diff options
| author | Tim Northover <tnorthover@apple.com> | 2018-04-07 10:57:03 +0000 |
|---|---|---|
| committer | Tim Northover <tnorthover@apple.com> | 2018-04-07 10:57:03 +0000 |
| commit | e25e458d5233ef829f90110e1197aa3e1588faf4 (patch) | |
| tree | 2b917151fc8ad32f7574c9463a83843a411430a9 /llvm/test/CodeGen/ARM | |
| parent | 61061d69eacfb546283f33cba053c29bb1c1ef7e (diff) | |
| download | bcm5719-llvm-e25e458d5233ef829f90110e1197aa3e1588faf4.tar.gz bcm5719-llvm-e25e458d5233ef829f90110e1197aa3e1588faf4.zip | |
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
Diffstat (limited to 'llvm/test/CodeGen/ARM')
| -rw-r--r-- | llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll | 2 | ||||
| -rw-r--r-- | llvm/test/CodeGen/ARM/noreturn-csr-skip.mir | 65 |
2 files changed, 66 insertions, 1 deletions
diff --git a/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll b/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll index 1985ff9b4a2..c943f60c56d 100644 --- a/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll +++ b/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll @@ -327,7 +327,7 @@ declare void @somethingElse(...) ; DISABLE-NEXT: pop {r4, r7, pc} ; ; ENABLE-NEXT: bx lr -define i32 @loopInfoRestoreOutsideLoop(i32 %cond, i32 %N) "no-frame-pointer-elim"="true" #0 { +define i32 @loopInfoRestoreOutsideLoop(i32 %cond, i32 %N) "no-frame-pointer-elim"="true" nounwind { entry: %tobool = icmp eq i32 %cond, 0 br i1 %tobool, label %if.else, label %if.then diff --git a/llvm/test/CodeGen/ARM/noreturn-csr-skip.mir b/llvm/test/CodeGen/ARM/noreturn-csr-skip.mir new file mode 100644 index 00000000000..2cf0bc80ae7 --- /dev/null +++ b/llvm/test/CodeGen/ARM/noreturn-csr-skip.mir @@ -0,0 +1,65 @@ +# RUN: llc -mtriple thumbv7m-none-eabi -run-pass prologepilog %s -o - | FileCheck %s + +--- | + define void @throw() noreturn { unreachable } + + define void @ret() nounwind { ret void } + + define void @tables() nounwind noreturn uwtable { ret void } + + define void @noret() noreturn nounwind { + start: + %p = alloca i32 + store i32 42, i32* %p + unreachable + } +... +--- +# This function may return by exception. Check that $r4 is saved and restored. +# CHECK-LABEL: name: throw +# CHECK: killed $r4 +# CHECK: def $r4 +name: throw +body: | + bb.0: + $r4 = IMPLICIT_DEF + tBX_RET 14, $noreg +--- +--- +# This function may return. Check that $r4 is saved and restored. +# CHECK-LABEL: name: ret +# CHECK: killed $r4 +# CHECK: def $r4 +name: ret +body: | + bb.0: + $r4 = IMPLICIT_DEF + tBX_RET 14, $noreg +--- +--- +# This function needs correct unwind tables anyway. Check that $r4 is saved and +# restored. +# CHECK-LABEL: name: tables +# CHECK: killed $r4 +# CHECK: def $r4 +name: tables +body: | + bb.0: + $r4 = IMPLICIT_DEF + tBX_RET 14, $noreg +--- +--- +# This function does not return. We need not save any CSR, but +# other stack adjustments in the prologue are still necessary. +# CHECK-LABEL: name: noret +# CHECK-NOT: killed $r4 +# CHECK-NOT: def $r4 +# CHECK: $sp = frame-setup +name: noret +stack: + - { id: 0, name: p, offset: 0, size: 4, alignment: 4, local-offset: -4 } +body: | + bb.0: + $r4 = IMPLICIT_DEF + tBX_RET 14, $noreg +--- |

