1 ; REQUIRES: x86-registered-target
3 ; Test CFI through the thin link and backend.
5 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t.o %s
8 ; RUN: llvm-lto2 run -save-temps %t.o \
10 ; RUN: -r=%t.o,test,px \
11 ; RUN: -r=%t.o,_ZTV1B, \
12 ; RUN: -r=%t.o,_ZN1B1fEi, \
13 ; RUN: -r=%t.o,_ZTV1B,px
14 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
17 ; RUN: llvm-lto2 run -save-temps %t.o -use-new-pm \
19 ; RUN: -r=%t.o,test,px \
20 ; RUN: -r=%t.o,_ZTV1B, \
21 ; RUN: -r=%t.o,_ZN1B1fEi, \
22 ; RUN: -r=%t.o,_ZTV1B,px
23 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
25 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
26 target triple = "x86_64-grtev4-linux-gnu"
28 %struct.B = type { %struct.A }
29 %struct.A = type { i32 (...)** }
31 @_ZTV1B = constant { [3 x i8*] } { [3 x i8*] [i8* undef, i8* undef, i8* undef] }, !type !0
33 ; CHECK-IR-LABEL: define void @test
34 define void @test(i8* %b) {
36 ; Ensure that traps are conditional. Invalid TYPE_ID can cause
37 ; unconditional traps.
38 ; CHECK-IR: br i1 {{.*}}, label %trap
39 %0 = bitcast i8* %b to i8**
40 %vtable2 = load i8*, i8** %0
41 %1 = tail call i1 @llvm.type.test(i8* %vtable2, metadata !"_ZTS1A")
42 br i1 %1, label %cont, label %trap
45 tail call void @llvm.trap()
49 ; CHECK-IR-LABEL: ret void
54 declare i1 @llvm.type.test(i8*, metadata)
55 declare void @llvm.trap()
57 declare i32 @_ZN1B1fEi(%struct.B* %this, i32 %a)
59 !0 = !{i64 16, !"_ZTS1A"}
60 !1 = !{i64 16, !"_ZTS1B"}