|
1 | 1 | ; RUN: rm -rf %t && mkdir %t && cd %t |
2 | 2 |
|
| 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. |
| 6 | + |
3 | 7 | ; Generate unsplit module with summary for ThinLTO index-based WPD. |
4 | 8 | ; RUN: opt -thinlto-bc -o summary.o %s |
5 | 9 |
|
6 | | -; RUN: llvm-dis -o - summary.o |
7 | | - |
8 | | -;; TODO: Implement the fix for WPD in regular or hybrid LTO, and add test coverage. |
9 | | - |
10 | 10 | ; Index based WPD |
11 | 11 | ; For `_ZTI7Derived`, the 'llvm-lto2' resolution arguments specifies `VisibleOutsideSummary` as false |
12 | 12 | ; and `ExportDynamic` as false. The callsite inside @_ZN4Base8dispatchEv |
|
21 | 21 | ; RUN: -r=summary.o,_ZN4Base8dispatchEv,px \ |
22 | 22 | ; RUN: -r=summary.o,_ZN7DerivedC2Ev, \ |
23 | 23 | ; RUN: -r=summary.o,_ZN8DerivedN5printEv,px \ |
24 | | -; RUN: -r=summary.o,_ZTS4Base, \ |
25 | 24 | ; RUN: -r=summary.o,_ZTV8DerivedN,p \ |
26 | 25 | ; RUN: -r=summary.o,_ZTI8DerivedN,p \ |
27 | | -; RUN: -r=summary.o,_ZTI4Base, \ |
28 | 26 | ; RUN: -r=summary.o,_ZTS8DerivedN,p \ |
29 | 27 | ; RUN: -r=summary.o,_ZTI7Derived, \ |
30 | | -; RUN: -r=summary.o,_ZTV4Base 2>&1 | FileCheck --allow-empty %s --check-prefix=REMARK |
| 28 | +; RUN: 2>&1 | FileCheck --allow-empty %s --check-prefix=REMARK |
31 | 29 |
|
32 | | -; REMARK: single-impl: devirtualized a call to _ZN8DerivedN5printEv |
33 | 30 |
|
34 | 31 | ; Index based WPD |
35 | 32 | ; For `_ZTI7Derived`, the 'llvm-lto2' resolution arguments specifies `VisibleOutsideSummary` as false |
|
45 | 42 | ; RUN: -r=summary.o,_ZN4Base8dispatchEv,px \ |
46 | 43 | ; RUN: -r=summary.o,_ZN7DerivedC2Ev, \ |
47 | 44 | ; RUN: -r=summary.o,_ZN8DerivedN5printEv,px \ |
48 | | -; RUN: -r=summary.o,_ZTS4Base, \ |
49 | 45 | ; RUN: -r=summary.o,_ZTV8DerivedN,p \ |
50 | 46 | ; RUN: -r=summary.o,_ZTI8DerivedN,p \ |
51 | | -; RUN: -r=summary.o,_ZTI4Base, \ |
52 | 47 | ; RUN: -r=summary.o,_ZTS8DerivedN,p \ |
53 | 48 | ; RUN: -r=summary.o,_ZTI7Derived,d \ |
54 | | -; RUN: -r=summary.o,_ZTV4Base 2>&1 | FileCheck %s --allow-empty --implicit-check-not='single-impl: devirtualized a call to' |
| 49 | +; RUN: 2>&1 | FileCheck %s --allow-empty --implicit-check-not='single-impl: devirtualized a call to' |
| 50 | + |
| 51 | + |
| 52 | +; Hybrid LTO WPD |
| 53 | +; RUN: opt --thinlto-bc --thinlto-split-lto-unit -o hybrid.o %s |
| 54 | +; RUN: llvm-lto2 run hybrid.o -save-temps -pass-remarks=. \ |
| 55 | +; RUN: -o hybrid \ |
| 56 | +; RUN: --whole-program-visibility-enabled-in-lto=true \ |
| 57 | +; RUN: --validate-all-vtables-have-type-infos=true \ |
| 58 | +; RUN: --all-vtables-have-type-infos=true \ |
| 59 | +; RUN: -r=hybrid.o,__cxa_pure_virtual, \ |
| 60 | +; RUN: -r=hybrid.o,_ZN8DerivedNC2Ev,x \ |
| 61 | +; RUN: -r=hybrid.o,_ZN4Base8dispatchEv,px \ |
| 62 | +; RUN: -r=hybrid.o,_ZN7DerivedC2Ev, \ |
| 63 | +; 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,_ZTS8DerivedN,p \ |
| 67 | +; RUN: -r=hybrid.o,_ZTI7Derived, \ |
| 68 | +; RUN: -r=hybrid.o,_ZN8DerivedN5printEv,px \ |
| 69 | +; RUN: -r=hybrid.o,_ZTV8DerivedN,p \ |
| 70 | +; RUN: -r=hybrid.o,_ZTI8DerivedN,p \ |
| 71 | +; RUN: 2>&1 | FileCheck --allow-empty %s --check-prefix=REMARK |
| 72 | + |
| 73 | +; Hybrid LTO WPD |
| 74 | +; RUN: llvm-lto2 run hybrid.o -save-temps -pass-remarks=. \ |
| 75 | +; RUN: -o hybrid \ |
| 76 | +; RUN: --whole-program-visibility-enabled-in-lto=true \ |
| 77 | +; RUN: --validate-all-vtables-have-type-infos=true \ |
| 78 | +; RUN: --all-vtables-have-type-infos=true \ |
| 79 | +; RUN: -r=hybrid.o,__cxa_pure_virtual, \ |
| 80 | +; RUN: -r=hybrid.o,_ZN8DerivedNC2Ev,x \ |
| 81 | +; RUN: -r=hybrid.o,_ZN4Base8dispatchEv,px \ |
| 82 | +; RUN: -r=hybrid.o,_ZN7DerivedC2Ev, \ |
| 83 | +; RUN: -r=hybrid.o,_ZN8DerivedN5printEv,px \ |
| 84 | +; RUN: -r=hybrid.o,_ZTV8DerivedN,p \ |
| 85 | +; RUN: -r=hybrid.o,_ZTI8DerivedN,p \ |
| 86 | +; RUN: -r=hybrid.o,_ZTS8DerivedN,p \ |
| 87 | +; RUN: -r=hybrid.o,_ZTI7Derived,d \ |
| 88 | +; RUN: -r=hybrid.o,_ZN8DerivedN5printEv,px \ |
| 89 | +; RUN: -r=hybrid.o,_ZTV8DerivedN,p \ |
| 90 | +; RUN: -r=hybrid.o,_ZTI8DerivedN,p \ |
| 91 | +; RUN: 2>&1 | FileCheck --allow-empty %s --implicit-check-not='single-impl: devirtualized a call to' |
| 92 | + |
| 93 | + |
| 94 | +; In regular LTO, global resolutions (as expected) show symbols are visible |
| 95 | +; outside summary (when they come from regular LTO module without summaries). |
| 96 | +; In the setting of this test case (equivalent of `-Wl,--lto-whole-program-visibility -Wl,--lto-validate-all-vtables-have-type-infos` in lld), |
| 97 | +; devirtualization will be suppressed even if the compatible class is not |
| 98 | +; referenced from shared libraries. So regular LTO test coverage is not meaningful. |
| 99 | + |
| 100 | +; REMARK: single-impl: devirtualized a call to _ZN8DerivedN5printEv |
55 | 101 |
|
56 | 102 | target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" |
57 | 103 | target triple = "x86_64-unknown-linux-gnu" |
58 | 104 |
|
59 | | -@_ZTV8DerivedN = linkonce_odr hidden constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI8DerivedN, ptr @_ZN8DerivedN5printEv] }, !type !0, !type !1, !type !2, !type !3, !type !4, !type !5, !vcall_visibility !6 |
| 105 | +@_ZTV8DerivedN = linkonce_odr hidden constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI8DerivedN, ptr @_ZN8DerivedN5printEv] }, !type !0, !type !1, !type !2, !type !3, !vcall_visibility !6 |
60 | 106 | @_ZTI8DerivedN = linkonce_odr hidden constant { ptr, ptr, ptr } { ptr null, ptr @_ZTS8DerivedN, ptr @_ZTI7Derived } |
61 | 107 | @_ZTS8DerivedN = linkonce_odr hidden constant [10 x i8] c"8DerivedN\00", align 1 |
62 | 108 | @_ZTI7Derived = external constant ptr |
63 | | -@_ZTV4Base = linkonce_odr hidden constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI4Base, ptr @__cxa_pure_virtual] }, !type !0, !type !1, !vcall_visibility !6 |
64 | | -@_ZTI4Base = linkonce_odr hidden constant { ptr, ptr } { ptr null, ptr @_ZTS4Base } |
65 | | -@_ZTS4Base = linkonce_odr hidden constant [6 x i8] c"4Base\00", align 1 |
66 | 109 |
|
67 | 110 | @llvm.used = appending global [1 x ptr] [ptr @_ZN8DerivedNC2Ev], section "llvm.metadata" |
68 | 111 |
|
@@ -102,10 +145,10 @@ declare i1 @llvm.type.test(ptr, metadata) |
102 | 145 | declare void @llvm.assume(i1) |
103 | 146 | declare void @_ZN7DerivedC2Ev(ptr) |
104 | 147 |
|
105 | | -!0 = !{i64 16, !"_ZTS4Base"} |
106 | | -!1 = !{i64 16, !"_ZTSM4BaseFvvE.virtual"} |
107 | | -!2 = !{i64 16, !"_ZTS7Derived"} |
108 | | -!3 = !{i64 16, !"_ZTSM7DerivedFvvE.virtual"} |
109 | | -!4 = !{i64 16, !"_ZTS8DerivedN"} |
110 | | -!5 = !{i64 16, !"_ZTSM8DerivedNFvvE.virtual"} |
| 148 | +!0 = !{i64 16, !"_ZTS7Derived"} |
| 149 | +!1 = !{i64 16, !"_ZTSM7DerivedFvvE.virtual"} |
| 150 | +!2 = !{i64 16, !"_ZTS8DerivedN"} |
| 151 | +!3 = !{i64 16, !"_ZTSM8DerivedNFvvE.virtual"} |
| 152 | +;!4 = !{i64 16, !"_ZTS8DerivedN"} |
| 153 | +;!5 = !{i64 16, !"_ZTSM8DerivedNFvvE.virtual"} |
111 | 154 | !6 = !{i64 0} |
0 commit comments