1 ; REQUIRES: x86-registered-target
3 ; Test CFI devirtualization through the thin link and backend when
4 ; a type id is Unsat (not used on any global's type metadata).
6 ; In this test case, the first module is split and will import a resolution
7 ; for its type test. The resolution would be exported by the second
8 ; module, which is set up so that it does not get split (treated as regular
9 ; LTO because it does not have any external globals from which to create
10 ; a unique module ID). We should not actually get any resolution for the
11 ; type id in this case, since no globals include it in their type metadata,
12 ; so the resolution is Unsat and the type.checked.load instructions are
13 ; converted to type tests that evaluate to false.
15 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t.o %s
16 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t1.o %p/Inputs/cfi-unsat.ll
18 ; RUN: llvm-lto2 run %t.o %t1.o -save-temps -pass-remarks=. \
19 ; RUN: -whole-program-visibility \
21 ; RUN: -r=%t.o,test2,px \
22 ; RUN: -r=%t1.o,_ZTV1B,px \
23 ; RUN: -r=%t1.o,test,px \
24 ; RUN: -r=%t1.o,testb,px
25 ; RUN: llvm-dis %t3.index.bc -o - | FileCheck %s --check-prefix=INDEX
26 ; RUN: llvm-dis %t3.0.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR0
27 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR1
29 ; INDEX-NOT: "typeid:"
31 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
32 target triple = "x86_64-grtev4-linux-gnu"
34 %struct.A = type { ptr }
38 define linkonce_odr i32 @test2(ptr %obj, i32 %a) comdat {
40 %vtable5 = load ptr, ptr %obj
42 %0 = tail call { ptr, i1 } @llvm.type.checked.load(ptr %vtable5, i32 8, metadata !"_ZTS1A")
43 %1 = extractvalue { ptr, i1 } %0, 1
44 br i1 %1, label %cont, label %trap
47 tail call void @llvm.trap()
51 %2 = extractvalue { ptr, i1 } %0, 0
53 %call = tail call i32 %2(ptr nonnull %obj, i32 %a)
58 ; CHECK-IR0: define weak_odr i32 @test
59 ; CHECK-IR0-NEXT: entry:
60 ; CHECK-IR0-NEXT: %vtable5 =
61 ; CHECK-IR0-NEXT: tail call void @llvm.trap()
62 ; CHECK-IR0-NEXT: unreachable
64 ; CHECK-IR0: define weak_odr i32 @testb
65 ; CHECK-IR0-NEXT: entry:
66 ; CHECK-IR0-NEXT: %vtable5 =
67 ; CHECK-IR0-NEXT: tail call void @llvm.trap()
68 ; CHECK-IR0-NEXT: unreachable
71 ; CHECK-IR1: define weak_odr i32 @test2
72 ; CHECK-IR1-NEXT: entry:
73 ; CHECK-IR1-NEXT: tail call void @llvm.trap()
74 ; CHECK-IR1-NEXT: unreachable
77 declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata)
78 declare void @llvm.trap()