diff options
author | Eli Friedman <efriedma@quicinc.com> | 2019-06-26 23:46:51 +0000 |
---|---|---|
committer | Eli Friedman <efriedma@quicinc.com> | 2019-06-26 23:46:51 +0000 |
commit | ab1d73ee32481e3033ebbe5a68afafb24da3df2e (patch) | |
tree | 2b16e264cc26eac95a6bc63cebfdee9db999c34d /llvm/test/CodeGen/Thumb/frame-access.ll | |
parent | d7999cbc6eb5e83e712904c1739fba799caf1c6c (diff) | |
download | bcm5719-llvm-ab1d73ee32481e3033ebbe5a68afafb24da3df2e.tar.gz bcm5719-llvm-ab1d73ee32481e3033ebbe5a68afafb24da3df2e.zip |
[ARM] Don't reserve R12 on Thumb1 as an emergency spill slot.
The current implementation of ThumbRegisterInfo::saveScavengerRegister
is bad for two reasons: one, it's buggy, and two, it blocks using R12
for other optimizations. So this patch gets rid of it, and adds the
necessary support for using an ordinary emergency spill slot on Thumb1.
(Specifically, I think saveScavengerRegister was broken by r305625, and
nobody noticed for two years because the codepath is almost never used.
The new code will also probably not be used much, but it now has better
tests, and if we fail to emit a necessary emergency spill slot we get a
reasonable error message instead of a miscompile.)
A rough outline of the changes in the patch:
1. Gets rid of ThumbRegisterInfo::saveScavengerRegister.
2. Modifies ARMFrameLowering::determineCalleeSaves to allocate an
emergency spill slot for Thumb1.
3. Implements useFPForScavengingIndex, so the emergency spill slot isn't
placed at a negative offset from FP on Thumb1.
4. Modifies the heuristics for allocating an emergency spill slot to
support Thumb1. This includes fixing ExtraCSSpill so we don't try to
use "lr" as a substitute for allocating an emergency spill slot.
5. Allocates a base pointer in more cases, so the emergency spill slot
is always accessible.
6. Modifies ARMFrameLowering::ResolveFrameIndexReference to compute the
right offset in the new cases where we're forcing a base pointer.
7. Ensures we never generate a load or store with an offset outside of
its frame object. This makes the heuristics more straightforward.
8. Changes Thumb1 prologue and epilogue emission so it never uses
register scavenging.
Some of the changes to the emergency spill slot heuristics in
determineCalleeSaves affect ARM/Thumb2; hopefully, they should allow
the compiler to avoid allocating an emergency spill slot in cases
where it isn't necessary. The rest of the changes should only affect
Thumb1.
Differential Revision: https://reviews.llvm.org/D63677
llvm-svn: 364490
Diffstat (limited to 'llvm/test/CodeGen/Thumb/frame-access.ll')
-rw-r--r-- | llvm/test/CodeGen/Thumb/frame-access.ll | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/llvm/test/CodeGen/Thumb/frame-access.ll b/llvm/test/CodeGen/Thumb/frame-access.ll index b472d235d39..ff1d57db944 100644 --- a/llvm/test/CodeGen/Thumb/frame-access.ll +++ b/llvm/test/CodeGen/Thumb/frame-access.ll @@ -124,7 +124,7 @@ entry: ; CHECK-NEXT: lsls r4, r4, #4 ; CHECK-NEXT: mov sp, r4 ; Incoming register varargs stored via FP -; CHECK: mov r0, r7 +; CHECK: mov r0, r7 ; CHECK-NEXT: adds r0, #8 ; CHECK-NEXT: stm r0!, {r1, r2, r3} ; VLAs present, access via FP @@ -199,11 +199,13 @@ entry: ; CHECK: push {r4, r5, r6, r7, lr} ; 20 bytes locals ; CHECK: sub sp, #20 +; Setup base pointer +; CHECK: mov r6, sp ; Allocate outgoing arguments space ; CHECK: sub sp, #508 ; CHECK: sub sp, #4 -; Load `e` via SP, 552 = 512 + 20 + 20 -; CHECK: ldr r3, [sp, #552] +; Load `e` via BP, 40 = 20 + 20 +; CHECK: ldr r3, [r6, #40] ; CHECK: bl f ; Stack restored before next call ; CHECK-NEXT: add sp, #508 @@ -235,11 +237,12 @@ entry: ; Three incoming register varargs ; CHECK: sub sp, #12 ; 16 bytes callee-saves -; CHECK: push {r4, r5, r7, lr} +; CHECK: push {r4, r5, r6, lr} ; 20 bytes locals ; CHECK: sub sp, #20 -; Incoming varargs stored via SP, 36 = 20 + 16 -; CHECK: add r0, sp, #36 +; Incoming varargs stored via BP, 36 = 20 + 16 +; CHECK: mov r0, r6 +; CHECK-NEXT: adds r0, #36 ; CHECK-NEXT: stm r0!, {r1, r2, r3} ; @@ -394,17 +397,19 @@ entry: ; CHECK-LABEL: test_local_moving_sp ; Locals area ; CHECK: sub sp, #36 +; Setup BP +; CHECK: mov r6, sp ; Outoging arguments ; CHECK: sub sp, #508 ; CHECK-NEXT: sub sp, #508 ; CHECK-NEXT: sub sp, #8 -; Argument addresses computed relative to SP -; CHECK: add r4, sp, #1020 -; CHECK-NEXT: adds r4, #24 -; CHECK: add r1, sp, #1020 -; CHECK-NEXT: adds r1, #20 -; CHECK: add r5, sp, #1020 -; CHECK-NEXT: adds r5, #16 +; Argument addresses computed relative to BP +; CHECK: adds r0, r6, #7 +; CHECK-NEXT: adds r0, #13 +; CHECK: adds r1, r6, #7 +; CHECK-NEXT: adds r1, #9 +; CHECK: adds r5, r6, #7 +; CHECK-NEXT: adds r5, #5 ; CHECK: bl u ; Stack restored before next call ; CHECK: add sp, #508 |