1; RUN: opt < %s -passes='globaldce<vfe-linkage-unit-visibility>' -S | FileCheck %s 2; RUN: opt < %s -passes='lto<O2>' -S | FileCheck %s 3 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. 8 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 12 13target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 14 15%struct.A = type { ptr } 16 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 18 19define internal void @_ZN1AC2Ev(ptr %this) { 20entry: 21 store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV1A, i64 0, i32 0, i64 2), ptr %this, align 8 22 ret void 23} 24 25; CHECK: define {{.*}} @_ZN1A3fooEv( 26; NO-LTO: define {{.*}} @_ZN1A3fooEv( 27define internal void @_ZN1A3fooEv(ptr nocapture %this) { 28entry: 29 ret void 30} 31 32define dso_local ptr @_Z6make_Av() { 33entry: 34 %call = tail call ptr @_Znwm(i64 8) 35 tail call void @_ZN1AC2Ev(ptr %call) 36 ret ptr %call 37} 38 39 40%struct.B = type { ptr } 41 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 43 44define internal void @_ZN1BC2Ev(ptr %this) { 45entry: 46 store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV1B, i64 0, i32 0, i64 2), ptr %this, align 8 47 ret void 48} 49 50; CHECK-NOT: define {{.*}} @_ZN1B3fooEv( 51; NO-LTO: define {{.*}} @_ZN1B3fooEv( 52define internal void @_ZN1B3fooEv(ptr nocapture %this) { 53entry: 54 ret void 55} 56 57define dso_local ptr @_Z6make_Bv() { 58entry: 59 %call = tail call ptr @_Znwm(i64 8) 60 tail call void @_ZN1BC2Ev(ptr %call) 61 ret ptr %call 62} 63 64 65%struct.C = type { ptr } 66 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 68 69define internal void @_ZN1CC2Ev(ptr %this) { 70entry: 71 store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV1C, i64 0, i32 0, i64 2), ptr %this, align 8 72 ret void 73} 74 75; CHECK-NOT: define {{.*}} @_ZN1C3fooEv( 76; NO-LTO-NOT: define {{.*}} @_ZN1C3fooEv( 77define internal void @_ZN1C3fooEv(ptr nocapture %this) { 78entry: 79 ret void 80} 81 82define dso_local ptr @_Z6make_Cv() { 83entry: 84 %call = tail call ptr @_Znwm(i64 8) 85 tail call void @_ZN1CC2Ev(ptr %call) 86 ret ptr %call 87} 88 89declare dso_local noalias nonnull ptr @_Znwm(i64) 90 91!llvm.module.flags = !{!6} 92 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} 99