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
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
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 (...)*)
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()
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()
86 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
88 define i32 @main() #0 {
90 call void @globalfuncAlias()
91 call void @globalfuncWeakAlias()
92 call void @globalfuncLinkonceAlias()
93 call void @globalfuncWeakODRAlias()
94 call void @globalfuncLinkonceODRAlias()
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()
107 call void @weakODRfuncAlias()
108 call void @weakODRfuncWeakAlias()
109 call void @weakODRfuncLinkonceAlias()
110 call void @weakODRfuncWeakODRAlias()
111 call void @weakODRfuncLinkonceODRAlias()
113 call void @linkoncefuncAlias()
114 call void @linkoncefuncWeakAlias()
115 call void @linkoncefuncLinkonceAlias()
116 call void @linkoncefuncWeakODRAlias()
117 call void @linkoncefuncLinkonceODRAlias()
119 call void @weakfuncAlias()
120 call void @weakfuncWeakAlias()
121 call void @weakfuncLinkonceAlias()
122 call void @weakfuncWeakODRAlias()
123 call void @weakfuncLinkonceODRAlias()
129 declare void @globalfuncAlias()
130 declare void @globalfuncWeakAlias()
131 declare void @globalfuncLinkonceAlias()
132 declare void @globalfuncWeakODRAlias()
133 declare void @globalfuncLinkonceODRAlias()
135 declare void @internalfuncAlias()
136 declare void @internalfuncWeakAlias()
137 declare void @internalfuncLinkonceAlias()
138 declare void @internalfuncWeakODRAlias()
139 declare void @internalfuncLinkonceODRAlias()
141 declare void @linkonceODRfuncAlias()
142 declare void @linkonceODRfuncWeakAlias()
143 declare void @linkonceODRfuncLinkonceAlias()
144 declare void @linkonceODRfuncWeakODRAlias()
145 declare void @linkonceODRfuncLinkonceODRAlias()
147 declare void @weakODRfuncAlias()
148 declare void @weakODRfuncWeakAlias()
149 declare void @weakODRfuncLinkonceAlias()
150 declare void @weakODRfuncWeakODRAlias()
151 declare void @weakODRfuncLinkonceODRAlias()
153 declare void @linkoncefuncAlias()
154 declare void @linkoncefuncWeakAlias()
155 declare void @linkoncefuncLinkonceAlias()
156 declare void @linkoncefuncWeakODRAlias()
157 declare void @linkoncefuncLinkonceODRAlias()
159 declare void @weakfuncAlias()
160 declare void @weakfuncWeakAlias()
161 declare void @weakfuncLinkonceAlias()
162 declare void @weakfuncWeakODRAlias()
163 declare void @weakfuncLinkonceODRAlias()