1 ; RUN: llc < %s -mtriple=i686-pc-linux-gnu -relocation-model=pic -asm-verbose=false -post-RA-scheduler=false | FileCheck %s -check-prefix=LINUX
3 @ptr = external global i32*
4 @dst = external global i32
5 @src = external global i32
7 define void @test0() nounwind {
9 store i32* @dst, i32** @ptr
10 %tmp.s = load i32* @src
11 store i32 %tmp.s, i32* @dst
18 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L0$pb),
19 ; LINUX: movl dst@GOT(%eax),
20 ; LINUX: movl ptr@GOT(%eax),
21 ; LINUX: movl src@GOT(%eax),
25 @ptr2 = global i32* null
29 define void @test1() nounwind {
31 store i32* @dst2, i32** @ptr2
32 %tmp.s = load i32* @src2
33 store i32 %tmp.s, i32* @dst2
40 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L1$pb), %eax
41 ; LINUX: movl dst2@GOT(%eax),
42 ; LINUX: movl ptr2@GOT(%eax),
43 ; LINUX: movl src2@GOT(%eax),
48 declare i8* @malloc(i32)
50 define void @test2() nounwind {
52 %ptr = call i8* @malloc(i32 40)
56 ; LINUX-NEXT: subl $8, %esp
57 ; LINUX-NEXT: calll .L2$pb
59 ; LINUX-NEXT: popl %ebx
60 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L2$pb), %ebx
61 ; LINUX: movl $40, (%esp)
62 ; LINUX: calll malloc@PLT
63 ; LINUX: addl $8, %esp
68 @pfoo = external global void(...)*
70 define void @test3() nounwind {
72 %tmp = call void(...)*(...)* @afoo()
73 store void(...)* %tmp, void(...)** @pfoo
74 %tmp1 = load void(...)** @pfoo
75 call void(...)* %tmp1()
81 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L3$pb), %[[REG3:e..]]
82 ; LINUX: calll afoo@PLT
83 ; LINUX: movl pfoo@GOT(%[[REG3]]),
87 declare void(...)* @afoo(...)
89 define void @test4() nounwind {
91 call void(...)* @foo()
96 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L4$pb), %ebx
97 ; LINUX: calll foo@PLT
100 declare void @foo(...)
103 @ptr6 = internal global i32* null
104 @dst6 = internal global i32 0
105 @src6 = internal global i32 0
107 define void @test5() nounwind {
109 store i32* @dst6, i32** @ptr6
110 %tmp.s = load i32* @src6
111 store i32 %tmp.s, i32* @dst6
115 ; LINUX: calll .L5$pb
116 ; LINUX-NEXT: .L5$pb:
117 ; LINUX-NEXT: popl %eax
118 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L5$pb), %eax
119 ; LINUX: leal dst6@GOTOFF(%eax), %ecx
120 ; LINUX: movl %ecx, ptr6@GOTOFF(%eax)
121 ; LINUX: movl src6@GOTOFF(%eax), %ecx
122 ; LINUX: movl %ecx, dst6@GOTOFF(%eax)
127 ;; Test constant pool references.
128 define double @test6(i32 %a.u) nounwind {
130 %tmp = icmp eq i32 %a.u,0
131 %retval = select i1 %tmp, double 4.561230e+02, double 1.234560e+02
137 ; LINUX: calll .L6$pb
139 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L6$pb),
140 ; LINUX: fldl .LCPI6_0@GOTOFF(
144 ;; Test jump table references.
145 define void @test7(i32 %n.u) nounwind {
147 switch i32 %n.u, label %bb12 [i32 1, label %bb i32 2, label %bb6 i32 4, label %bb7 i32 5, label %bb8 i32 6, label %bb10 i32 7, label %bb1 i32 8, label %bb3 i32 9, label %bb4 i32 10, label %bb9 i32 11, label %bb2 i32 12, label %bb5 i32 13, label %bb11 ]
149 tail call void(...)* @foo1()
152 tail call void(...)* @foo2()
155 tail call void(...)* @foo6()
158 tail call void(...)* @foo3()
161 tail call void(...)* @foo4()
164 tail call void(...)* @foo5()
167 tail call void(...)* @foo1()
170 tail call void(...)* @foo2()
173 tail call void(...)* @foo6()
176 tail call void(...)* @foo3()
179 tail call void(...)* @foo4()
182 tail call void(...)* @foo5()
185 tail call void(...)* @foo6()
189 ; LINUX: calll .L7$pb
191 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L7$pb),
192 ; LINUX: .LJTI7_0@GOTOFF(
196 ; LINUX: .long .LBB7_2@GOTOFF
197 ; LINUX: .long .LBB7_8@GOTOFF
198 ; LINUX: .long .LBB7_14@GOTOFF
199 ; LINUX: .long .LBB7_9@GOTOFF
200 ; LINUX: .long .LBB7_10@GOTOFF
203 declare void @foo1(...)
204 declare void @foo2(...)
205 declare void @foo6(...)
206 declare void @foo3(...)
207 declare void @foo4(...)
208 declare void @foo5(...)