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 call void (...) @variadic_va_start() 15 ret void 16} 17 18define void @globalfunc2() #0 { 19entry: 20 ret void 21} 22 23define linkonce_odr void @linkoncefunc() #0 { 24entry: 25 ret void 26} 27 28define i32 @referencestatics(i32 %i) #0 { 29entry: 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 40 ret i32 %add1 41} 42 43define i32 @referenceglobals(i32 %i) #0 { 44entry: 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 49 ret i32 %0 50} 51 52define i32 @referencecommon(i32 %i) #0 { 53entry: 54 %i.addr = alloca i32, align 4 55 store i32 %i, i32* %i.addr, align 4 56 %0 = load i32, i32* @commonvar, align 4 57 ret i32 %0 58} 59 60define void @setfuncptr() #0 { 61entry: 62 store void ()* @staticfunc2, void ()** @P, align 8 63 ret void 64} 65 66define void @callfuncptr() #0 { 67entry: 68 %0 = load void ()*, void ()** @P, align 8 69 call void %0() 70 ret void 71} 72 73@weakvar = weak global i32 1, align 4 74define weak void @weakfunc() #0 { 75entry: 76 ret void 77} 78 79define linkonce void @linkoncefunc2() #0 { 80entry: 81 ret void 82} 83 84define internal i32 @staticfunc() #0 { 85entry: 86 ret i32 1 87} 88 89declare i32 @__gxx_personality_v0(...) 90 91; Add enough instructions to prevent import with inst limit of 5 92define internal void @funcwithpersonality() #2 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { 93entry: 94 call void @globalfunc2() 95 call void @globalfunc2() 96 call void @globalfunc2() 97 call void @globalfunc2() 98 call void @globalfunc2() 99 call void @globalfunc2() 100 ret void 101} 102 103define internal void @staticfunc2() #0 { 104entry: 105 ret void 106} 107 108define void @referencelargelinkonce() #0 { 109entry: 110 call void @linkonceodr() 111 ret void 112} 113 114; A large enough linkonce_odr function that should never be imported 115define linkonce_odr void @linkonceodr() #0 { 116entry: 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() 147 ret void 148} 149 150; Variadic function without va_start can be imported because inliner 151; can handle it. 152define void @variadic_no_va_start(...) { 153 ret void 154} 155 156; Variadic function with va_start should not be imported because inliner 157; doesn't handle it. 158define 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) 162 ret void 163} 164 165declare void @llvm.va_start(i8*) nounwind 166