1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -fsanitize=function -fno-sanitize-recover=all | FileCheck %s --check-prefixes=CHECK,GNU,64
2 // RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm -o - %s -fsanitize=function -fno-sanitize-recover=all | FileCheck %s --check-prefixes=CHECK,MSVC,64
3 // RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s -fsanitize=function -fno-sanitize-recover=all | FileCheck %s --check-prefixes=CHECK,GNU,64
4 // RUN: %clang_cc1 -triple aarch64_be-linux-gnu -emit-llvm -o - %s -fsanitize=function -fno-sanitize-recover=all | FileCheck %s --check-prefixes=CHECK,GNU,64
5 // RUN: %clang_cc1 -triple arm-none-eabi -emit-llvm -o - %s -fsanitize=function -fno-sanitize-recover=all | FileCheck %s --check-prefixes=CHECK,ARM,GNU,32
7 // GNU: define{{.*}} void @_Z3funv() #0 !func_sanitize ![[FUNCSAN:.*]] {
8 // MSVC: define{{.*}} void @"?fun@@YA?A?<auto>@@XZ"() #0 !func_sanitize ![[FUNCSAN:.*]] {
11 // GNU-LABEL: define{{.*}} void @_Z6callerv()
12 // MSVC-LABEL: define{{.*}} void @"?caller@@YAXXZ"()
13 // ARM: ptrtoint ptr {{.*}} to i32, !nosanitize !4
14 // ARM: and i32 {{.*}}, -2, !nosanitize !4
15 // ARM: inttoptr i32 {{.*}} to ptr, !nosanitize !4
16 // CHECK: getelementptr <{ i32, i32 }>, ptr {{.*}}, i32 -1, i32 0, !nosanitize
17 // CHECK: load i32, ptr {{.*}}, align {{.*}}, !nosanitize
18 // CHECK: icmp eq i32 {{.*}}, -1056584962, !nosanitize
19 // CHECK: br i1 {{.*}}, label %[[LABEL1:.*]], label %[[LABEL4:.*]], !nosanitize
21 // CHECK: getelementptr <{ i32, i32 }>, ptr {{.*}}, i32 -1, i32 1, !nosanitize
22 // CHECK: load i32, ptr {{.*}}, align {{.*}}, !nosanitize
23 // GNU: icmp eq i32 {{.*}}, 905068220, !nosanitize
24 // MSVC: icmp eq i32 {{.*}}, -1600339357, !nosanitize
25 // CHECK: br i1 {{.*}}, label %[[LABEL3:.*]], label %[[LABEL2:[^,]*]], {{.*}}!nosanitize
27 // 64: call void @__ubsan_handle_function_type_mismatch_abort(ptr @[[#]], i64 %[[#]]) #[[#]], !nosanitize
28 // 32: call void @__ubsan_handle_function_type_mismatch_abort(ptr @[[#]], i32 %[[#]]) #[[#]], !nosanitize
29 // CHECK-NEXT: unreachable, !nosanitize
31 // CHECK-NEXT: [[LABEL3]]:
32 // CHECK: br label %[[LABEL4]], !nosanitize
34 // CHECK-NEXT: [[LABEL4]]:
35 // CHECK-NEXT: call void
36 // CHECK-NEXT: ret void
42 // GNU: ![[FUNCSAN]] = !{i32 -1056584962, i32 905068220}
43 // MSVC: ![[FUNCSAN]] = !{i32 -1056584962, i32 -1600339357}