[ARM] Enable shrink-wrapping by default.
[oota-llvm.git] / test / CodeGen / ARM / none-macho.ll
1 ; RUN: llc -mtriple=thumbv7m-none-macho %s -o - -relocation-model=pic -disable-fp-elim | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NON-FAST
2 ; RUN: llc -mtriple=thumbv7m-none-macho -O0 %s -o - -relocation-model=pic -disable-fp-elim | FileCheck %s
3 ; RUN: llc -mtriple=thumbv7m-none-macho -filetype=obj %s -o /dev/null
4
5 @var = external global i32
6
7 define i32 @test_litpool() minsize {
8 ; CHECK-LABEL: test_litpool:
9   %val = load i32, i32* @var
10   ret i32 %val
11
12   ; Lit-pool entries need to produce a "$non_lazy_ptr" version of the symbol.
13 ; CHECK: LCPI0_0:
14 ; CHECK-NEXT: .long L_var$non_lazy_ptr-(LPC0_0+4)
15 }
16
17 define i32 @test_movw_movt() {
18 ; CHECK-LABEL: test_movw_movt:
19   %val = load i32, i32* @var
20   ret i32 %val
21
22   ; movw/movt should also address their symbols MachO-style
23 ; CHECK: movw [[RTMP:r[0-9]+]], :lower16:(L_var$non_lazy_ptr-(LPC1_0+4))
24 ; CHECK: movt [[RTMP]], :upper16:(L_var$non_lazy_ptr-(LPC1_0+4))
25 ; CHECK: LPC1_0:
26 ; CHECK: add [[RTMP]], pc
27 }
28
29 declare void @llvm.trap()
30
31 define void @test_trap() {
32 ; CHECK-LABEL: test_trap:
33
34   ; Bare-metal MachO gets compiled on top of normal MachO toolchain which
35   ; understands trap natively.
36   call void @llvm.trap()
37 ; CHECK: trap
38
39   ret void
40 }
41
42 define i32 @test_frame_ptr() {
43 ; CHECK-LABEL: test_frame_ptr:
44   call void @test_trap()
45
46   ; Frame pointer is r11.
47 ; CHECK: mov r11, sp
48   ret i32 42
49 }
50
51 %big_arr = type [8 x i32]
52 define void @test_two_areas(%big_arr* %addr) {
53 ; CHECK-LABEL: test_two_areas:
54   %val = load %big_arr, %big_arr* %addr
55   call void @test_trap()
56   store %big_arr %val, %big_arr* %addr
57
58   ; This goes with the choice of r7 as FP (largely). FP and LR have to be stored
59   ; consecutively on the stack for the frame record to be valid, which means we
60   ; need the 2 register-save areas employed by iOS.
61 ; CHECK-NON-FAST: push.w {r4, r5, r6, r7, r8, r9, r10, r11, lr}
62 ; ...
63 ; CHECK-NON-FAST: pop.w {r4, r5, r6, r7, r8, r9, r10, r11, pc}
64   ret void
65 }
66
67 define void @test_tail_call() {
68 ; CHECK-LABEL: test_tail_call:
69   tail call void @test_trap()
70
71   ; Tail calls should be available and use Thumb2 branch.
72 ; CHECK: b.w _test_trap
73   ret void
74 }
75
76 define float @test_softfloat_calls(float %in) {
77 ; CHECK-LABEL: test_softfloat_calls:
78   %sum = fadd float %in, %in
79
80   ; Soft-float calls should be GNU-style rather than RTABI and should not be the
81   ; *vfp variants used for ARMv6 iOS.
82 ; CHECK: bl ___addsf3{{$}}
83   ret float %sum
84 }
85
86   ; Even bare-metal PIC needs GOT-like behaviour, in principle. Depends a bit on
87   ; the use-case of course, but LLVM doesn't know what that is.
88 ; CHECK: non_lazy_symbol_pointers
89 ; CHECK: L_var$non_lazy_ptr:
90 ; CHECK-NEXT:   .indirect_symbol _var
91
92   ; All MachO objects should have this to give the linker leeway in removing
93   ; dead code.
94 ; CHECK: .subsections_via_symbols