1 ; RUN: opt -S -cross-dso-cfi < %s | FileCheck %s 2 ; RUN: opt -S -passes=cross-dso-cfi < %s | FileCheck %s 3 4 ; CHECK: define void @__cfi_check(i64 %[[TYPE:.*]], i8* %[[ADDR:.*]], i8* %[[DATA:.*]]) align 4096 5 ; CHECK: switch i64 %[[TYPE]], label %[[FAIL:.*]] [ 6 ; CHECK-NEXT: i64 111, label %[[L1:.*]] 7 ; CHECK-NEXT: i64 222, label %[[L2:.*]] 8 ; CHECK-NEXT: i64 333, label %[[L3:.*]] 9 ; CHECK-NEXT: i64 444, label %[[L4:.*]] 10 ; CHECK-NEXT: {{]$}} 11 12 ; CHECK: [[EXIT:.*]]: 13 ; CHECK-NEXT: ret void 14 15 ; CHECK: [[FAIL]]: 16 ; CHECK-NEXT: call void @__cfi_check_fail(i8* %[[DATA]], i8* %[[ADDR]]) 17 ; CHECK-NEXT: br label %[[EXIT]] 18 19 ; CHECK: [[L1]]: 20 ; CHECK-NEXT: call i1 @llvm.type.test(i8* %[[ADDR]], metadata i64 111) 21 ; CHECK-NEXT: br {{.*}} label %[[EXIT]], label %[[FAIL]] 22 23 ; CHECK: [[L2]]: 24 ; CHECK-NEXT: call i1 @llvm.type.test(i8* %[[ADDR]], metadata i64 222) 25 ; CHECK-NEXT: br {{.*}} label %[[EXIT]], label %[[FAIL]] 26 27 ; CHECK: [[L3]]: 28 ; CHECK-NEXT: call i1 @llvm.type.test(i8* %[[ADDR]], metadata i64 333) 29 ; CHECK-NEXT: br {{.*}} label %[[EXIT]], label %[[FAIL]] 30 31 ; CHECK: [[L4]]: 32 ; CHECK-NEXT: call i1 @llvm.type.test(i8* %[[ADDR]], metadata i64 444) 33 ; CHECK-NEXT: br {{.*}} label %[[EXIT]], label %[[FAIL]] 34 35 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 36 target triple = "x86_64-unknown-linux-gnu" 37 38 @_ZTV1A = constant i8 0, !type !4, !type !5 39 @_ZTV1B = constant i8 0, !type !4, !type !5, !type !6, !type !7 40 41 define signext i8 @f11() !type !0 !type !1 { 42 entry: 43 ret i8 1 44 } 45 46 define signext i8 @f12() !type !0 !type !1 { 47 entry: 48 ret i8 2 49 } 50 51 define signext i8 @f13() !type !0 !type !1 { 52 entry: 53 ret i8 3 54 } 55 56 define i32 @f21() !type !2 !type !3 { 57 entry: 58 ret i32 4 59 } 60 61 define i32 @f22() !type !2 !type !3 { 62 entry: 63 ret i32 5 64 } 65 66 define weak_odr hidden void @__cfi_check_fail(i8*, i8*) { 67 entry: 68 ret void 69 } 70 71 !llvm.module.flags = !{!8} 72 73 !0 = !{i64 0, !"_ZTSFcvE"} 74 !1 = !{i64 0, i64 111} 75 !2 = !{i64 0, !"_ZTSFivE"} 76 !3 = !{i64 0, i64 222} 77 !4 = !{i64 16, !"_ZTS1A"} 78 !5 = !{i64 16, i64 333} 79 !6 = !{i64 16, !"_ZTS1B"} 80 !7 = !{i64 16, i64 444} 81 !8 = !{i32 4, !"Cross-DSO CFI", i32 1} 82