2016-03-03 03:20:00 +08:00
|
|
|
; RUN: llc < %s -mtriple=thumbv7-apple-ios -mattr=+thumb2 | FileCheck %s -check-prefix=ALL -check-prefix=CHECK
|
|
|
|
; RUN: llc < %s -mtriple=thumbv7-apple-ios -mattr=+thumb2 -arm-assume-misaligned-load-store | FileCheck %s -check-prefix=ALL -check-prefix=CONSERVATIVE
|
2009-08-05 05:12:13 +08:00
|
|
|
|
|
|
|
@X = external global [0 x i32] ; <[0 x i32]*> [#uses=5]
|
|
|
|
|
[ARM] Generate consistent frame records for Thumb2
There is not an official documented ABI for frame pointers in Thumb2,
but we should try to emit something which is useful.
We use r7 as the frame pointer for Thumb code, which currently means
that if a function needs to save a high register (r8-r11), it will get
pushed to the stack between the frame pointer (r7) and link register
(r14). This means that while a stack unwinder can follow the chain of
frame pointers up the stack, it cannot know the offset to lr, so does
not know which functions correspond to the stack frames.
To fix this, we need to push the callee-saved registers in two batches,
with the first push saving the low registers, fp and lr, and the second
push saving the high registers. This is already implemented, but
previously only used for iOS. This patch turns it on for all Thumb2
targets when frame pointers are required by the ABI, and the frame
pointer is r7 (Windows uses r11, so this isn't a problem there). If
frame pointer elimination is enabled we still emit a single push/pop
even if we need a frame pointer for other reasons, to avoid increasing
code size.
We must also ensure that lr is pushed to the stack when using a frame
pointer, so that we end up with a complete frame record. Situations that
could cause this were rare, because we already push lr in most
situations so that we can return using the pop instruction.
Differential Revision: https://reviews.llvm.org/D23516
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define i32 @t1() "no-frame-pointer-elim"="true" {
|
2016-03-03 03:20:00 +08:00
|
|
|
; ALL-LABEL: t1:
|
|
|
|
; ALL: push {r7, lr}
|
2014-05-16 22:14:30 +08:00
|
|
|
; CHECK: ldrd
|
2016-03-03 03:20:00 +08:00
|
|
|
; CONSERVATIVE-NOT: ldrd
|
|
|
|
; CONSERVATIVE-NOT: ldm
|
|
|
|
; ALL: pop {r7, pc}
|
2015-03-14 02:20:45 +08:00
|
|
|
%tmp = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @X, i32 0, i32 0) ; <i32> [#uses=1]
|
|
|
|
%tmp3 = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @X, i32 0, i32 1) ; <i32> [#uses=1]
|
2010-06-04 05:53:01 +08:00
|
|
|
%tmp4 = call i32 @f1( i32 %tmp, i32 %tmp3 ) ; <i32> [#uses=1]
|
2009-08-05 05:12:13 +08:00
|
|
|
ret i32 %tmp4
|
|
|
|
}
|
|
|
|
|
[ARM] Generate consistent frame records for Thumb2
There is not an official documented ABI for frame pointers in Thumb2,
but we should try to emit something which is useful.
We use r7 as the frame pointer for Thumb code, which currently means
that if a function needs to save a high register (r8-r11), it will get
pushed to the stack between the frame pointer (r7) and link register
(r14). This means that while a stack unwinder can follow the chain of
frame pointers up the stack, it cannot know the offset to lr, so does
not know which functions correspond to the stack frames.
To fix this, we need to push the callee-saved registers in two batches,
with the first push saving the low registers, fp and lr, and the second
push saving the high registers. This is already implemented, but
previously only used for iOS. This patch turns it on for all Thumb2
targets when frame pointers are required by the ABI, and the frame
pointer is r7 (Windows uses r11, so this isn't a problem there). If
frame pointer elimination is enabled we still emit a single push/pop
even if we need a frame pointer for other reasons, to avoid increasing
code size.
We must also ensure that lr is pushed to the stack when using a frame
pointer, so that we end up with a complete frame record. Situations that
could cause this were rare, because we already push lr in most
situations so that we can return using the pop instruction.
Differential Revision: https://reviews.llvm.org/D23516
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define i32 @t2() "no-frame-pointer-elim"="true" {
|
2016-03-03 03:20:00 +08:00
|
|
|
; ALL-LABEL: t2:
|
|
|
|
; ALL: push {r7, lr}
|
2011-08-19 05:50:53 +08:00
|
|
|
; CHECK: ldm
|
2016-03-03 03:20:00 +08:00
|
|
|
; CONSERVATIVE-NOT: ldrd
|
|
|
|
; CONSERVATIVE-NOT: ldm
|
|
|
|
; ALL: pop {r7, pc}
|
2015-03-14 02:20:45 +08:00
|
|
|
%tmp = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @X, i32 0, i32 2) ; <i32> [#uses=1]
|
|
|
|
%tmp3 = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @X, i32 0, i32 3) ; <i32> [#uses=1]
|
|
|
|
%tmp5 = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @X, i32 0, i32 4) ; <i32> [#uses=1]
|
2010-06-04 05:53:01 +08:00
|
|
|
%tmp6 = call i32 @f2( i32 %tmp, i32 %tmp3, i32 %tmp5 ) ; <i32> [#uses=1]
|
2009-08-05 05:12:13 +08:00
|
|
|
ret i32 %tmp6
|
|
|
|
}
|
|
|
|
|
[ARM] Generate consistent frame records for Thumb2
There is not an official documented ABI for frame pointers in Thumb2,
but we should try to emit something which is useful.
We use r7 as the frame pointer for Thumb code, which currently means
that if a function needs to save a high register (r8-r11), it will get
pushed to the stack between the frame pointer (r7) and link register
(r14). This means that while a stack unwinder can follow the chain of
frame pointers up the stack, it cannot know the offset to lr, so does
not know which functions correspond to the stack frames.
To fix this, we need to push the callee-saved registers in two batches,
with the first push saving the low registers, fp and lr, and the second
push saving the high registers. This is already implemented, but
previously only used for iOS. This patch turns it on for all Thumb2
targets when frame pointers are required by the ABI, and the frame
pointer is r7 (Windows uses r11, so this isn't a problem there). If
frame pointer elimination is enabled we still emit a single push/pop
even if we need a frame pointer for other reasons, to avoid increasing
code size.
We must also ensure that lr is pushed to the stack when using a frame
pointer, so that we end up with a complete frame record. Situations that
could cause this were rare, because we already push lr in most
situations so that we can return using the pop instruction.
Differential Revision: https://reviews.llvm.org/D23516
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define i32 @t3() "no-frame-pointer-elim"="true" {
|
2016-03-03 03:20:00 +08:00
|
|
|
; ALL-LABEL: t3:
|
|
|
|
; ALL: push {r7, lr}
|
2014-05-16 22:14:30 +08:00
|
|
|
; CHECK: ldm
|
2016-03-03 03:20:00 +08:00
|
|
|
; CONSERVATIVE-NOT: ldrd
|
|
|
|
; CONSERVATIVE-NOT: ldm
|
|
|
|
; ALL: pop {r7, pc}
|
2015-03-14 02:20:45 +08:00
|
|
|
%tmp = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @X, i32 0, i32 1) ; <i32> [#uses=1]
|
|
|
|
%tmp3 = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @X, i32 0, i32 2) ; <i32> [#uses=1]
|
|
|
|
%tmp5 = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @X, i32 0, i32 3) ; <i32> [#uses=1]
|
2010-06-04 05:53:01 +08:00
|
|
|
%tmp6 = call i32 @f2( i32 %tmp, i32 %tmp3, i32 %tmp5 ) ; <i32> [#uses=1]
|
2009-08-05 05:12:13 +08:00
|
|
|
ret i32 %tmp6
|
|
|
|
}
|
|
|
|
|
2016-03-03 03:20:00 +08:00
|
|
|
@g = common global i32* null
|
|
|
|
|
[ARM] Generate consistent frame records for Thumb2
There is not an official documented ABI for frame pointers in Thumb2,
but we should try to emit something which is useful.
We use r7 as the frame pointer for Thumb code, which currently means
that if a function needs to save a high register (r8-r11), it will get
pushed to the stack between the frame pointer (r7) and link register
(r14). This means that while a stack unwinder can follow the chain of
frame pointers up the stack, it cannot know the offset to lr, so does
not know which functions correspond to the stack frames.
To fix this, we need to push the callee-saved registers in two batches,
with the first push saving the low registers, fp and lr, and the second
push saving the high registers. This is already implemented, but
previously only used for iOS. This patch turns it on for all Thumb2
targets when frame pointers are required by the ABI, and the frame
pointer is r7 (Windows uses r11, so this isn't a problem there). If
frame pointer elimination is enabled we still emit a single push/pop
even if we need a frame pointer for other reasons, to avoid increasing
code size.
We must also ensure that lr is pushed to the stack when using a frame
pointer, so that we end up with a complete frame record. Situations that
could cause this were rare, because we already push lr in most
situations so that we can return using the pop instruction.
Differential Revision: https://reviews.llvm.org/D23516
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define void @t4(i32 %a0, i32 %a1, i32 %a2) "no-frame-pointer-elim"="true" {
|
2016-03-03 03:20:00 +08:00
|
|
|
; ALL-LABEL: t4:
|
|
|
|
; ALL: stm.w sp, {r0, r1, r2}
|
2016-05-11 03:17:47 +08:00
|
|
|
; ALL: bl _ext
|
2016-03-03 03:20:00 +08:00
|
|
|
; ALL: ldm.w sp, {r0, r1, r2}
|
2016-05-11 03:17:47 +08:00
|
|
|
; ALL: bl _f2
|
2016-03-03 03:20:00 +08:00
|
|
|
%arr = alloca [4 x i32], align 4
|
|
|
|
%p0 = getelementptr inbounds [4 x i32], [4 x i32]* %arr, i64 0, i64 0
|
|
|
|
%p1 = getelementptr inbounds [4 x i32], [4 x i32]* %arr, i64 0, i64 1
|
|
|
|
%p2 = getelementptr inbounds [4 x i32], [4 x i32]* %arr, i64 0, i64 2
|
|
|
|
store i32* %p0, i32** @g, align 8
|
|
|
|
|
|
|
|
store i32 %a0, i32* %p0, align 4
|
|
|
|
store i32 %a1, i32* %p1, align 4
|
|
|
|
store i32 %a2, i32* %p2, align 4
|
|
|
|
call void @ext()
|
|
|
|
|
|
|
|
%v0 = load i32, i32* %p0, align 4
|
|
|
|
%v1 = load i32, i32* %p1, align 4
|
|
|
|
%v2 = load i32, i32* %p2, align 4
|
|
|
|
call i32 @f2(i32 %v0, i32 %v1, i32 %v2)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2009-08-05 05:12:13 +08:00
|
|
|
declare i32 @f1(i32, i32)
|
|
|
|
|
|
|
|
declare i32 @f2(i32, i32, i32)
|
2016-03-03 03:20:00 +08:00
|
|
|
|
|
|
|
declare void @ext()
|