1; RUN: llc < %s -relocation-model=static | FileCheck %s -check-prefix=STATIC
2; RUN: llc < %s -relocation-model=pic -mtriple=powerpc-apple-darwin8 | FileCheck %s -check-prefix=PIC
3; RUN: llc < %s -relocation-model=pic -mtriple=powerpc-unknown-linux | FileCheck %s -check-prefix=PICELF
4; RUN: llc < %s -relocation-model=pic -mtriple=powerpc64-apple-darwin8 | FileCheck %s -check-prefix=PIC64
5; RUN: llc < %s -relocation-model=dynamic-no-pic -mtriple=powerpc-apple-darwin8 | FileCheck %s -check-prefix=DYNAMIC
6; RUN: llc < %s -relocation-model=dynamic-no-pic -mtriple=powerpc64-apple-darwin8 | FileCheck %s -check-prefix=DYNAMIC64
7; PR4482
8target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
9target triple = "powerpc-apple-darwin8"
10
11define i32 @foo(i64 %x) nounwind {
12entry:
13; STATIC: _foo:
14; STATIC: bl _exact_log2
15; STATIC: blr
16; STATIC: .subsections_via_symbols
17
18; PIC: _foo:
19; PIC: bl L_exact_log2$stub
20; PIC: blr
21
22; PICELF: foo:
23; PICELF: bl exact_log2@PLT
24; PICELF: blr
25
26; PIC64: _foo:
27; PIC64: bl L_exact_log2$stub
28; PIC64: blr
29
30; DYNAMIC: _foo:
31; DYNAMIC: bl L_exact_log2$stub
32; DYNAMIC: blr
33
34; DYNAMIC64: _foo:
35; DYNAMIC64: bl L_exact_log2$stub
36; DYNAMIC64: blr
37
38        %A = call i32 @exact_log2(i64 %x) nounwind
39	ret i32 %A
40}
41
42define available_externally i32 @exact_log2(i64 %x) nounwind {
43entry:
44	ret i32 42
45}
46
47
48; PIC: .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
49; PIC: L_exact_log2$stub:
50; PIC: .indirect_symbol _exact_log2
51; PIC: mflr r0
52; PIC: bcl 20, 31, L_exact_log2$stub$tmp
53
54; PIC: L_exact_log2$stub$tmp:
55; PIC: mflr r11
56; PIC: addis r11, r11, ha16(L_exact_log2$lazy_ptr-L_exact_log2$stub$tmp)
57; PIC: mtlr r0
58; PIC: lwzu r12, lo16(L_exact_log2$lazy_ptr-L_exact_log2$stub$tmp)(r11)
59; PIC: mtctr r12
60; PIC: bctr
61
62; PIC: .section __DATA,__la_symbol_ptr,lazy_symbol_pointers
63; PIC: L_exact_log2$lazy_ptr:
64; PIC: .indirect_symbol _exact_log2
65; PIC: .long dyld_stub_binding_helper
66
67; PIC: .subsections_via_symbols
68
69; PIC64: .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
70; PIC64: L_exact_log2$stub:
71; PIC64: .indirect_symbol _exact_log2
72; PIC64: mflr r0
73; PIC64: bcl 20, 31, L_exact_log2$stub$tmp
74
75; PIC64: L_exact_log2$stub$tmp:
76; PIC64: mflr r11
77; PIC64: addis r11, r11, ha16(L_exact_log2$lazy_ptr-L_exact_log2$stub$tmp)
78; PIC64: mtlr r0
79; PIC64: ldu r12, lo16(L_exact_log2$lazy_ptr-L_exact_log2$stub$tmp)(r11)
80; PIC64: mtctr r12
81; PIC64: bctr
82
83; PIC64: .section __DATA,__la_symbol_ptr,lazy_symbol_pointers
84; PIC64: L_exact_log2$lazy_ptr:
85; PIC64: .indirect_symbol _exact_log2
86; PIC64: .quad dyld_stub_binding_helper
87
88; PIC64: .subsections_via_symbols
89
90; DYNAMIC: .section __TEXT,__symbol_stub1,symbol_stubs,pure_instructions,16
91; DYNAMIC: L_exact_log2$stub:
92; DYNAMIC: .indirect_symbol _exact_log2
93; DYNAMIC: lis r11, ha16(L_exact_log2$lazy_ptr)
94; DYNAMIC: lwzu r12, lo16(L_exact_log2$lazy_ptr)(r11)
95; DYNAMIC: mtctr r12
96; DYNAMIC: bctr
97
98; DYNAMIC: .section __DATA,__la_symbol_ptr,lazy_symbol_pointers
99; DYNAMIC: L_exact_log2$lazy_ptr:
100; DYNAMIC: .indirect_symbol _exact_log2
101; DYNAMIC: .long dyld_stub_binding_helper
102
103; DYNAMIC64: .section __TEXT,__symbol_stub1,symbol_stubs,pure_instructions,16
104; DYNAMIC64: L_exact_log2$stub:
105; DYNAMIC64: .indirect_symbol _exact_log2
106; DYNAMIC64: lis r11, ha16(L_exact_log2$lazy_ptr)
107; DYNAMIC64: ldu r12, lo16(L_exact_log2$lazy_ptr)(r11)
108; DYNAMIC64: mtctr r12
109; DYNAMIC64: bctr
110
111; DYNAMIC64: .section __DATA,__la_symbol_ptr,lazy_symbol_pointers
112; DYNAMIC64: L_exact_log2$lazy_ptr:
113; DYNAMIC64: .indirect_symbol _exact_log2
114; DYNAMIC64: .quad dyld_stub_binding_helper
115