1; RUN: opt < %s -passes=globaldce -S | FileCheck %s 2 3; structs A, B and C have vcall_visibility of public, linkage-unit and 4; translation-unit respectively. This test is run before LTO linking occurs 5; so only C can be VFE'd. 6 7target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 8 9%struct.A = type { ptr } 10 11@_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 12 13define internal void @_ZN1AC2Ev(ptr %this) { 14entry: 15 store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV1A, i64 0, i32 0, i64 2), ptr %this, align 8 16 ret void 17} 18 19; CHECK: define {{.*}} @_ZN1A3fooEv( 20define internal void @_ZN1A3fooEv(ptr nocapture %this) { 21entry: 22 ret void 23} 24 25define dso_local ptr @_Z6make_Av() { 26entry: 27 %call = tail call ptr @_Znwm(i64 8) 28 tail call void @_ZN1AC2Ev(ptr %call) 29 ret ptr %call 30} 31 32 33%struct.B = type { ptr } 34 35@_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 36 37define internal void @_ZN1BC2Ev(ptr %this) { 38entry: 39 store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV1B, i64 0, i32 0, i64 2), ptr %this, align 8 40 ret void 41} 42 43; CHECK: define {{.*}} @_ZN1B3fooEv( 44define internal void @_ZN1B3fooEv(ptr nocapture %this) { 45entry: 46 ret void 47} 48 49define dso_local ptr @_Z6make_Bv() { 50entry: 51 %call = tail call ptr @_Znwm(i64 8) 52 tail call void @_ZN1BC2Ev(ptr %call) 53 ret ptr %call 54} 55 56 57%struct.C = type { ptr } 58 59@_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 60 61define internal void @_ZN1CC2Ev(ptr %this) { 62entry: 63 store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV1C, i64 0, i32 0, i64 2), ptr %this, align 8 64 ret void 65} 66 67; CHECK-NOT: define {{.*}} @_ZN1C3fooEv( 68define internal void @_ZN1C3fooEv(ptr nocapture %this) { 69entry: 70 ret void 71} 72 73define dso_local ptr @_Z6make_Cv() { 74entry: 75 %call = tail call ptr @_Znwm(i64 8) 76 tail call void @_ZN1CC2Ev(ptr %call) 77 ret ptr %call 78} 79 80declare dso_local noalias nonnull ptr @_Znwm(i64) 81 82!llvm.module.flags = !{!5} 83 84!0 = !{i64 16, !"_ZTS1A"} 85!1 = !{i64 16, !"_ZTSM1AFvvE.virtual"} 86!2 = !{i64 0} ; public vcall visibility 87!3 = !{i64 1} ; linkage-unit vcall visibility 88!4 = !{i64 2} ; translation-unit vcall visibility 89!5 = !{i32 1, !"Virtual Function Elim", i32 1} 90