llvm.org GIT mirror llvm / 978b6cf
[ThinLTO] Scan all variants of vague symbol for reachability. Summary: Alias can make one (but not all) live, we still need to scan all others if this symbol is reachable from somewhere else. Reviewers: tejohnson, grimar Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D56117 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350269 91177308-0d34-0410-b5e6-96231b3b80d8 Xin Tong 8 months ago
3 changed file(s) with 49 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
776776 VI = updateValueInfoForIndirectCalls(Index, VI);
777777 if (!VI)
778778 return;
779 for (auto &S : VI.getSummaryList())
780 if (S->isLive())
781 return;
779
780 // We need to make sure all variants of the symbol are scanned, alias can
781 // make one (but not all) alive.
782 if (llvm::all_of(VI.getSummaryList(),
783 [](const std::unique_ptr &S) {
784 return S->isLive();
785 }))
786 return;
782787
783788 // We only keep live symbols that are known to be non-prevailing if any are
784789 // available_externally, linkonceodr, weakodr. Those symbols are discarded
1919 call void @dead_func()
2020 ret void
2121 }
22
23 define linkonce_odr void @linkonceodrfuncwithalias() {
24 entry:
25 ret void
26 }
1919 ; RUN: -r %t1.bc,_live_available_externally_func,l \
2020 ; RUN: -r %t1.bc,_live_linkonce_odr_func,l \
2121 ; RUN: -r %t1.bc,_live_weak_odr_func,l \
22 ; RUN: -r %t1.bc,_linkonceodralias,pl \
23 ; RUN: -r %t1.bc,_linkonceodrfuncwithalias,l \
24 ; RUN: -r %t1.bc,_linkonceodrfuncwithalias_caller,pl \
2225 ; RUN: -r %t2.bc,_baz,pl \
2326 ; RUN: -r %t2.bc,_boo,pl \
2427 ; RUN: -r %t2.bc,_dead_func,l \
2528 ; RUN: -r %t2.bc,_another_dead_func,pl \
29 ; RUN: -r %t2.bc,_linkonceodrfuncwithalias,pl \
2630 ; RUN: -thinlto-threads=1 \
2731 ; RUN: -debug-only=function-import 2>&1 | FileCheck %s --check-prefix=DEBUG --check-prefix=STATS
2832 ; RUN: llvm-dis < %t.out.1.3.import.bc | FileCheck %s --check-prefix=LTO2
7074 ; llvm.global_ctors
7175 ; CHECK2: define void @boo()
7276 ; LTO2-CHECK2: define dso_local void @boo()
77
78 ; Make sure we keep @linkonceodrfuncwithalias in Input/deadstrip.ll alive as it
79 ; is reachable from @main.
80 ; LTO2-CHECK2: define weak_odr dso_local void @linkonceodrfuncwithalias() {
81
7382 ; We should have eventually removed @baz since it was internalized and unused
7483 ; CHECK2-NM-NOT: _baz
7584
104113 ; RUN: -r %t1.bc,_live_available_externally_func,l \
105114 ; RUN: -r %t1.bc,_live_linkonce_odr_func,l \
106115 ; RUN: -r %t1.bc,_live_weak_odr_func,l \
116 ; RUN: -r %t1.bc,_linkonceodralias,pl \
117 ; RUN: -r %t1.bc,_linkonceodrfuncwithalias,l \
118 ; RUN: -r %t1.bc,_linkonceodrfuncwithalias_caller,pl \
107119 ; RUN: -r %t3.bc,_baz,pl \
108120 ; RUN: -r %t3.bc,_boo,pl \
109121 ; RUN: -r %t3.bc,_dead_func,l \
110 ; RUN: -r %t3.bc,_another_dead_func,pl
122 ; RUN: -r %t3.bc,_another_dead_func,pl \
123 ; RUN: -r %t3.bc,_linkonceodrfuncwithalias,pl
111124 ; RUN: llvm-dis < %t4.out.1.3.import.bc | FileCheck %s --check-prefix=CHECK-NOTDEAD
112125 ; RUN: llvm-nm %t4.out.0 | FileCheck %s --check-prefix=CHECK-NM-NOTDEAD
113126
162175 ret void
163176 }
164177
178 ; This alias will set its base object in this file (linkonceodrfuncwithalias)
179 ; alive.
180 ; We want to make sure the @linkonceodrfuncwithalias copy in Input/deadstrip.ll
181 ; is also scanned when computing reachability.
182 @linkonceodralias = linkonce_odr alias void (), void ()* @linkonceodrfuncwithalias
183
184 define linkonce_odr void @linkonceodrfuncwithalias() {
185 entry:
186 ret void
187 }
188
189 define void @linkonceodrfuncwithalias_caller() {
190 entry:
191 call void @linkonceodrfuncwithalias()
192 ret void
193 }
194
195
165196 define void @main() {
166197 call void @bar()
167198 call void @bar_internal()
168199 call void @live_linkonce_odr_func()
169200 call void @live_weak_odr_func()
170201 call void @live_available_externally_func()
171 ret void
172 }
202 call void @linkonceodrfuncwithalias_caller()
203 call void @linkonceodralias()
204 ret void
205 }