• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
6
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 (...)*)
10
11define void @globalfunc1() #0 {
12entry:
13  call void @funcwithpersonality()
14  ret void
15}
16
17define void @globalfunc2() #0 {
18entry:
19  ret void
20}
21
22define linkonce_odr void @linkoncefunc() #0 {
23entry:
24  ret void
25}
26
27define i32 @referencestatics(i32 %i) #0 {
28entry:
29  %i.addr = alloca i32, align 4
30  store i32 %i, i32* %i.addr, align 4
31  %call = call i32 @staticfunc()
32  %0 = load i32, i32* @staticvar, align 4
33  %add = add nsw i32 %call, %0
34  %1 = load i32, i32* %i.addr, align 4
35  %idxprom = sext i32 %1 to i64
36  %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* @staticconstvar, i64 0, i64 %idxprom
37  %2 = load i32, i32* %arrayidx, align 4
38  %add1 = add nsw i32 %add, %2
39  ret i32 %add1
40}
41
42define i32 @referenceglobals(i32 %i) #0 {
43entry:
44  %i.addr = alloca i32, align 4
45  store i32 %i, i32* %i.addr, align 4
46  call void @globalfunc1()
47  %0 = load i32, i32* @globalvar, align 4
48  ret i32 %0
49}
50
51define i32 @referencecommon(i32 %i) #0 {
52entry:
53  %i.addr = alloca i32, align 4
54  store i32 %i, i32* %i.addr, align 4
55  %0 = load i32, i32* @commonvar, align 4
56  ret i32 %0
57}
58
59define void @setfuncptr() #0 {
60entry:
61  store void ()* @staticfunc2, void ()** @P, align 8
62  ret void
63}
64
65define void @callfuncptr() #0 {
66entry:
67  %0 = load void ()*, void ()** @P, align 8
68  call void %0()
69  ret void
70}
71
72@weakvar = weak global i32 1, align 4
73define weak void @weakfunc() #0 {
74entry:
75  ret void
76}
77
78define linkonce void @linkoncefunc2() #0 {
79entry:
80  ret void
81}
82
83define internal i32 @staticfunc() #0 {
84entry:
85  ret i32 1
86}
87
88declare i32 @__gxx_personality_v0(...)
89
90; Add enough instructions to prevent import with inst limit of 5
91define internal void @funcwithpersonality() #2 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
92entry:
93  call void @globalfunc2()
94  call void @globalfunc2()
95  call void @globalfunc2()
96  call void @globalfunc2()
97  call void @globalfunc2()
98  call void @globalfunc2()
99  ret void
100}
101
102define internal void @staticfunc2() #0 {
103entry:
104  ret void
105}
106
107define void @referencelargelinkonce() #0 {
108entry:
109  call void @linkonceodr()
110  ret void
111}
112
113; A large enough linkonce_odr function that should never be imported
114define linkonce_odr void @linkonceodr() #0 {
115entry:
116  call void @globalfunc2()
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  ret void
147}
148
149
150