• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -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; (the LTOPostLink metadata is not present), 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 { i32 (...)** }
10
11@_ZTV1A = hidden unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.A*)* @_ZN1A3fooEv to i8*)] }, align 8, !type !0, !type !1, !vcall_visibility !2
12
13define internal void @_ZN1AC2Ev(%struct.A* %this) {
14entry:
15  %0 = getelementptr inbounds %struct.A, %struct.A* %this, i64 0, i32 0
16  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8
17  ret void
18}
19
20; CHECK: define {{.*}} @_ZN1A3fooEv(
21define internal void @_ZN1A3fooEv(%struct.A* nocapture %this) {
22entry:
23  ret void
24}
25
26define dso_local i8* @_Z6make_Av() {
27entry:
28  %call = tail call i8* @_Znwm(i64 8)
29  %0 = bitcast i8* %call to %struct.A*
30  tail call void @_ZN1AC2Ev(%struct.A* %0)
31  ret i8* %call
32}
33
34
35%struct.B = type { i32 (...)** }
36
37@_ZTV1B = hidden unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.B*)* @_ZN1B3fooEv to i8*)] }, align 8, !type !0, !type !1, !vcall_visibility !3
38
39define internal void @_ZN1BC2Ev(%struct.B* %this) {
40entry:
41  %0 = getelementptr inbounds %struct.B, %struct.B* %this, i64 0, i32 0
42  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1B, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8
43  ret void
44}
45
46; CHECK: define {{.*}} @_ZN1B3fooEv(
47define internal void @_ZN1B3fooEv(%struct.B* nocapture %this) {
48entry:
49  ret void
50}
51
52define dso_local i8* @_Z6make_Bv() {
53entry:
54  %call = tail call i8* @_Znwm(i64 8)
55  %0 = bitcast i8* %call to %struct.B*
56  tail call void @_ZN1BC2Ev(%struct.B* %0)
57  ret i8* %call
58}
59
60
61%struct.C = type { i32 (...)** }
62
63@_ZTV1C = hidden unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.C*)* @_ZN1C3fooEv to i8*)] }, align 8, !type !0, !type !1, !vcall_visibility !4
64
65define internal void @_ZN1CC2Ev(%struct.C* %this) {
66entry:
67  %0 = getelementptr inbounds %struct.C, %struct.C* %this, i64 0, i32 0
68  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1C, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8
69  ret void
70}
71
72; CHECK-NOT: define {{.*}} @_ZN1C3fooEv(
73define internal void @_ZN1C3fooEv(%struct.C* nocapture %this) {
74entry:
75  ret void
76}
77
78define dso_local i8* @_Z6make_Cv() {
79entry:
80  %call = tail call i8* @_Znwm(i64 8)
81  %0 = bitcast i8* %call to %struct.C*
82  tail call void @_ZN1CC2Ev(%struct.C* %0)
83  ret i8* %call
84}
85
86declare dso_local noalias nonnull i8* @_Znwm(i64)
87
88!llvm.module.flags = !{!5}
89
90!0 = !{i64 16, !"_ZTS1A"}
91!1 = !{i64 16, !"_ZTSM1AFvvE.virtual"}
92!2 = !{i64 0} ; public vcall visibility
93!3 = !{i64 1} ; linkage-unit vcall visibility
94!4 = !{i64 2} ; translation-unit vcall visibility
95!5 = !{i32 1, !"Virtual Function Elim", i32 1}
96