1bf612458SYaxun (Sam) Liutarget datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 2bf612458SYaxun (Sam) Liutarget triple = "x86_64-apple-macosx10.11.0" 3bf612458SYaxun (Sam) Liu 4cee313d2SEric Christopher@globalvar = global i32 1, align 4 5cee313d2SEric Christopher@staticvar = internal global i32 1, align 4 6cee313d2SEric Christopher@staticconstvar = internal unnamed_addr constant [2 x i32] [i32 10, i32 20], align 4 7cee313d2SEric Christopher@commonvar = common global i32 0, align 4 8*41d5033eSNikita Popov@P = internal global ptr null, align 8 9cee313d2SEric Christopher 10*41d5033eSNikita Popov@weakalias = weak alias void (...), ptr @globalfunc1 11*41d5033eSNikita Popov@analias = alias void (...), ptr @globalfunc2 12*41d5033eSNikita Popov@linkoncealias = alias void (...), ptr @linkoncefunc 13cee313d2SEric Christopher 14cee313d2SEric Christopherdefine void @globalfunc1() #0 { 15cee313d2SEric Christopherentry: 16cee313d2SEric Christopher call void @funcwithpersonality() 17cee313d2SEric Christopher call void (...) @variadic_va_start() 18cee313d2SEric Christopher ret void 19cee313d2SEric Christopher} 20cee313d2SEric Christopher 21cee313d2SEric Christopherdefine void @globalfunc2() #0 { 22cee313d2SEric Christopherentry: 23cee313d2SEric Christopher ret void 24cee313d2SEric Christopher} 25cee313d2SEric Christopher 26cee313d2SEric Christopherdefine linkonce_odr void @linkoncefunc() #0 { 27cee313d2SEric Christopherentry: 28cee313d2SEric Christopher ret void 29cee313d2SEric Christopher} 30cee313d2SEric Christopher 31cee313d2SEric Christopherdefine i32 @referencestatics(i32 %i) #0 { 32cee313d2SEric Christopherentry: 33cee313d2SEric Christopher %i.addr = alloca i32, align 4 34*41d5033eSNikita Popov store i32 %i, ptr %i.addr, align 4 35cee313d2SEric Christopher %call = call i32 @staticfunc() 36*41d5033eSNikita Popov %0 = load i32, ptr @staticvar, align 4 37cee313d2SEric Christopher %add = add nsw i32 %call, %0 38*41d5033eSNikita Popov %1 = load i32, ptr %i.addr, align 4 39cee313d2SEric Christopher %idxprom = sext i32 %1 to i64 40*41d5033eSNikita Popov %arrayidx = getelementptr inbounds [2 x i32], ptr @staticconstvar, i64 0, i64 %idxprom 41*41d5033eSNikita Popov %2 = load i32, ptr %arrayidx, align 4 42cee313d2SEric Christopher %add1 = add nsw i32 %add, %2 43cee313d2SEric Christopher ret i32 %add1 44cee313d2SEric Christopher} 45cee313d2SEric Christopher 46cee313d2SEric Christopherdefine i32 @referenceglobals(i32 %i) #0 { 47cee313d2SEric Christopherentry: 48cee313d2SEric Christopher %i.addr = alloca i32, align 4 49*41d5033eSNikita Popov store i32 %i, ptr %i.addr, align 4 50cee313d2SEric Christopher call void @globalfunc1() 51*41d5033eSNikita Popov %0 = load i32, ptr @globalvar, align 4 52cee313d2SEric Christopher ret i32 %0 53cee313d2SEric Christopher} 54cee313d2SEric Christopher 55cee313d2SEric Christopherdefine i32 @referencecommon(i32 %i) #0 { 56cee313d2SEric Christopherentry: 57cee313d2SEric Christopher %i.addr = alloca i32, align 4 58*41d5033eSNikita Popov store i32 %i, ptr %i.addr, align 4 59*41d5033eSNikita Popov %0 = load i32, ptr @commonvar, align 4 60cee313d2SEric Christopher ret i32 %0 61cee313d2SEric Christopher} 62cee313d2SEric Christopher 63cee313d2SEric Christopherdefine void @setfuncptr() #0 { 64cee313d2SEric Christopherentry: 65*41d5033eSNikita Popov store ptr @staticfunc2, ptr @P, align 8 66cee313d2SEric Christopher ret void 67cee313d2SEric Christopher} 68cee313d2SEric Christopher 69cee313d2SEric Christopherdefine void @callfuncptr() #0 { 70cee313d2SEric Christopherentry: 71*41d5033eSNikita Popov %0 = load ptr, ptr @P, align 8 72cee313d2SEric Christopher call void %0() 73cee313d2SEric Christopher ret void 74cee313d2SEric Christopher} 75cee313d2SEric Christopher 76cee313d2SEric Christopher@weakvar = weak global i32 1, align 4 77cee313d2SEric Christopherdefine weak void @weakfunc() #0 { 78cee313d2SEric Christopherentry: 79cee313d2SEric Christopher ret void 80cee313d2SEric Christopher} 81cee313d2SEric Christopher 82cee313d2SEric Christopherdefine linkonce void @linkoncefunc2() #0 { 83cee313d2SEric Christopherentry: 84cee313d2SEric Christopher ret void 85cee313d2SEric Christopher} 86cee313d2SEric Christopher 87cee313d2SEric Christopherdefine internal i32 @staticfunc() #0 { 88cee313d2SEric Christopherentry: 89cee313d2SEric Christopher ret i32 1 90cee313d2SEric Christopher} 91cee313d2SEric Christopher 92cee313d2SEric Christopherdeclare i32 @__gxx_personality_v0(...) 93cee313d2SEric Christopher 94cee313d2SEric Christopher; Add enough instructions to prevent import with inst limit of 5 95*41d5033eSNikita Popovdefine internal void @funcwithpersonality() #2 personality ptr @__gxx_personality_v0 { 96cee313d2SEric Christopherentry: 97cee313d2SEric Christopher call void @globalfunc2() 98cee313d2SEric Christopher call void @globalfunc2() 99cee313d2SEric Christopher call void @globalfunc2() 100cee313d2SEric Christopher call void @globalfunc2() 101cee313d2SEric Christopher call void @globalfunc2() 102cee313d2SEric Christopher call void @globalfunc2() 103cee313d2SEric Christopher ret void 104cee313d2SEric Christopher} 105cee313d2SEric Christopher 106cee313d2SEric Christopherdefine internal void @staticfunc2() #0 { 107cee313d2SEric Christopherentry: 108cee313d2SEric Christopher ret void 109cee313d2SEric Christopher} 110cee313d2SEric Christopher 111cee313d2SEric Christopherdefine void @referencelargelinkonce() #0 { 112cee313d2SEric Christopherentry: 113cee313d2SEric Christopher call void @linkonceodr() 114cee313d2SEric Christopher ret void 115cee313d2SEric Christopher} 116cee313d2SEric Christopher 117cee313d2SEric Christopher; A large enough linkonce_odr function that should never be imported 118cee313d2SEric Christopherdefine linkonce_odr void @linkonceodr() #0 { 119cee313d2SEric Christopherentry: 120cee313d2SEric Christopher call void @globalfunc2() 121cee313d2SEric Christopher call void @globalfunc2() 122cee313d2SEric Christopher call void @globalfunc2() 123cee313d2SEric Christopher call void @globalfunc2() 124cee313d2SEric Christopher call void @globalfunc2() 125cee313d2SEric Christopher call void @globalfunc2() 126cee313d2SEric Christopher call void @globalfunc2() 127cee313d2SEric Christopher call void @globalfunc2() 128cee313d2SEric Christopher call void @globalfunc2() 129cee313d2SEric Christopher call void @globalfunc2() 130cee313d2SEric Christopher call void @globalfunc2() 131cee313d2SEric Christopher call void @globalfunc2() 132cee313d2SEric Christopher call void @globalfunc2() 133cee313d2SEric Christopher call void @globalfunc2() 134cee313d2SEric Christopher call void @globalfunc2() 135cee313d2SEric Christopher call void @globalfunc2() 136cee313d2SEric Christopher call void @globalfunc2() 137cee313d2SEric Christopher call void @globalfunc2() 138cee313d2SEric Christopher call void @globalfunc2() 139cee313d2SEric Christopher call void @globalfunc2() 140cee313d2SEric Christopher call void @globalfunc2() 141cee313d2SEric Christopher call void @globalfunc2() 142cee313d2SEric Christopher call void @globalfunc2() 143cee313d2SEric Christopher call void @globalfunc2() 144cee313d2SEric Christopher call void @globalfunc2() 145cee313d2SEric Christopher call void @globalfunc2() 146cee313d2SEric Christopher call void @globalfunc2() 147cee313d2SEric Christopher call void @globalfunc2() 148cee313d2SEric Christopher call void @globalfunc2() 149cee313d2SEric Christopher call void @globalfunc2() 150cee313d2SEric Christopher ret void 151cee313d2SEric Christopher} 152cee313d2SEric Christopher 153cee313d2SEric Christopher; Variadic function without va_start can be imported because inliner 154cee313d2SEric Christopher; can handle it. 155cee313d2SEric Christopherdefine void @variadic_no_va_start(...) { 156cee313d2SEric Christopher ret void 157cee313d2SEric Christopher} 158cee313d2SEric Christopher 159cee313d2SEric Christopher; Variadic function with va_start should not be imported because inliner 160cee313d2SEric Christopher; doesn't handle it. 161cee313d2SEric Christopherdefine void @variadic_va_start(...) { 162*41d5033eSNikita Popov %ap = alloca ptr, align 8 163*41d5033eSNikita Popov call void @llvm.va_start(ptr %ap) 164cee313d2SEric Christopher ret void 165cee313d2SEric Christopher} 166cee313d2SEric Christopher 167*41d5033eSNikita Popovdeclare void @llvm.va_start(ptr) nounwind 168