xref: /llvm-project/llvm/test/Transforms/GlobalDCE/vtable-rtti.ll (revision 0f46e31cfbf415fcd3d3ce121bef94e92c6ccfc8)
1; RUN: opt < %s -passes=globaldce -S | FileCheck %s
2
3; We currently only use llvm.type.checked.load for virtual function pointers,
4; not any other part of the vtable, so we can't remove the RTTI pointer even if
5; it's never going to be loaded from.
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; CHECK: @_ZTV1A = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1A, ptr null] }, align 8, !type !0, !type !1, !vcall_visibility !2
12
13@_ZTV1A = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1A, ptr @_ZN1A3fooEv] }, align 8, !type !0, !type !1, !vcall_visibility !2
14@_ZTS1A = hidden constant [3 x i8] c"1A\00", align 1
15@_ZTI1A = hidden constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS1A }, align 8
16
17define internal void @_ZN1AC2Ev(ptr %this) {
18entry:
19  store ptr getelementptr inbounds inrange(-16, 8) ({ [3 x ptr] }, ptr @_ZTV1A, i64 0, i32 0, i64 2), ptr %this, align 8
20  ret void
21}
22
23; CHECK-NOT: define {{.*}} @_ZN1A3fooEv(
24define internal void @_ZN1A3fooEv(ptr nocapture %this) {
25entry:
26  ret void
27}
28
29define dso_local ptr @_Z6make_Av() {
30entry:
31  %call = tail call ptr @_Znwm(i64 8)
32  tail call void @_ZN1AC2Ev(ptr %call)
33  ret ptr %call
34}
35
36
37declare dso_local noalias nonnull ptr @_Znwm(i64)
38@_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global ptr
39
40!llvm.module.flags = !{!4}
41
42!0 = !{i64 16, !"_ZTS1A"}
43!1 = !{i64 16, !"_ZTSM1AFvvE.virtual"}
44!2 = !{i64 2} ; translation-unit vcall visibility
45!4 = !{i32 1, !"Virtual Function Elim", i32 1}
46