1; RUN: opt -module-summary %s -o %t1.bc 2; RUN: opt -module-summary %p/Inputs/alias_import.ll -o %t2.bc 3; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %t1.bc %t2.bc 4; RUN: llvm-lto -thinlto-action=promote -thinlto-index %t.index.bc %t2.bc -o - | llvm-dis -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=PROMOTE 5; RUN: llvm-lto -thinlto-action=import -thinlto-index %t.index.bc %t1.bc -o - | llvm-dis -o - | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=IMPORT 6 7; Alias can't point to "available_externally", so they are implemented by 8; importing the alias as an available_externally definition copied from the 9; aliasee's body. 10; PROMOTE-DAG: @globalfuncAlias = alias void (...), bitcast (void ()* @globalfunc to void (...)*) 11; PROMOTE-DAG: @globalfuncWeakAlias = weak alias void (...), bitcast (void ()* @globalfunc to void (...)*) 12; PROMOTE-DAG: @globalfuncLinkonceAlias = weak alias void (...), bitcast (void ()* @globalfunc to void (...)*) 13; PROMOTE-DAG: @globalfuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @globalfunc to void (...)*) 14; PROMOTE-DAG: @globalfuncLinkonceODRAlias = weak_odr alias void (...), bitcast (void ()* @globalfunc to void (...)*) 15; PROMOTE-DAG: @internalfuncAlias = alias void (...), bitcast (void ()* @internalfunc to void (...)*) 16; PROMOTE-DAG: @internalfuncWeakAlias = weak alias void (...), bitcast (void ()* @internalfunc to void (...)*) 17; PROMOTE-DAG: @internalfuncLinkonceAlias = weak alias void (...), bitcast (void ()* @internalfunc to void (...)*) 18; PROMOTE-DAG: @internalfuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @internalfunc to void (...)*) 19; PROMOTE-DAG: @internalfuncLinkonceODRAlias = weak_odr alias void (...), bitcast (void ()* @internalfunc to void (...)*) 20; PROMOTE-DAG: @linkoncefuncAlias = alias void (...), bitcast (void ()* @linkoncefunc to void (...)*) 21; PROMOTE-DAG: @linkoncefuncWeakAlias = weak alias void (...), bitcast (void ()* @linkoncefunc to void (...)*) 22; PROMOTE-DAG: @linkoncefuncLinkonceAlias = weak alias void (...), bitcast (void ()* @linkoncefunc to void (...)*) 23; PROMOTE-DAG: @linkoncefuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @linkoncefunc to void (...)*) 24; PROMOTE-DAG: @linkoncefuncLinkonceODRAlias = weak_odr alias void (...), bitcast (void ()* @linkoncefunc to void (...)*) 25; PROMOTE-DAG: @weakfuncAlias = alias void (...), bitcast (void ()* @weakfunc to void (...)*) 26; PROMOTE-DAG: @weakfuncWeakAlias = weak alias void (...), bitcast (void ()* @weakfunc to void (...)*) 27; PROMOTE-DAG: @weakfuncLinkonceAlias = weak alias void (...), bitcast (void ()* @weakfunc to void (...)*) 28; PROMOTE-DAG: @weakfuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @weakfunc to void (...)*) 29; PROMOTE-DAG: @weakfuncLinkonceODRAlias = weak_odr alias void (...), bitcast (void ()* @weakfunc to void (...)*) 30; PROMOTE-DAG: @weakODRfuncAlias = alias void (...), bitcast (void ()* @weakODRfunc to void (...)*) 31; PROMOTE-DAG: @weakODRfuncWeakAlias = weak alias void (...), bitcast (void ()* @weakODRfunc to void (...)*) 32; PROMOTE-DAG: @weakODRfuncLinkonceAlias = weak alias void (...), bitcast (void ()* @weakODRfunc to void (...)*) 33; PROMOTE-DAG: @weakODRfuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @weakODRfunc to void (...)*) 34; PROMOTE-DAG: @weakODRfuncLinkonceODRAlias = weak_odr alias void (...), bitcast (void ()* @weakODRfunc to void (...)*) 35; PROMOTE-DAG: @linkonceODRfuncAlias = alias void (...), bitcast (void ()* @linkonceODRfunc to void (...)*) 36; PROMOTE-DAG: @linkonceODRfuncWeakAlias = weak alias void (...), bitcast (void ()* @linkonceODRfunc to void (...)*) 37; PROMOTE-DAG: @linkonceODRfuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @linkonceODRfunc to void (...)*) 38; PROMOTE-DAG: @linkonceODRfuncLinkonceAlias = weak alias void (...), bitcast (void ()* @linkonceODRfunc to void (...)*) 39; PROMOTE-DAG: @linkonceODRfuncLinkonceODRAlias = weak_odr alias void (...), bitcast (void ()* @linkonceODRfunc to void (...)*) 40 41; PROMOTE-DAG: define hidden void @globalfunc() 42; PROMOTE-DAG: define internal void @internalfunc() 43; PROMOTE-DAG: define weak_odr void @linkonceODRfunc() 44; PROMOTE-DAG: define weak_odr void @weakODRfunc() 45; PROMOTE-DAG: define weak void @linkoncefunc() 46; PROMOTE-DAG: define weak void @weakfunc() 47 48; On the import side now, verify that aliases are imported unless they 49; are preemptible (non-ODR weak/linkonce). 50; IMPORT-DAG: declare void @linkonceODRfuncWeakAlias 51; IMPORT-DAG: declare void @linkonceODRfuncLinkonceAlias 52; IMPORT-DAG: define available_externally void @linkonceODRfuncAlias 53; IMPORT-DAG: define available_externally void @linkonceODRfuncWeakODRAlias 54; IMPORT-DAG: define available_externally void @linkonceODRfuncLinkonceODRAlias 55; IMPORT-DAG: define available_externally dso_local void @globalfuncAlias() 56; IMPORT-DAG: declare void @globalfuncWeakAlias() 57; IMPORT-DAG: declare void @globalfuncLinkonceAlias() 58; IMPORT-DAG: define available_externally dso_local void @globalfuncWeakODRAlias() 59; IMPORT-DAG: define available_externally dso_local void @globalfuncLinkonceODRAlias() 60; IMPORT-DAG: define available_externally dso_local void @internalfuncAlias() 61; IMPORT-DAG: declare void @internalfuncWeakAlias() 62; IMPORT-DAG: declare void @internalfuncLinkonceAlias() 63; IMPORT-DAG: define available_externally dso_local void @internalfuncWeakODRAlias() 64; IMPORT-DAG: define available_externally dso_local void @internalfuncLinkonceODRAlias() 65; IMPORT-DAG: define available_externally void @weakODRfuncAlias() 66; IMPORT-DAG: declare void @weakODRfuncWeakAlias() 67; IMPORT-DAG: declare void @weakODRfuncLinkonceAlias() 68; IMPORT-DAG: define available_externally void @weakODRfuncWeakODRAlias() 69; IMPORT-DAG: define available_externally void @weakODRfuncLinkonceODRAlias() 70; IMPORT-DAG: define available_externally void @linkoncefuncAlias() 71; IMPORT-DAG: declare void @linkoncefuncWeakAlias() 72; IMPORT-DAG: declare void @linkoncefuncLinkonceAlias() 73; IMPORT-DAG: define available_externally void @linkoncefuncWeakODRAlias() 74; IMPORT-DAG: define available_externally void @linkoncefuncLinkonceODRAlias() 75; IMPORT-DAG: define available_externally void @weakfuncAlias() 76; IMPORT-DAG: declare void @weakfuncWeakAlias() 77; IMPORT-DAG: declare void @weakfuncLinkonceAlias() 78; IMPORT-DAG: define available_externally void @weakfuncWeakODRAlias() 79; IMPORT-DAG: define available_externally void @weakfuncLinkonceODRAlias() 80; IMPORT-DAG: define available_externally void @linkonceODRfuncAlias() 81; IMPORT-DAG: declare void @linkonceODRfuncWeakAlias() 82; IMPORT-DAG: define available_externally void @linkonceODRfuncWeakODRAlias() 83; IMPORT-DAG: declare void @linkonceODRfuncLinkonceAlias() 84; IMPORT-DAG: define available_externally void @linkonceODRfuncLinkonceODRAlias() 85 86target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 87 88define i32 @main() #0 { 89entry: 90 call void @globalfuncAlias() 91 call void @globalfuncWeakAlias() 92 call void @globalfuncLinkonceAlias() 93 call void @globalfuncWeakODRAlias() 94 call void @globalfuncLinkonceODRAlias() 95 96 call void @internalfuncAlias() 97 call void @internalfuncWeakAlias() 98 call void @internalfuncLinkonceAlias() 99 call void @internalfuncWeakODRAlias() 100 call void @internalfuncLinkonceODRAlias() 101 call void @linkonceODRfuncAlias() 102 call void @linkonceODRfuncWeakAlias() 103 call void @linkonceODRfuncLinkonceAlias() 104 call void @linkonceODRfuncWeakODRAlias() 105 call void @linkonceODRfuncLinkonceODRAlias() 106 107 call void @weakODRfuncAlias() 108 call void @weakODRfuncWeakAlias() 109 call void @weakODRfuncLinkonceAlias() 110 call void @weakODRfuncWeakODRAlias() 111 call void @weakODRfuncLinkonceODRAlias() 112 113 call void @linkoncefuncAlias() 114 call void @linkoncefuncWeakAlias() 115 call void @linkoncefuncLinkonceAlias() 116 call void @linkoncefuncWeakODRAlias() 117 call void @linkoncefuncLinkonceODRAlias() 118 119 call void @weakfuncAlias() 120 call void @weakfuncWeakAlias() 121 call void @weakfuncLinkonceAlias() 122 call void @weakfuncWeakODRAlias() 123 call void @weakfuncLinkonceODRAlias() 124 125 ret i32 0 126} 127 128 129declare void @globalfuncAlias() 130declare void @globalfuncWeakAlias() 131declare void @globalfuncLinkonceAlias() 132declare void @globalfuncWeakODRAlias() 133declare void @globalfuncLinkonceODRAlias() 134 135declare void @internalfuncAlias() 136declare void @internalfuncWeakAlias() 137declare void @internalfuncLinkonceAlias() 138declare void @internalfuncWeakODRAlias() 139declare void @internalfuncLinkonceODRAlias() 140 141declare void @linkonceODRfuncAlias() 142declare void @linkonceODRfuncWeakAlias() 143declare void @linkonceODRfuncLinkonceAlias() 144declare void @linkonceODRfuncWeakODRAlias() 145declare void @linkonceODRfuncLinkonceODRAlias() 146 147declare void @weakODRfuncAlias() 148declare void @weakODRfuncWeakAlias() 149declare void @weakODRfuncLinkonceAlias() 150declare void @weakODRfuncWeakODRAlias() 151declare void @weakODRfuncLinkonceODRAlias() 152 153declare void @linkoncefuncAlias() 154declare void @linkoncefuncWeakAlias() 155declare void @linkoncefuncLinkonceAlias() 156declare void @linkoncefuncWeakODRAlias() 157declare void @linkoncefuncLinkonceODRAlias() 158 159declare void @weakfuncAlias() 160declare void @weakfuncWeakAlias() 161declare void @weakfuncLinkonceAlias() 162declare void @weakfuncWeakODRAlias() 163declare void @weakfuncLinkonceODRAlias() 164 165 166