1 @globalvar = global i32 1, align 4
2 @staticvar = internal global i32 1, align 4
3 @staticconstvar = internal unnamed_addr constant [2 x i32] [i32 10, i32 20], align 4
4 @commonvar = common global i32 0, align 4
5 @P = internal global void ()* null, align 8
7 @weakalias = weak alias void (...), bitcast (void ()* @globalfunc1 to void (...)*)
8 @analias = alias void (...), bitcast (void ()* @globalfunc2 to void (...)*)
9 @linkoncealias = alias void (...), bitcast (void ()* @linkoncefunc to void (...)*)
11 define void @globalfunc1() #0 {
13 call void @funcwithpersonality()
14 call void (...) @variadic_va_start()
18 define void @globalfunc2() #0 {
23 define linkonce_odr void @linkoncefunc() #0 {
28 define i32 @referencestatics(i32 %i) #0 {
30 %i.addr = alloca i32, align 4
31 store i32 %i, i32* %i.addr, align 4
32 %call = call i32 @staticfunc()
33 %0 = load i32, i32* @staticvar, align 4
34 %add = add nsw i32 %call, %0
35 %1 = load i32, i32* %i.addr, align 4
36 %idxprom = sext i32 %1 to i64
37 %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* @staticconstvar, i64 0, i64 %idxprom
38 %2 = load i32, i32* %arrayidx, align 4
39 %add1 = add nsw i32 %add, %2
43 define i32 @referenceglobals(i32 %i) #0 {
45 %i.addr = alloca i32, align 4
46 store i32 %i, i32* %i.addr, align 4
47 call void @globalfunc1()
48 %0 = load i32, i32* @globalvar, align 4
52 define i32 @referencecommon(i32 %i) #0 {
54 %i.addr = alloca i32, align 4
55 store i32 %i, i32* %i.addr, align 4
56 %0 = load i32, i32* @commonvar, align 4
60 define void @setfuncptr() #0 {
62 store void ()* @staticfunc2, void ()** @P, align 8
66 define void @callfuncptr() #0 {
68 %0 = load void ()*, void ()** @P, align 8
73 @weakvar = weak global i32 1, align 4
74 define weak void @weakfunc() #0 {
79 define linkonce void @linkoncefunc2() #0 {
84 define internal i32 @staticfunc() #0 {
89 declare i32 @__gxx_personality_v0(...)
91 ; Add enough instructions to prevent import with inst limit of 5
92 define internal void @funcwithpersonality() #2 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
94 call void @globalfunc2()
95 call void @globalfunc2()
96 call void @globalfunc2()
97 call void @globalfunc2()
98 call void @globalfunc2()
99 call void @globalfunc2()
103 define internal void @staticfunc2() #0 {
108 define void @referencelargelinkonce() #0 {
110 call void @linkonceodr()
114 ; A large enough linkonce_odr function that should never be imported
115 define linkonce_odr void @linkonceodr() #0 {
117 call void @globalfunc2()
118 call void @globalfunc2()
119 call void @globalfunc2()
120 call void @globalfunc2()
121 call void @globalfunc2()
122 call void @globalfunc2()
123 call void @globalfunc2()
124 call void @globalfunc2()
125 call void @globalfunc2()
126 call void @globalfunc2()
127 call void @globalfunc2()
128 call void @globalfunc2()
129 call void @globalfunc2()
130 call void @globalfunc2()
131 call void @globalfunc2()
132 call void @globalfunc2()
133 call void @globalfunc2()
134 call void @globalfunc2()
135 call void @globalfunc2()
136 call void @globalfunc2()
137 call void @globalfunc2()
138 call void @globalfunc2()
139 call void @globalfunc2()
140 call void @globalfunc2()
141 call void @globalfunc2()
142 call void @globalfunc2()
143 call void @globalfunc2()
144 call void @globalfunc2()
145 call void @globalfunc2()
146 call void @globalfunc2()
150 ; Variadic function without va_start can be imported because inliner
152 define void @variadic_no_va_start(...) {
156 ; Variadic function with va_start should not be imported because inliner
158 define void @variadic_va_start(...) {
159 %ap = alloca i8*, align 8
160 %ap.0 = bitcast i8** %ap to i8*
161 call void @llvm.va_start(i8* %ap.0)
165 declare void @llvm.va_start(i8*) nounwind