diff options
| author | Kristof Beyls <kristof.beyls@arm.com> | 2015-01-08 15:09:14 +0000 |
|---|---|---|
| committer | Kristof Beyls <kristof.beyls@arm.com> | 2015-01-08 15:09:14 +0000 |
| commit | 933de7aa062fb879a6715d2b91c085a089063ee8 (patch) | |
| tree | a779f2e813eb4cdd2c3cf71b730c4b0fa6661275 /llvm/test/CodeGen/Thumb2 | |
| parent | 654d669e564250d8edecc07ca8b6c875dcaf8ff7 (diff) | |
| download | bcm5719-llvm-933de7aa062fb879a6715d2b91c085a089063ee8.tar.gz bcm5719-llvm-933de7aa062fb879a6715d2b91c085a089063ee8.zip | |
Fix large stack alignment codegen for ARM and Thumb2 targets
This partially fixes PR13007 (ARM CodeGen fails with large stack
alignment): for ARM and Thumb2 targets, but not for Thumb1, as it
seems stack alignment for Thumb1 targets hasn't been supported at
all.
Producing an aligned stack pointer is done by zero-ing out the lower
bits of the stack pointer. The BIC instruction was used for this.
However, the immediate field of the BIC instruction only allows to
encode an immediate that can zero out up to a maximum of the 8 lower
bits. When a larger alignment is requested, a BIC instruction cannot
be used; llvm was silently producing incorrect code in this case.
This commit fixes code generation for large stack aligments by
using the BFC instruction instead, when the BFC instruction is
available. When not, it uses 2 instructions: a right shift,
followed by a left shift to zero out the lower bits.
The lowering of ARM::Int_eh_sjlj_dispatchsetup still has code
that unconditionally uses BIC to realign the stack pointer, so it
very likely has the same problem. However, I wasn't able to
produce a test case for that. This commit adds an assert so that
the compiler will fail the assert instead of silently generating
wrong code if this is ever reached.
llvm-svn: 225446
Diffstat (limited to 'llvm/test/CodeGen/Thumb2')
| -rw-r--r-- | llvm/test/CodeGen/Thumb2/aligned-spill.ll | 8 | ||||
| -rw-r--r-- | llvm/test/CodeGen/Thumb2/thumb2-spill-q.ll | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/llvm/test/CodeGen/Thumb2/aligned-spill.ll b/llvm/test/CodeGen/Thumb2/aligned-spill.ll index 3a2803f91f1..4ef294bdf5f 100644 --- a/llvm/test/CodeGen/Thumb2/aligned-spill.ll +++ b/llvm/test/CodeGen/Thumb2/aligned-spill.ll @@ -9,7 +9,7 @@ target triple = "thumbv7-apple-ios" ; ; The caller-saved r4 is used as a scratch register for stack realignment. ; CHECK: push {r4, r7, lr} -; CHECK: bic r4, r4, #7 +; CHECK: bfc r4, #0, #3 ; CHECK: mov sp, r4 define void @f(double* nocapture %p) nounwind ssp { entry: @@ -23,7 +23,7 @@ entry: ; NEON: f ; NEON: push {r4, r7, lr} ; NEON: sub.w r4, sp, #64 -; NEON: bic r4, r4, #15 +; NEON: bfc r4, #0, #4 ; Stack pointer must be updated before the spills. ; NEON: mov sp, r4 ; NEON: vst1.64 {d8, d9, d10, d11}, [r4:128]! @@ -54,7 +54,7 @@ entry: ; NEON: f7 ; NEON: push {r4, r7, lr} ; NEON: sub.w r4, sp, #56 -; NEON: bic r4, r4, #15 +; NEON: bfc r4, #0, #4 ; Stack pointer must be updated before the spills. ; NEON: mov sp, r4 ; NEON: vst1.64 {d8, d9, d10, d11}, [r4:128]! @@ -81,7 +81,7 @@ entry: ; NEON: push {r4, r7, lr} ; NEON: vpush {d12, d13, d14, d15} ; NEON: sub.w r4, sp, #24 -; NEON: bic r4, r4, #15 +; NEON: bfc r4, #0, #4 ; Stack pointer must be updated before the spills. ; NEON: mov sp, r4 ; NEON: vst1.64 {d8, d9}, [r4:128] diff --git a/llvm/test/CodeGen/Thumb2/thumb2-spill-q.ll b/llvm/test/CodeGen/Thumb2/thumb2-spill-q.ll index 94f472593b3..d1deb461574 100644 --- a/llvm/test/CodeGen/Thumb2/thumb2-spill-q.ll +++ b/llvm/test/CodeGen/Thumb2/thumb2-spill-q.ll @@ -11,7 +11,7 @@ declare <4 x float> @llvm.arm.neon.vld1.v4f32(i8*, i32) nounwind readonly define void @aaa(%quuz* %this, i8* %block) { ; CHECK-LABEL: aaa: -; CHECK: bic r4, r4, #15 +; CHECK: bfc r4, #0, #4 ; CHECK: vst1.64 {{.*}}[{{.*}}:128] ; CHECK: vld1.64 {{.*}}[{{.*}}:128] entry: |

