Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 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 |
Joel E. Denny | 9fa9c93 | 2018-07-11 20:25:49 +0000 | [diff] [blame] | 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 |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 6 | |
Teresa Johnson | 81bbf74 | 2017-12-16 00:18:12 +0000 | [diff] [blame] | 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. |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 10 | ; PROMOTE-DAG: @globalfuncAlias = alias void (...), bitcast (void ()* @globalfunc to void (...)*) |
| 11 | ; PROMOTE-DAG: @globalfuncWeakAlias = weak alias void (...), bitcast (void ()* @globalfunc to void (...)*) |
Peter Collingbourne | 73589f3 | 2016-07-07 18:31:51 +0000 | [diff] [blame] | 12 | ; PROMOTE-DAG: @globalfuncLinkonceAlias = weak alias void (...), bitcast (void ()* @globalfunc to void (...)*) |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 13 | ; PROMOTE-DAG: @globalfuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @globalfunc to void (...)*) |
Peter Collingbourne | 73589f3 | 2016-07-07 18:31:51 +0000 | [diff] [blame] | 14 | ; PROMOTE-DAG: @globalfuncLinkonceODRAlias = weak_odr alias void (...), bitcast (void ()* @globalfunc to void (...)*) |
Teresa Johnson | 4fef68c | 2016-11-14 19:21:41 +0000 | [diff] [blame] | 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 (...)*) |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 20 | ; PROMOTE-DAG: @linkoncefuncAlias = alias void (...), bitcast (void ()* @linkoncefunc to void (...)*) |
| 21 | ; PROMOTE-DAG: @linkoncefuncWeakAlias = weak alias void (...), bitcast (void ()* @linkoncefunc to void (...)*) |
Peter Collingbourne | 73589f3 | 2016-07-07 18:31:51 +0000 | [diff] [blame] | 22 | ; PROMOTE-DAG: @linkoncefuncLinkonceAlias = weak alias void (...), bitcast (void ()* @linkoncefunc to void (...)*) |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 23 | ; PROMOTE-DAG: @linkoncefuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @linkoncefunc to void (...)*) |
Peter Collingbourne | 73589f3 | 2016-07-07 18:31:51 +0000 | [diff] [blame] | 24 | ; PROMOTE-DAG: @linkoncefuncLinkonceODRAlias = weak_odr alias void (...), bitcast (void ()* @linkoncefunc to void (...)*) |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 25 | ; PROMOTE-DAG: @weakfuncAlias = alias void (...), bitcast (void ()* @weakfunc to void (...)*) |
| 26 | ; PROMOTE-DAG: @weakfuncWeakAlias = weak alias void (...), bitcast (void ()* @weakfunc to void (...)*) |
Peter Collingbourne | 73589f3 | 2016-07-07 18:31:51 +0000 | [diff] [blame] | 27 | ; PROMOTE-DAG: @weakfuncLinkonceAlias = weak alias void (...), bitcast (void ()* @weakfunc to void (...)*) |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 28 | ; PROMOTE-DAG: @weakfuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @weakfunc to void (...)*) |
Peter Collingbourne | 73589f3 | 2016-07-07 18:31:51 +0000 | [diff] [blame] | 29 | ; PROMOTE-DAG: @weakfuncLinkonceODRAlias = weak_odr alias void (...), bitcast (void ()* @weakfunc to void (...)*) |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 30 | ; PROMOTE-DAG: @weakODRfuncAlias = alias void (...), bitcast (void ()* @weakODRfunc to void (...)*) |
| 31 | ; PROMOTE-DAG: @weakODRfuncWeakAlias = weak alias void (...), bitcast (void ()* @weakODRfunc to void (...)*) |
Peter Collingbourne | 73589f3 | 2016-07-07 18:31:51 +0000 | [diff] [blame] | 32 | ; PROMOTE-DAG: @weakODRfuncLinkonceAlias = weak alias void (...), bitcast (void ()* @weakODRfunc to void (...)*) |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 33 | ; PROMOTE-DAG: @weakODRfuncWeakODRAlias = weak_odr alias void (...), bitcast (void ()* @weakODRfunc to void (...)*) |
Peter Collingbourne | 73589f3 | 2016-07-07 18:31:51 +0000 | [diff] [blame] | 34 | ; PROMOTE-DAG: @weakODRfuncLinkonceODRAlias = weak_odr alias void (...), bitcast (void ()* @weakODRfunc to void (...)*) |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 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 (...)*) |
Peter Collingbourne | 73589f3 | 2016-07-07 18:31:51 +0000 | [diff] [blame] | 38 | ; PROMOTE-DAG: @linkonceODRfuncLinkonceAlias = weak alias void (...), bitcast (void ()* @linkonceODRfunc to void (...)*) |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 39 | ; PROMOTE-DAG: @linkonceODRfuncLinkonceODRAlias = weak_odr alias void (...), bitcast (void ()* @linkonceODRfunc to void (...)*) |
| 40 | |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 41 | ; PROMOTE-DAG: define void @globalfunc() |
Teresa Johnson | 4fef68c | 2016-11-14 19:21:41 +0000 | [diff] [blame] | 42 | ; PROMOTE-DAG: define internal void @internalfunc() |
Teresa Johnson | 3bc8abd | 2016-10-30 05:15:23 +0000 | [diff] [blame] | 43 | ; PROMOTE-DAG: define weak_odr void @linkonceODRfunc() |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 44 | ; PROMOTE-DAG: define weak_odr void @weakODRfunc() |
Teresa Johnson | 3bc8abd | 2016-10-30 05:15:23 +0000 | [diff] [blame] | 45 | ; PROMOTE-DAG: define weak void @linkoncefunc() |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 46 | ; PROMOTE-DAG: define weak void @weakfunc() |
| 47 | |
Teresa Johnson | 81bbf74 | 2017-12-16 00:18:12 +0000 | [diff] [blame] | 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 void @globalfuncAlias() |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 56 | ; IMPORT-DAG: declare void @globalfuncWeakAlias() |
| 57 | ; IMPORT-DAG: declare void @globalfuncLinkonceAlias() |
Teresa Johnson | 81bbf74 | 2017-12-16 00:18:12 +0000 | [diff] [blame] | 58 | ; IMPORT-DAG: define available_externally void @globalfuncWeakODRAlias() |
| 59 | ; IMPORT-DAG: define available_externally void @globalfuncLinkonceODRAlias() |
Rafael Espindola | e4b0231 | 2018-01-11 22:15:05 +0000 | [diff] [blame] | 60 | ; IMPORT-DAG: define available_externally dso_local void @internalfuncAlias() |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 61 | ; IMPORT-DAG: declare void @internalfuncWeakAlias() |
| 62 | ; IMPORT-DAG: declare void @internalfuncLinkonceAlias() |
Rafael Espindola | e4b0231 | 2018-01-11 22:15:05 +0000 | [diff] [blame] | 63 | ; IMPORT-DAG: define available_externally dso_local void @internalfuncWeakODRAlias() |
| 64 | ; IMPORT-DAG: define available_externally dso_local void @internalfuncLinkonceODRAlias() |
Teresa Johnson | 81bbf74 | 2017-12-16 00:18:12 +0000 | [diff] [blame] | 65 | ; IMPORT-DAG: define available_externally void @weakODRfuncAlias() |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 66 | ; IMPORT-DAG: declare void @weakODRfuncWeakAlias() |
| 67 | ; IMPORT-DAG: declare void @weakODRfuncLinkonceAlias() |
Teresa Johnson | 81bbf74 | 2017-12-16 00:18:12 +0000 | [diff] [blame] | 68 | ; IMPORT-DAG: define available_externally void @weakODRfuncWeakODRAlias() |
| 69 | ; IMPORT-DAG: define available_externally void @weakODRfuncLinkonceODRAlias() |
| 70 | ; IMPORT-DAG: define available_externally void @linkoncefuncAlias() |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 71 | ; IMPORT-DAG: declare void @linkoncefuncWeakAlias() |
| 72 | ; IMPORT-DAG: declare void @linkoncefuncLinkonceAlias() |
Teresa Johnson | 81bbf74 | 2017-12-16 00:18:12 +0000 | [diff] [blame] | 73 | ; IMPORT-DAG: define available_externally void @linkoncefuncWeakODRAlias() |
| 74 | ; IMPORT-DAG: define available_externally void @linkoncefuncLinkonceODRAlias() |
| 75 | ; IMPORT-DAG: define available_externally void @weakfuncAlias() |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 76 | ; IMPORT-DAG: declare void @weakfuncWeakAlias() |
| 77 | ; IMPORT-DAG: declare void @weakfuncLinkonceAlias() |
Teresa Johnson | 81bbf74 | 2017-12-16 00:18:12 +0000 | [diff] [blame] | 78 | ; IMPORT-DAG: define available_externally void @weakfuncWeakODRAlias() |
| 79 | ; IMPORT-DAG: define available_externally void @weakfuncLinkonceODRAlias() |
| 80 | ; IMPORT-DAG: define available_externally void @linkonceODRfuncAlias() |
David Blaikie | 2f0cc47 | 2017-07-27 15:09:06 +0000 | [diff] [blame] | 81 | ; IMPORT-DAG: declare void @linkonceODRfuncWeakAlias() |
Teresa Johnson | 81bbf74 | 2017-12-16 00:18:12 +0000 | [diff] [blame] | 82 | ; IMPORT-DAG: define available_externally void @linkonceODRfuncWeakODRAlias() |
David Blaikie | 2f0cc47 | 2017-07-27 15:09:06 +0000 | [diff] [blame] | 83 | ; IMPORT-DAG: declare void @linkonceODRfuncLinkonceAlias() |
Teresa Johnson | 81bbf74 | 2017-12-16 00:18:12 +0000 | [diff] [blame] | 84 | ; IMPORT-DAG: define available_externally void @linkonceODRfuncLinkonceODRAlias() |
Mehdi Amini | a71a5a6 | 2016-04-21 05:47:17 +0000 | [diff] [blame] | 85 | |
| 86 | define i32 @main() #0 { |
| 87 | entry: |
| 88 | call void @globalfuncAlias() |
| 89 | call void @globalfuncWeakAlias() |
| 90 | call void @globalfuncLinkonceAlias() |
| 91 | call void @globalfuncWeakODRAlias() |
| 92 | call void @globalfuncLinkonceODRAlias() |
| 93 | |
| 94 | call void @internalfuncAlias() |
| 95 | call void @internalfuncWeakAlias() |
| 96 | call void @internalfuncLinkonceAlias() |
| 97 | call void @internalfuncWeakODRAlias() |
| 98 | call void @internalfuncLinkonceODRAlias() |
| 99 | call void @linkonceODRfuncAlias() |
| 100 | call void @linkonceODRfuncWeakAlias() |
| 101 | call void @linkonceODRfuncLinkonceAlias() |
| 102 | call void @linkonceODRfuncWeakODRAlias() |
| 103 | call void @linkonceODRfuncLinkonceODRAlias() |
| 104 | |
| 105 | call void @weakODRfuncAlias() |
| 106 | call void @weakODRfuncWeakAlias() |
| 107 | call void @weakODRfuncLinkonceAlias() |
| 108 | call void @weakODRfuncWeakODRAlias() |
| 109 | call void @weakODRfuncLinkonceODRAlias() |
| 110 | |
| 111 | call void @linkoncefuncAlias() |
| 112 | call void @linkoncefuncWeakAlias() |
| 113 | call void @linkoncefuncLinkonceAlias() |
| 114 | call void @linkoncefuncWeakODRAlias() |
| 115 | call void @linkoncefuncLinkonceODRAlias() |
| 116 | |
| 117 | call void @weakfuncAlias() |
| 118 | call void @weakfuncWeakAlias() |
| 119 | call void @weakfuncLinkonceAlias() |
| 120 | call void @weakfuncWeakODRAlias() |
| 121 | call void @weakfuncLinkonceODRAlias() |
| 122 | |
| 123 | ret i32 0 |
| 124 | } |
| 125 | |
| 126 | |
| 127 | declare void @globalfuncAlias() |
| 128 | declare void @globalfuncWeakAlias() |
| 129 | declare void @globalfuncLinkonceAlias() |
| 130 | declare void @globalfuncWeakODRAlias() |
| 131 | declare void @globalfuncLinkonceODRAlias() |
| 132 | |
| 133 | declare void @internalfuncAlias() |
| 134 | declare void @internalfuncWeakAlias() |
| 135 | declare void @internalfuncLinkonceAlias() |
| 136 | declare void @internalfuncWeakODRAlias() |
| 137 | declare void @internalfuncLinkonceODRAlias() |
| 138 | |
| 139 | declare void @linkonceODRfuncAlias() |
| 140 | declare void @linkonceODRfuncWeakAlias() |
| 141 | declare void @linkonceODRfuncLinkonceAlias() |
| 142 | declare void @linkonceODRfuncWeakODRAlias() |
| 143 | declare void @linkonceODRfuncLinkonceODRAlias() |
| 144 | |
| 145 | declare void @weakODRfuncAlias() |
| 146 | declare void @weakODRfuncWeakAlias() |
| 147 | declare void @weakODRfuncLinkonceAlias() |
| 148 | declare void @weakODRfuncWeakODRAlias() |
| 149 | declare void @weakODRfuncLinkonceODRAlias() |
| 150 | |
| 151 | declare void @linkoncefuncAlias() |
| 152 | declare void @linkoncefuncWeakAlias() |
| 153 | declare void @linkoncefuncLinkonceAlias() |
| 154 | declare void @linkoncefuncWeakODRAlias() |
| 155 | declare void @linkoncefuncLinkonceODRAlias() |
| 156 | |
| 157 | declare void @weakfuncAlias() |
| 158 | declare void @weakfuncWeakAlias() |
| 159 | declare void @weakfuncLinkonceAlias() |
| 160 | declare void @weakfuncWeakODRAlias() |
| 161 | declare void @weakfuncLinkonceODRAlias() |
| 162 | |
| 163 | |