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 11 define void @globalfunc1() #0 { 12 entry: 13 call void @funcwithpersonality() 14 ret void 15 } 16 17 define void @globalfunc2() #0 { 18 entry: 19 ret void 20 } 21 22 define linkonce_odr void @linkoncefunc() #0 { 23 entry: 24 ret void 25 } 26 27 define i32 @referencestatics(i32 %i) #0 { 28 entry: 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 42 define i32 @referenceglobals(i32 %i) #0 { 43 entry: 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 51 define i32 @referencecommon(i32 %i) #0 { 52 entry: 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 59 define void @setfuncptr() #0 { 60 entry: 61 store void ()* @staticfunc2, void ()** @P, align 8 62 ret void 63 } 64 65 define void @callfuncptr() #0 { 66 entry: 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 73 define weak void @weakfunc() #0 { 74 entry: 75 ret void 76 } 77 78 define linkonce void @linkoncefunc2() #0 { 79 entry: 80 ret void 81 } 82 83 define internal i32 @staticfunc() #0 { 84 entry: 85 ret i32 1 86 } 87 88 declare i32 @__gxx_personality_v0(...) 89 90 ; Add enough instructions to prevent import with inst limit of 5 91 define internal void @funcwithpersonality() #2 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { 92 entry: 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 102 define internal void @staticfunc2() #0 { 103 entry: 104 ret void 105 } 106 107 define void @referencelargelinkonce() #0 { 108 entry: 109 call void @linkonceodr() 110 ret void 111 } 112 113 ; A large enough linkonce_odr function that should never be imported 114 define linkonce_odr void @linkonceodr() #0 { 115 entry: 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