2012-01-04 09:55:04 +08:00
|
|
|
; RUN: llc < %s -mtriple=thumb-apple-ios | FileCheck %s
|
2009-06-24 14:36:07 +08:00
|
|
|
|
|
|
|
define void @test1() {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test1:
|
2010-08-11 03:30:19 +08:00
|
|
|
; CHECK: sub sp, #256
|
|
|
|
; CHECK: add sp, #256
|
2009-06-24 14:36:07 +08:00
|
|
|
%tmp = alloca [ 64 x i32 ] , align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @test2() {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test2:
|
2013-07-22 23:49:36 +08:00
|
|
|
; CHECK: ldr r0, LCPI
|
2010-08-11 03:30:19 +08:00
|
|
|
; CHECK: add sp, r0
|
Fix epilogue codegen to avoid leaving the stack pointer in an invalid
state. Previously Thumb2 would restore sp from fp like this:
mov sp, r7
sub, sp, #4
If an interrupt is taken after the 'mov' but before the 'sub', callee-saved
registers might be clobbered by the interrupt handler. Instead, try
restoring directly from sp:
add sp, #4
Or, if necessary (with VLA, etc.) use a scratch register to compute sp and
then restore it:
sub.w r4, r7, #8
mov sp, r7
rdar://8465407
llvm-svn: 119977
2010-11-23 02:12:04 +08:00
|
|
|
; CHECK: subs r4, r7, #4
|
|
|
|
; CHECK: mov sp, r4
|
2009-06-24 14:36:07 +08:00
|
|
|
%tmp = alloca [ 4168 x i8 ] , align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test3() {
|
2013-07-14 04:38:47 +08:00
|
|
|
; CHECK-LABEL: test3:
|
2013-07-22 23:49:36 +08:00
|
|
|
; CHECK: ldr r1, LCPI
|
2013-05-01 04:04:37 +08:00
|
|
|
; CHECK: add sp, r1
|
2013-07-22 23:49:36 +08:00
|
|
|
; CHECK: ldr r1, LCPI
|
2010-08-11 03:30:19 +08:00
|
|
|
; CHECK: add r1, sp
|
Fix epilogue codegen to avoid leaving the stack pointer in an invalid
state. Previously Thumb2 would restore sp from fp like this:
mov sp, r7
sub, sp, #4
If an interrupt is taken after the 'mov' but before the 'sub', callee-saved
registers might be clobbered by the interrupt handler. Instead, try
restoring directly from sp:
add sp, #4
Or, if necessary (with VLA, etc.) use a scratch register to compute sp and
then restore it:
sub.w r4, r7, #8
mov sp, r7
rdar://8465407
llvm-svn: 119977
2010-11-23 02:12:04 +08:00
|
|
|
; CHECK: subs r4, r7, #4
|
|
|
|
; CHECK: mov sp, r4
|
2010-08-11 03:30:19 +08:00
|
|
|
%retval = alloca i32, align 4
|
|
|
|
%tmp = alloca i32, align 4
|
|
|
|
%a = alloca [805306369 x i8], align 16
|
|
|
|
store i32 0, i32* %tmp
|
|
|
|
%tmp1 = load i32* %tmp
|
|
|
|
ret i32 %tmp1
|
2009-06-24 14:36:07 +08:00
|
|
|
}
|
2014-10-20 19:00:18 +08:00
|
|
|
|
|
|
|
; Here, the adds get optimized out because they are dead, but the calculation
|
|
|
|
; of the address of stack_a is dead but not optimized out. When the address
|
|
|
|
; calculation gets expanded to two instructions, we need to avoid reading a
|
|
|
|
; dead register.
|
|
|
|
; No CHECK lines (just test for crashes), as we hope this will be optimised
|
|
|
|
; better in future.
|
|
|
|
define i32 @test4() {
|
|
|
|
entry:
|
|
|
|
%stack_a = alloca i8, align 1
|
|
|
|
%stack_b = alloca [256 x i32*], align 4
|
|
|
|
%int = ptrtoint i8* %stack_a to i32
|
|
|
|
%add = add i32 %int, 1
|
|
|
|
br label %block2
|
|
|
|
|
|
|
|
block2:
|
|
|
|
%add2 = add i32 %add, 1
|
|
|
|
ret i32 0
|
|
|
|
}
|