1; REQUIRES: x86-registered-target 2 3; Test CFI through the thin link and backend. 4 5; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t.o %s 6 7; Legacy PM 8; RUN: llvm-lto2 run -save-temps %t.o \ 9; RUN: -o %t3 \ 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 15 16; New PM 17; RUN: llvm-lto2 run -save-temps %t.o -use-new-pm \ 18; RUN: -o %t3 \ 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 24 25target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 26target triple = "x86_64-grtev4-linux-gnu" 27 28%struct.B = type { %struct.A } 29%struct.A = type { i32 (...)** } 30 31@_ZTV1B = constant { [3 x i8*] } { [3 x i8*] [i8* undef, i8* undef, i8* undef] }, !type !0 32 33; CHECK-IR-LABEL: define void @test 34define void @test(i8* %b) { 35entry: 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 43 44trap: 45 tail call void @llvm.trap() 46 unreachable 47 48cont: 49 ; CHECK-IR-LABEL: ret void 50 ret void 51} 52; CHECK-IR-LABEL: } 53 54declare i1 @llvm.type.test(i8*, metadata) 55declare void @llvm.trap() 56 57declare i32 @_ZN1B1fEi(%struct.B* %this, i32 %a) 58 59!0 = !{i64 16, !"_ZTS1A"} 60!1 = !{i64 16, !"_ZTS1B"} 61