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; RUN: llvm-lto2 run -save-temps %t.o \ 8; RUN: -o %t3 \ 9; RUN: -r=%t.o,test,px \ 10; RUN: -r=%t.o,_ZTV1B, \ 11; RUN: -r=%t.o,_ZN1B1fEi, \ 12; RUN: -r=%t.o,_ZTV1B,px 13; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR 14 15target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 16target triple = "x86_64-grtev4-linux-gnu" 17 18%struct.B = type { %struct.A } 19%struct.A = type { ptr } 20 21@_ZTV1B = constant { [3 x ptr] } { [3 x ptr] [ptr undef, ptr undef, ptr undef] }, !type !0 22 23; CHECK-IR-LABEL: define void @test 24define void @test(ptr %b) { 25entry: 26 ; Ensure that traps are conditional. Invalid TYPE_ID can cause 27 ; unconditional traps. 28 ; CHECK-IR: br i1 {{.*}}, label %trap 29 %vtable2 = load ptr, ptr %b 30 %0 = tail call i1 @llvm.type.test(ptr %vtable2, metadata !"_ZTS1A") 31 br i1 %0, label %cont, label %trap 32 33trap: 34 tail call void @llvm.trap() 35 unreachable 36 37cont: 38 ; CHECK-IR-LABEL: ret void 39 ret void 40} 41; CHECK-IR-LABEL: } 42 43declare i1 @llvm.type.test(ptr, metadata) 44declare void @llvm.trap() 45 46declare i32 @_ZN1B1fEi(ptr %this, i32 %a) 47 48!0 = !{i64 16, !"_ZTS1A"} 49!1 = !{i64 16, !"_ZTS1B"} 50