Skip to content

Commit dfe5970

Browse files
Look at the Prevailing bit as opposed to ExportDynamic bit, update
regression test
1 parent 6be4464 commit dfe5970

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

llvm/lib/LTO/LTO.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ Error LTO::runRegularLTO(AddStreamFn AddStream) {
13151315
auto IsVisibleToRegularObj = [&](StringRef name) {
13161316
auto It = GlobalResolutions->find(name);
13171317
return (It == GlobalResolutions->end() ||
1318-
It->second.VisibleOutsideSummary || It->second.ExportDynamic);
1318+
It->second.VisibleOutsideSummary || !It->second.Prevailing);
13191319
};
13201320

13211321
// If allowed, upgrade public vcall visibility metadata to linkage unit
@@ -1906,7 +1906,7 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
19061906
auto IsVisibleToRegularObj = [&](StringRef name) {
19071907
auto It = GlobalResolutions->find(name);
19081908
return (It == GlobalResolutions->end() ||
1909-
It->second.VisibleOutsideSummary || It->second.ExportDynamic);
1909+
It->second.VisibleOutsideSummary || !It->second.Prevailing);
19101910
};
19111911

19121912
getVisibleToRegularObjVtableGUIDs(ThinLTO.CombinedIndex,

llvm/test/ThinLTO/X86/nodevirt_export_dynamic.ll renamed to llvm/test/ThinLTO/X86/devirt_prevailing.ll

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
; RUN: rm -rf %t && mkdir %t && cd %t
22

3-
; Tests that devirtualization is suppressed on a class when its compatible
4-
; class could be referenced from dynamic linker that is not visible to the
5-
; linker.
3+
; Tests that devirtualization is suppressed on a class when the LTO unit doesn't
4+
; have the prevailing definition of the class.
65

76
; Generate unsplit module with summary for ThinLTO index-based WPD.
87
; RUN: opt -thinlto-bc -o summary.o %s
98

109
; Index based WPD
11-
; For `_ZTI7Derived`, the 'llvm-lto2' resolution arguments specifies `VisibleOutsideSummary` as false
12-
; and `ExportDynamic` as false. The callsite inside @_ZN4Base8dispatchEv
13-
; got devirtualized.
10+
; The callsite inside @_ZN4Base8dispatchEv gets devirtualized when symbol
11+
; resolution shows there is a prevailing definition of `_ZTI7Derived` in the
12+
; LTO unit.
1413
; RUN: llvm-lto2 run summary.o -save-temps -pass-remarks=. \
14+
; RUN: -thinlto-threads=1 \
1515
; RUN: -o tmp \
1616
; RUN: --whole-program-visibility-enabled-in-lto=true \
1717
; RUN: --validate-all-vtables-have-type-infos=true \
@@ -24,15 +24,16 @@
2424
; RUN: -r=summary.o,_ZTV8DerivedN,p \
2525
; RUN: -r=summary.o,_ZTI8DerivedN,p \
2626
; RUN: -r=summary.o,_ZTS8DerivedN,p \
27-
; RUN: -r=summary.o,_ZTI7Derived, \
27+
; RUN: -r=summary.o,_ZTI7Derived,p \
2828
; RUN: 2>&1 | FileCheck --allow-empty %s --check-prefix=REMARK
2929

3030

3131
; Index based WPD
32-
; For `_ZTI7Derived`, the 'llvm-lto2' resolution arguments specifies `VisibleOutsideSummary` as false
33-
; and `ExportDynamic` as true. The callsite inside @_ZN4Base8dispatchEv won't
34-
; get devirtualized.
32+
; The callsite inside @_ZN4Base8dispatchEv remains indirect and not de-virtualized
33+
; when symbol resolution shows there isn't a prevailing definition of
34+
; `_ZTI7Derived` in the LTO unit.
3535
; RUN: llvm-lto2 run summary.o -save-temps -pass-remarks=. \
36+
; RUN: -thinlto-threads=1 \
3637
; RUN: -o tmp \
3738
; RUN: --whole-program-visibility-enabled-in-lto=true \
3839
; RUN: --validate-all-vtables-have-type-infos=true \
@@ -45,13 +46,14 @@
4546
; RUN: -r=summary.o,_ZTV8DerivedN,p \
4647
; RUN: -r=summary.o,_ZTI8DerivedN,p \
4748
; RUN: -r=summary.o,_ZTS8DerivedN,p \
48-
; RUN: -r=summary.o,_ZTI7Derived,d \
49+
; RUN: -r=summary.o,_ZTI7Derived, \
4950
; RUN: 2>&1 | FileCheck %s --allow-empty --implicit-check-not='single-impl: devirtualized a call to'
5051

51-
52-
; Hybrid LTO WPD
52+
; Repeat the above tests for WPD in hybrid LTO.
5353
; RUN: opt --thinlto-bc --thinlto-split-lto-unit -o hybrid.o %s
54+
5455
; RUN: llvm-lto2 run hybrid.o -save-temps -pass-remarks=. \
56+
; RUN: -thinlto-threads=1 \
5557
; RUN: -o hybrid \
5658
; RUN: --whole-program-visibility-enabled-in-lto=true \
5759
; RUN: --validate-all-vtables-have-type-infos=true \
@@ -61,17 +63,18 @@
6163
; RUN: -r=hybrid.o,_ZN4Base8dispatchEv,px \
6264
; RUN: -r=hybrid.o,_ZN7DerivedC2Ev, \
6365
; RUN: -r=hybrid.o,_ZN8DerivedN5printEv,px \
64-
; RUN: -r=hybrid.o,_ZTV8DerivedN,p \
65-
; RUN: -r=hybrid.o,_ZTI8DerivedN,p \
66+
; RUN: -r=hybrid.o,_ZTV8DerivedN, \
67+
; RUN: -r=hybrid.o,_ZTI8DerivedN, \
6668
; RUN: -r=hybrid.o,_ZTS8DerivedN,p \
67-
; RUN: -r=hybrid.o,_ZTI7Derived, \
68-
; RUN: -r=hybrid.o,_ZN8DerivedN5printEv,px \
69+
; RUN: -r=hybrid.o,_ZTI7Derived,p \
70+
; RUN: -r=hybrid.o,_ZN8DerivedN5printEv, \
6971
; RUN: -r=hybrid.o,_ZTV8DerivedN,p \
7072
; RUN: -r=hybrid.o,_ZTI8DerivedN,p \
7173
; RUN: 2>&1 | FileCheck --allow-empty %s --check-prefix=REMARK
7274

73-
; Hybrid LTO WPD
75+
7476
; RUN: llvm-lto2 run hybrid.o -save-temps -pass-remarks=. \
77+
; RUN: -thinlto-threads=1 \
7578
; RUN: -o hybrid \
7679
; RUN: --whole-program-visibility-enabled-in-lto=true \
7780
; RUN: --validate-all-vtables-have-type-infos=true \
@@ -81,11 +84,11 @@
8184
; RUN: -r=hybrid.o,_ZN4Base8dispatchEv,px \
8285
; RUN: -r=hybrid.o,_ZN7DerivedC2Ev, \
8386
; RUN: -r=hybrid.o,_ZN8DerivedN5printEv,px \
84-
; RUN: -r=hybrid.o,_ZTV8DerivedN,p \
85-
; RUN: -r=hybrid.o,_ZTI8DerivedN,p \
87+
; RUN: -r=hybrid.o,_ZTV8DerivedN, \
88+
; RUN: -r=hybrid.o,_ZTI8DerivedN, \
8689
; RUN: -r=hybrid.o,_ZTS8DerivedN,p \
87-
; RUN: -r=hybrid.o,_ZTI7Derived,d \
88-
; RUN: -r=hybrid.o,_ZN8DerivedN5printEv,px \
90+
; RUN: -r=hybrid.o,_ZTI7Derived, \
91+
; RUN: -r=hybrid.o,_ZN8DerivedN5printEv, \
8992
; RUN: -r=hybrid.o,_ZTV8DerivedN,p \
9093
; RUN: -r=hybrid.o,_ZTI8DerivedN,p \
9194
; RUN: 2>&1 | FileCheck --allow-empty %s --implicit-check-not='single-impl: devirtualized a call to'

llvm/tools/llvm-lto2/llvm-lto2.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ static int run(int argc, char **argv) {
269269
Res.VisibleToRegularObj = true;
270270
else if (C == 'r')
271271
Res.LinkerRedefined = true;
272-
else if (C == 'd')
273-
Res.ExportDynamic = true;
274272
else {
275273
llvm::errs() << "invalid character " << C << " in resolution: " << R
276274
<< '\n';

0 commit comments

Comments
 (0)