mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-29 10:32:47 +00:00
d1cee9b3bc
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225446 91177308-0d34-0410-b5e6-96231b3b80d8
75 lines
3.2 KiB
LLVM
75 lines
3.2 KiB
LLVM
; RUN: llc < %s -mtriple=armv7-apple-ios -O0 | FileCheck %s -check-prefix=NO-REALIGN
|
|
; RUN: llc < %s -mtriple=armv7-apple-ios -O0 | FileCheck %s -check-prefix=REALIGN
|
|
|
|
; rdar://12713765
|
|
; When realign-stack is set to false, make sure we are not creating stack
|
|
; objects that are assumed to be 64-byte aligned.
|
|
@T3_retval = common global <16 x float> zeroinitializer, align 16
|
|
|
|
define void @test1(<16 x float>* noalias sret %agg.result) nounwind ssp "no-realign-stack" {
|
|
entry:
|
|
; NO-REALIGN-LABEL: test1
|
|
; NO-REALIGN: mov r[[R2:[0-9]+]], r[[R1:[0-9]+]]
|
|
; NO-REALIGN: vld1.32 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]!
|
|
; NO-REALIGN: vld1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]
|
|
; NO-REALIGN: add r[[R2:[0-9]+]], r[[R1]], #32
|
|
; NO-REALIGN: vld1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]
|
|
; NO-REALIGN: add r[[R2:[0-9]+]], r[[R1]], #48
|
|
; NO-REALIGN: vld1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]
|
|
|
|
; NO-REALIGN: add r[[R2:[0-9]+]], r[[R1:[0-9]+]], #48
|
|
; NO-REALIGN: vst1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]
|
|
; NO-REALIGN: add r[[R2:[0-9]+]], r[[R1]], #32
|
|
; NO-REALIGN: vst1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]
|
|
; NO-REALIGN: vst1.32 {{{d[0-9]+, d[0-9]+}}}, [r[[R1]]:128]!
|
|
; NO-REALIGN: vst1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R1]]:128]
|
|
|
|
; NO-REALIGN: add r[[R2:[0-9]+]], r[[R0:0]], #48
|
|
; NO-REALIGN: vst1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]
|
|
; NO-REALIGN: add r[[R2:[0-9]+]], r[[R0]], #32
|
|
; NO-REALIGN: vst1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]
|
|
; NO-REALIGN: vst1.32 {{{d[0-9]+, d[0-9]+}}}, [r[[R0]]:128]!
|
|
; NO-REALIGN: vst1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R0]]:128]
|
|
%retval = alloca <16 x float>, align 16
|
|
%0 = load <16 x float>* @T3_retval, align 16
|
|
store <16 x float> %0, <16 x float>* %retval
|
|
%1 = load <16 x float>* %retval
|
|
store <16 x float> %1, <16 x float>* %agg.result, align 16
|
|
ret void
|
|
}
|
|
|
|
define void @test2(<16 x float>* noalias sret %agg.result) nounwind ssp {
|
|
entry:
|
|
; REALIGN-LABEL: test2
|
|
; REALIGN: bfc sp, #0, #6
|
|
; REALIGN: mov r[[R2:[0-9]+]], r[[R1:[0-9]+]]
|
|
; REALIGN: vld1.32 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]!
|
|
; REALIGN: vld1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]
|
|
; REALIGN: add r[[R2:[0-9]+]], r[[R1]], #32
|
|
; REALIGN: vld1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]
|
|
; REALIGN: add r[[R2:[0-9]+]], r[[R1]], #48
|
|
; REALIGN: vld1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]
|
|
|
|
|
|
; REALIGN: orr r[[R2:[0-9]+]], r[[R1:[0-9]+]], #48
|
|
; REALIGN: vst1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]
|
|
; REALIGN: orr r[[R2:[0-9]+]], r[[R1]], #32
|
|
; REALIGN: vst1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]
|
|
; REALIGN: orr r[[R2:[0-9]+]], r[[R1]], #16
|
|
; REALIGN: vst1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R2]]:128]
|
|
; REALIGN: vst1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R1]]:128]
|
|
|
|
; REALIGN: add r[[R1:[0-9]+]], r[[R0:0]], #48
|
|
; REALIGN: vst1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R1]]:128]
|
|
; REALIGN: add r[[R1:[0-9]+]], r[[R0]], #32
|
|
; REALIGN: vst1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R1]]:128]
|
|
; REALIGN: vst1.32 {{{d[0-9]+, d[0-9]+}}}, [r[[R0]]:128]!
|
|
; REALIGN: vst1.64 {{{d[0-9]+, d[0-9]+}}}, [r[[R0]]:128]
|
|
%retval = alloca <16 x float>, align 16
|
|
%0 = load <16 x float>* @T3_retval, align 16
|
|
store <16 x float> %0, <16 x float>* %retval
|
|
%1 = load <16 x float>* %retval
|
|
store <16 x float> %1, <16 x float>* %agg.result, align 16
|
|
ret void
|
|
}
|