1 ; RUN: opt < %s -passes=globaldce -S | FileCheck %s
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.
7 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
9 %struct.A = type { ptr }
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
13 define internal void @_ZN1AC2Ev(ptr %this) {
15 store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1A, i64 0, inrange i32 0, i64 2), ptr %this, align 8
19 ; CHECK: define {{.*}} @_ZN1A3fooEv(
20 define internal void @_ZN1A3fooEv(ptr nocapture %this) {
25 define dso_local ptr @_Z6make_Av() {
27 %call = tail call ptr @_Znwm(i64 8)
28 tail call void @_ZN1AC2Ev(ptr %call)
33 %struct.B = type { ptr }
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
37 define internal void @_ZN1BC2Ev(ptr %this) {
39 store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1B, i64 0, inrange i32 0, i64 2), ptr %this, align 8
43 ; CHECK: define {{.*}} @_ZN1B3fooEv(
44 define internal void @_ZN1B3fooEv(ptr nocapture %this) {
49 define dso_local ptr @_Z6make_Bv() {
51 %call = tail call ptr @_Znwm(i64 8)
52 tail call void @_ZN1BC2Ev(ptr %call)
57 %struct.C = type { ptr }
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
61 define internal void @_ZN1CC2Ev(ptr %this) {
63 store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1C, i64 0, inrange i32 0, i64 2), ptr %this, align 8
67 ; CHECK-NOT: define {{.*}} @_ZN1C3fooEv(
68 define internal void @_ZN1C3fooEv(ptr nocapture %this) {
73 define dso_local ptr @_Z6make_Cv() {
75 %call = tail call ptr @_Znwm(i64 8)
76 tail call void @_ZN1CC2Ev(ptr %call)
80 declare dso_local noalias nonnull ptr @_Znwm(i64)
82 !llvm.module.flags = !{!5}
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}