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 -use-new-pm -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 { i32 (...)** }
38 define linkonce_odr i32 @test2(%struct.A* %obj, i32 %a) comdat {
40 %0 = bitcast %struct.A* %obj to i8**
41 %vtable5 = load i8*, i8** %0
43 %1 = tail call { i8*, i1 } @llvm.type.checked.load(i8* %vtable5, i32 8, metadata !"_ZTS1A")
44 %2 = extractvalue { i8*, i1 } %1, 1
45 br i1 %2, label %cont, label %trap
48 tail call void @llvm.trap()
52 %3 = extractvalue { i8*, i1 } %1, 0
53 %4 = bitcast i8* %3 to i32 (%struct.A*, i32)*
55 %call = tail call i32 %4(%struct.A* nonnull %obj, i32 %a)
60 ; CHECK-IR0: define weak_odr i32 @test
61 ; CHECK-IR0-NEXT: entry:
62 ; CHECK-IR0-NEXT: %0 = bitcast
63 ; CHECK-IR0-NEXT: %vtable5 =
64 ; CHECK-IR0-NEXT: tail call void @llvm.trap()
65 ; CHECK-IR0-NEXT: unreachable
67 ; CHECK-IR0: define weak_odr i32 @testb
68 ; CHECK-IR0-NEXT: entry:
69 ; CHECK-IR0-NEXT: %0 = bitcast
70 ; CHECK-IR0-NEXT: %vtable5 =
71 ; CHECK-IR0-NEXT: tail call void @llvm.trap()
72 ; CHECK-IR0-NEXT: unreachable
75 ; CHECK-IR1: define weak_odr i32 @test2
76 ; CHECK-IR1-NEXT: entry:
77 ; CHECK-IR1-NEXT: tail call void @llvm.trap()
78 ; CHECK-IR1-NEXT: unreachable
81 declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata)
82 declare void @llvm.trap()