1 ; RUN: llc < %s -mtriple=i686-pc-linux-gnu -relocation-model=pic | FileCheck %s -check-prefix=LINUX
3 @ptr = external global i32*
4 @dst = external global i32
5 @src = external global i32
7 define void @test1() nounwind {
9 store i32* @dst, i32** @ptr
10 %tmp.s = load i32* @src
11 store i32 %tmp.s, i32* @dst
19 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.Lpicbaseref1-.L1$pb),
20 ; LINUX: movl dst@GOT(%eax),
21 ; LINUX: movl ptr@GOT(%eax),
22 ; LINUX: movl src@GOT(%eax),
26 @ptr2 = global i32* null
30 define void @test2() nounwind {
32 store i32* @dst2, i32** @ptr2
33 %tmp.s = load i32* @src2
34 store i32 %tmp.s, i32* @dst2
41 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.Lpicbaseref2-.L2$pb), %eax
42 ; LINUX: movl dst2@GOT(%eax),
43 ; LINUX: movl ptr2@GOT(%eax),
44 ; LINUX: movl src2@GOT(%eax),
49 declare i8* @malloc(i32)
51 define void @test3() nounwind {
53 %ptr = call i8* @malloc(i32 40)
57 ; LINUX-NEXT: subl $8, %esp
58 ; LINUX-NEXT: call .L3$pb
60 ; LINUX-NEXT: popl %ebx
61 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.Lpicbaseref3-.L3$pb), %ebx
62 ; LINUX: movl $40, (%esp)
63 ; LINUX: call malloc@PLT
64 ; LINUX: addl $8, %esp
69 @pfoo = external global void(...)*
71 define void @test4() nounwind {
73 %tmp = call void(...)*(...)* @afoo()
74 store void(...)* %tmp, void(...)** @pfoo
75 %tmp1 = load void(...)** @pfoo
76 call void(...)* %tmp1()
82 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.Lpicbaseref4-.L4$pb),
83 ; LINUX: movl pfoo@GOT(%esi),
84 ; LINUX: call afoo@PLT
88 declare void(...)* @afoo(...)
90 define void @test5() nounwind {
92 call void(...)* @foo()
97 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.Lpicbaseref5-.L5$pb), %ebx
101 declare void @foo(...)
104 @ptr6 = internal global i32* null
105 @dst6 = internal global i32 0
106 @src6 = internal global i32 0
108 define void @test6() nounwind {
110 store i32* @dst6, i32** @ptr6
111 %tmp.s = load i32* @src6
112 store i32 %tmp.s, i32* @dst6
117 ; LINUX-NEXT: .L6$pb:
118 ; LINUX-NEXT: popl %eax
119 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.Lpicbaseref6-.L6$pb), %eax
120 ; LINUX: leal dst6@GOTOFF(%eax), %ecx
121 ; LINUX: movl %ecx, ptr6@GOTOFF(%eax)
122 ; LINUX: movl src6@GOTOFF(%eax), %ecx
123 ; LINUX: movl %ecx, dst6@GOTOFF(%eax)
128 ;; Test constant pool references.
129 define double @test7(i32 %a.u) nounwind {
131 %tmp = icmp eq i32 %a.u,0
132 %retval = select i1 %tmp, double 4.561230e+02, double 1.234560e+02
140 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.Lpicbaseref7-.L7$pb),
141 ; LINUX: fldl .LCPI7_0@GOTOFF(
145 ;; Test jump table references.
146 define void @test8(i32 %n.u) nounwind {
148 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 ]
150 tail call void(...)* @foo1()
153 tail call void(...)* @foo2()
156 tail call void(...)* @foo6()
159 tail call void(...)* @foo3()
162 tail call void(...)* @foo4()
165 tail call void(...)* @foo5()
168 tail call void(...)* @foo1()
171 tail call void(...)* @foo2()
174 tail call void(...)* @foo6()
177 tail call void(...)* @foo3()
180 tail call void(...)* @foo4()
183 tail call void(...)* @foo5()
186 tail call void(...)* @foo6()
192 ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.Lpicbaseref8-.L8$pb),
193 ; LINUX: addl .LJTI8_0@GOTOFF(
197 ; LINUX: .long .LBB8_2@GOTOFF
198 ; LINUX: .long .LBB8_2@GOTOFF
199 ; LINUX: .long .LBB8_7@GOTOFF
200 ; LINUX: .long .LBB8_3@GOTOFF
201 ; LINUX: .long .LBB8_7@GOTOFF
204 declare void @foo1(...)
205 declare void @foo2(...)
206 declare void @foo6(...)
207 declare void @foo3(...)
208 declare void @foo4(...)
209 declare void @foo5(...)