[AArch64] Add fpext and fpround costs (#119292)
[llvm-project.git] / clang / test / CodeGen / cfi-check-fail2.c
blobd904ee41f607b1b7da9230ba01a1195db6269f79
1 // __cfi_check_fail codegen when not all CFI checkers are enabled.
2 // RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \
3 // RUN: -fsanitize=cfi-vcall \
4 // RUN: -emit-llvm -o - %s | FileCheck %s
6 // Check that ignorelist does not affect generated code.
7 // RUN: echo "src:*" > %t-all.ignorelist
8 // RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \
9 // RUN: -fsanitize=cfi-vcall -fsanitize-ignorelist=%t-all.ignorelist \
10 // RUN: -emit-llvm -o - %s | FileCheck %s
12 void caller(void (*f)(void)) {
13 f();
16 // CHECK: define weak_odr hidden void @__cfi_check_fail(ptr noundef %0, ptr noundef %1)
17 // CHECK: store ptr %0, ptr %[[ALLOCA0:.*]], align 8
18 // CHECK: store ptr %1, ptr %[[ALLOCA1:.*]], align 8
19 // CHECK: %[[DATA:.*]] = load ptr, ptr %[[ALLOCA0]], align 8
20 // CHECK: %[[ADDR:.*]] = load ptr, ptr %[[ALLOCA1]], align 8
21 // CHECK: %[[ICMP_NOT_NULL:.*]] = icmp ne ptr %[[DATA]], null
22 // CHECK: br i1 %[[ICMP_NOT_NULL]], label %[[CONT0:.*]], label %[[TRAP:.*]],
24 // CHECK: [[TRAP]]:
25 // CHECK-NEXT: call void @llvm.ubsantrap(i8 2)
26 // CHECK-NEXT: unreachable
28 // CHECK: [[CONT0]]:
29 // CHECK: %[[KINDPTR:.*]] = getelementptr {{.*}} %[[DATA]], i32 0, i32 0
30 // CHECK: %[[KIND:.*]] = load i8, ptr %[[KINDPTR]], align 4
31 // CHECK: %[[VTVALID0:.*]] = call i1 @llvm.type.test(ptr %[[ADDR]], metadata !"all-vtables")
32 // CHECK: %[[VTVALID:.*]] = zext i1 %[[VTVALID0]] to i64
33 // CHECK: %[[NOT_0:.*]] = icmp ne i8 %[[KIND]], 0
34 // CHECK: br i1 %[[NOT_0]], label %[[CONT1:.*]], label %[[HANDLE0:.*]], !prof
36 // CHECK: [[HANDLE0]]:
37 // CHECK: %[[DATA0:.*]] = ptrtoint ptr %[[DATA]] to i64,
38 // CHECK: %[[ADDR0:.*]] = ptrtoint ptr %[[ADDR]] to i64,
39 // CHECK: call void @__ubsan_handle_cfi_check_fail_abort(i64 %[[DATA0]], i64 %[[ADDR0]], i64 %[[VTVALID]])
40 // CHECK: unreachable
42 // CHECK: [[CONT1]]:
43 // CHECK: %[[NOT_1:.*]] = icmp ne i8 %[[KIND]], 1
44 // CHECK: br i1 %[[NOT_1]], label %[[CONT2:.*]], label %[[HANDLE1:.*]], !nosanitize
46 // CHECK: [[HANDLE1]]:
47 // CHECK-NEXT: call void @llvm.ubsantrap(i8 2)
48 // CHECK-NEXT: unreachable
50 // CHECK: [[CONT2]]:
51 // CHECK: %[[NOT_2:.*]] = icmp ne i8 %[[KIND]], 2
52 // CHECK: br i1 %[[NOT_2]], label %[[CONT3:.*]], label %[[HANDLE2:.*]], !nosanitize
54 // CHECK: [[HANDLE2]]:
55 // CHECK-NEXT: call void @llvm.ubsantrap(i8 2)
56 // CHECK-NEXT: unreachable
58 // CHECK: [[CONT3]]:
59 // CHECK: %[[NOT_3:.*]] = icmp ne i8 %[[KIND]], 3
60 // CHECK: br i1 %[[NOT_3]], label %[[CONT4:.*]], label %[[HANDLE3:.*]], !nosanitize
62 // CHECK: [[HANDLE3]]:
63 // CHECK-NEXT: call void @llvm.ubsantrap(i8 2)
64 // CHECK-NEXT: unreachable
66 // CHECK: [[CONT4]]:
67 // CHECK: %[[NOT_4:.*]] = icmp ne i8 %[[KIND]], 4
68 // CHECK: br i1 %[[NOT_4]], label %[[CONT5:.*]], label %[[HANDLE4:.*]], !nosanitize
70 // CHECK: [[HANDLE4]]:
71 // CHECK-NEXT: call void @llvm.ubsantrap(i8 2)
72 // CHECK-NEXT: unreachable
74 // CHECK: [[CONT5]]:
75 // CHECK: ret void