• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -fast-isel -O0 -mcpu=generic -mtriple=i386-apple-darwin10 -relocation-model=pic < %s | FileCheck %s
2; RUN: llc -fast-isel -O0 -mcpu=generic -mtriple=i386-apple-darwin10 -relocation-model=pic < %s -fast-isel-verbose 2>&1 >/dev/null | FileCheck -check-prefix=STDERR -allow-empty %s
3
4; This should use flds to set the return value.
5; CHECK-LABEL: test0:
6; CHECK: flds
7; CHECK: retl
8@G = external global float
9define float @test0() nounwind {
10  %t = load float, float* @G
11  ret float %t
12}
13
14; This should pop 4 bytes on return.
15; CHECK-LABEL: test1:
16; CHECK: retl $4
17define void @test1({i32, i32, i32, i32}* sret %p) nounwind {
18  store {i32, i32, i32, i32} zeroinitializer, {i32, i32, i32, i32}* %p
19  ret void
20}
21
22; This should pop 8 bytes on return.
23; CHECK-LABEL: thiscallfun:
24; CHECK: retl $8
25define x86_thiscallcc i32 @thiscallfun(i32* %this, i32 %a, i32 %b) nounwind {
26; STDERR-NOT: FastISel missed terminator: ret i32 12345
27  ret i32 12345
28}
29
30; Here, the callee pop doesn't fit the 16 bit immediate -- see x86-big-ret.ll
31; This checks that -fast-isel doesn't miscompile this.
32; CHECK-LABEL: thiscall_large:
33; CHECK:      popl %ecx
34; CHECK-NEXT: addl $65536, %esp
35; CHECK-NEXT: pushl %ecx
36; CHECK-NEXT: retl
37define x86_thiscallcc void @thiscall_large(i32* %this, [65533 x i8]* byval %b) nounwind {
38  ret void
39}
40
41; This should pop 4 bytes on return.
42; CHECK-LABEL: stdcallfun:
43; CHECK: retl $4
44define x86_stdcallcc i32 @stdcallfun(i32 %a) nounwind {
45; STDERR-NOT: FastISel missed terminator: ret i32 54321
46  ret i32 54321
47}
48
49; Properly initialize the pic base.
50; CHECK-LABEL: test2:
51; CHECK-NOT: HHH
52; CHECK: call{{.*}}L5$pb
53; CHECK-NEXT: L5$pb:
54; CHECK-NEXT: pop
55; CHECK: HHH
56; CHECK: retl
57@HHH = external global i32
58define i32 @test2() nounwind {
59  %t = load i32, i32* @HHH
60  ret i32 %t
61}
62
63; Check that we fast-isel sret, and handle the callee-pops behavior correctly.
64%struct.a = type { i64, i64, i64 }
65define void @test3() nounwind ssp {
66entry:
67  %tmp = alloca %struct.a, align 8
68  call void @test3sret(%struct.a* sret %tmp)
69  ret void
70; CHECK-LABEL: test3:
71; CHECK: subl $44
72; CHECK: leal 16(%esp)
73; CHECK: calll _test3sret
74; CHECK: addl $40
75}
76declare void @test3sret(%struct.a* sret)
77
78; Check that fast-isel sret works with fastcc (and does not callee-pop)
79define void @test4() nounwind ssp {
80entry:
81  %tmp = alloca %struct.a, align 8
82  call fastcc void @test4fastccsret(%struct.a* sret %tmp)
83  ret void
84; CHECK-LABEL: test4:
85; CHECK: subl $28
86; CHECK: leal (%esp), %ecx
87; CHECK: calll _test4fastccsret
88; CHECK: addl $28
89}
90declare fastcc void @test4fastccsret(%struct.a* sret)
91
92
93; Check that fast-isel cleans up when it fails to lower a call instruction.
94define void @test5() {
95entry:
96  %call = call i32 @test5dllimport(i32 42)
97  ret void
98; CHECK-LABEL: test5:
99; Local value area is still there:
100; CHECK: movl $42, {{%[a-z]+}}
101; Fast-ISel's arg push is not here:
102; CHECK-NOT: movl $42, (%esp)
103; SDag-ISel's arg push:
104; CHECK: movl %esp, [[REGISTER:%[a-z]+]]
105; CHECK: movl $42, ([[REGISTER]])
106; CHECK: movl L_test5dllimport$non_lazy_ptr-L8$pb(%eax), %eax
107
108}
109declare dllimport i32 @test5dllimport(i32)
110