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 ret void 14} 15 16define void @globalfunc2() #0 { 17entry: 18 ret void 19} 20 21define linkonce_odr void @linkoncefunc() #0 { 22entry: 23 ret void 24} 25 26define i32 @referencestatics(i32 %i) #0 { 27entry: 28 %i.addr = alloca i32, align 4 29 store i32 %i, i32* %i.addr, align 4 30 %call = call i32 @staticfunc() 31 %0 = load i32, i32* @staticvar, align 4 32 %add = add nsw i32 %call, %0 33 %1 = load i32, i32* %i.addr, align 4 34 %idxprom = sext i32 %1 to i64 35 %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* @staticconstvar, i64 0, i64 %idxprom 36 %2 = load i32, i32* %arrayidx, align 4 37 %add1 = add nsw i32 %add, %2 38 ret i32 %add1 39} 40 41define i32 @referenceglobals(i32 %i) #0 { 42entry: 43 %i.addr = alloca i32, align 4 44 store i32 %i, i32* %i.addr, align 4 45 call void @globalfunc1() 46 %0 = load i32, i32* @globalvar, align 4 47 ret i32 %0 48} 49 50define i32 @referencecommon(i32 %i) #0 { 51entry: 52 %i.addr = alloca i32, align 4 53 store i32 %i, i32* %i.addr, align 4 54 %0 = load i32, i32* @commonvar, align 4 55 ret i32 %0 56} 57 58define void @setfuncptr() #0 { 59entry: 60 store void ()* @staticfunc2, void ()** @P, align 8 61 ret void 62} 63 64define void @callfuncptr() #0 { 65entry: 66 %0 = load void ()*, void ()** @P, align 8 67 call void %0() 68 ret void 69} 70 71@weakvar = weak global i32 1, align 4 72define weak void @weakfunc() #0 { 73entry: 74 ret void 75} 76 77define internal i32 @staticfunc() #0 { 78entry: 79 ret i32 1 80} 81 82define internal void @staticfunc2() #0 { 83entry: 84 ret void 85} 86 87 88