1 ; RUN: opt < %s -passes='globaldce<vfe-linkage-unit-visibility>' -S | FileCheck %s
2 ; RUN: opt < %s -passes='lto<O2>' -S | FileCheck %s
4 ; structs A, B and C have vcall_visibility of public, linkage-unit and
5 ; translation-unit respectively. This test is run after LTO linking (the
6 ; pass parameter simulates how GlobalDCE is invoked from the regular LTO
7 ; pipeline), so B and C can be VFE'd.
9 ;; Try again without being in the LTO post link, we can only eliminate C.
10 ; RUN: opt < %s -passes='globaldce' -S | FileCheck %s --check-prefix=NO-LTO
11 ; RUN: opt < %s -passes='default<O2>' -S | FileCheck %s --check-prefix=NO-LTO
13 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
15 %struct.A = type { ptr }
17 @_ZTV1A = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1A3fooEv] }, align 8, !type !0, !type !1, !vcall_visibility !2
19 define internal void @_ZN1AC2Ev(ptr %this) {
21 store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV1A, i64 0, i32 0, i64 2), ptr %this, align 8
25 ; CHECK: define {{.*}} @_ZN1A3fooEv(
26 ; NO-LTO: define {{.*}} @_ZN1A3fooEv(
27 define internal void @_ZN1A3fooEv(ptr nocapture %this) {
32 define dso_local ptr @_Z6make_Av() {
34 %call = tail call ptr @_Znwm(i64 8)
35 tail call void @_ZN1AC2Ev(ptr %call)
40 %struct.B = type { ptr }
42 @_ZTV1B = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1B3fooEv] }, align 8, !type !0, !type !1, !vcall_visibility !3
44 define internal void @_ZN1BC2Ev(ptr %this) {
46 store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV1B, i64 0, i32 0, i64 2), ptr %this, align 8
50 ; CHECK-NOT: define {{.*}} @_ZN1B3fooEv(
51 ; NO-LTO: define {{.*}} @_ZN1B3fooEv(
52 define internal void @_ZN1B3fooEv(ptr nocapture %this) {
57 define dso_local ptr @_Z6make_Bv() {
59 %call = tail call ptr @_Znwm(i64 8)
60 tail call void @_ZN1BC2Ev(ptr %call)
65 %struct.C = type { ptr }
67 @_ZTV1C = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1C3fooEv] }, align 8, !type !0, !type !1, !vcall_visibility !4
69 define internal void @_ZN1CC2Ev(ptr %this) {
71 store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV1C, i64 0, i32 0, i64 2), ptr %this, align 8
75 ; CHECK-NOT: define {{.*}} @_ZN1C3fooEv(
76 ; NO-LTO-NOT: define {{.*}} @_ZN1C3fooEv(
77 define internal void @_ZN1C3fooEv(ptr nocapture %this) {
82 define dso_local ptr @_Z6make_Cv() {
84 %call = tail call ptr @_Znwm(i64 8)
85 tail call void @_ZN1CC2Ev(ptr %call)
89 declare dso_local noalias nonnull ptr @_Znwm(i64)
91 !llvm.module.flags = !{!6}
93 !0 = !{i64 16, !"_ZTS1A"}
94 !1 = !{i64 16, !"_ZTSM1AFvvE.virtual"}
95 !2 = !{i64 0} ; public vcall visibility
96 !3 = !{i64 1} ; linkage-unit vcall visibility
97 !4 = !{i64 2} ; translation-unit vcall visibility
98 !6 = !{i32 1, !"Virtual Function Elim", i32 1}