xref: /llvm-project/llvm/test/Transforms/Internalize/vcall-visibility.ll (revision 0f46e31cfbf415fcd3d3ce121bef94e92c6ccfc8)
1; RUN: opt < %s -passes=internalize -S | FileCheck %s
2
3%struct.A = type { ptr }
4%struct.B = type { ptr }
5%struct.C = type { ptr }
6
7; Class A has default visibility, so has no !vcall_visibility metadata before
8; or after LTO.
9; CHECK-NOT: @_ZTV1A = {{.*}}!vcall_visibility
10@_ZTV1A = dso_local unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1A3fooEv] }, align 8, !type !0, !type !1
11
12; Class B has hidden visibility but public LTO visibility, so has no
13; !vcall_visibility metadata before or after LTO.
14; CHECK-NOT: @_ZTV1B = {{.*}}!vcall_visibility
15@_ZTV1B = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1B3fooEv] }, align 8, !type !2, !type !3
16
17; Class C has hidden visibility, so the !vcall_visibility metadata is set to 1
18; (linkage unit) before LTO, and 2 (translation unit) after LTO.
19; CHECK: @_ZTV1C ={{.*}}!vcall_visibility [[MD_TU_VIS:![0-9]+]]
20@_ZTV1C = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1C3fooEv] }, align 8, !type !4, !type !5, !vcall_visibility !6
21
22; Class D has translation unit visibility before LTO, and this is not changed
23; by LTO.
24; CHECK: @_ZTVN12_GLOBAL__N_11DE = {{.*}}!vcall_visibility [[MD_TU_VIS:![0-9]+]]
25@_ZTVN12_GLOBAL__N_11DE = internal unnamed_addr constant { [3 x ptr] } zeroinitializer, align 8, !type !7, !type !9, !vcall_visibility !11
26
27define dso_local void @_ZN1A3fooEv(ptr nocapture %this) {
28entry:
29  ret void
30}
31
32define hidden void @_ZN1B3fooEv(ptr nocapture %this) {
33entry:
34  ret void
35}
36
37define hidden void @_ZN1C3fooEv(ptr nocapture %this) {
38entry:
39  ret void
40}
41
42define hidden noalias nonnull ptr @_Z6make_dv() {
43entry:
44  %call = tail call ptr @_Znwm(i64 8) #3
45  store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTVN12_GLOBAL__N_11DE, i64 0, i32 0, i64 2), ptr %call, align 8
46  ret ptr %call
47}
48
49declare dso_local noalias nonnull ptr @_Znwm(i64)
50
51; CHECK: [[MD_TU_VIS]] = !{i64 2}
52!0 = !{i64 16, !"_ZTS1A"}
53!1 = !{i64 16, !"_ZTSM1AFvvE.virtual"}
54!2 = !{i64 16, !"_ZTS1B"}
55!3 = !{i64 16, !"_ZTSM1BFvvE.virtual"}
56!4 = !{i64 16, !"_ZTS1C"}
57!5 = !{i64 16, !"_ZTSM1CFvvE.virtual"}
58!6 = !{i64 1}
59!7 = !{i64 16, !8}
60!8 = distinct !{}
61!9 = !{i64 16, !10}
62!10 = distinct !{}
63!11 = !{i64 2}
64