1; Test to ensure type tests that are only used in assumes are ignored by 2; LowerTypeTests (in the normal pass sequence they will be stripped out 3; by a subsequent special LTT invocation). 4 5; RUN: opt -S -passes=lowertypetests < %s | FileCheck %s 6 7; ModuleID = 'pr48245.o' 8source_filename = "pr48245.cpp" 9target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 10target triple = "x86_64-unknown-linux-gnu" 11 12%struct.Foo = type { i32 (...)** } 13 14; Check that the vtable was not turned into an alias to a rewritten private 15; global. 16; CHECK: @_ZTV3Foo = dso_local unnamed_addr constant 17@_ZTV3Foo = dso_local unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI3Foo to i8*), i8* bitcast (i32 (%struct.Foo*)* @_ZN3Foo2f1Ev to i8*), i8* bitcast (i32 (%struct.Foo*)* @_ZN3Foo2f2Ev to i8*)] }, align 8, !type !0, !type !1, !type !2 18 19@_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global i8* 20@_ZTS3Foo = dso_local constant [5 x i8] c"3Foo\00", align 1 21@_ZTI3Foo = dso_local constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @_ZTS3Foo, i32 0, i32 0) }, align 8 22@b = dso_local local_unnamed_addr global %struct.Foo* null, align 8 23 24define dso_local i32 @main() local_unnamed_addr { 25entry: 26 %0 = load %struct.Foo*, %struct.Foo** @b, align 8 27 %1 = bitcast %struct.Foo* %0 to i32 (%struct.Foo*)*** 28 %vtable.i = load i32 (%struct.Foo*)**, i32 (%struct.Foo*)*** %1, align 8 29 %2 = bitcast i32 (%struct.Foo*)** %vtable.i to i8* 30 31 ; Check that the type test was not lowered. 32 ; CHECK: tail call i1 @llvm.type.test 33 %3 = tail call i1 @llvm.type.test(i8* %2, metadata !"_ZTS3Foo") 34 35 tail call void @llvm.assume(i1 %3) 36 %4 = load i32 (%struct.Foo*)*, i32 (%struct.Foo*)** %vtable.i, align 8 37 %call.i = tail call i32 %4(%struct.Foo* nonnull dereferenceable(8) %0) 38 ret i32 %call.i 39} 40 41declare i1 @llvm.type.test(i8*, metadata) 42declare void @llvm.assume(i1 noundef) 43declare dso_local i32 @_ZN3Foo2f1Ev(%struct.Foo* nocapture nonnull readnone dereferenceable(8) %this) unnamed_addr 44declare dso_local i32 @_ZN3Foo2f2Ev(%struct.Foo* nocapture nonnull readnone dereferenceable(8) %this) unnamed_addr 45 46!0 = !{i64 16, !"_ZTS3Foo"} 47!1 = !{i64 16, !"_ZTSM3FooFivE.virtual"} 48!2 = !{i64 24, !"_ZTSM3FooFivE.virtual"} 49