14914d33bSMatheus Izvekov // 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
24914d33bSMatheus Izvekov // 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
34914d33bSMatheus Izvekov // RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s -fsanitize=function -fno-sanitize-recover=all | FileCheck %s --check-prefixes=CHECK,GNU,64
44914d33bSMatheus Izvekov // 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
54914d33bSMatheus Izvekov // 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
64914d33bSMatheus Izvekov
74914d33bSMatheus Izvekov // GNU: define{{.*}} void @_Z3funv() #0 !func_sanitize ![[FUNCSAN:.*]] {
84914d33bSMatheus Izvekov // MSVC: define{{.*}} void @"?fun@@YA?A?<auto>@@XZ"() #0 !func_sanitize ![[FUNCSAN:.*]] {
fun()94914d33bSMatheus Izvekov auto fun() {}
104914d33bSMatheus Izvekov
114914d33bSMatheus Izvekov // GNU-LABEL: define{{.*}} void @_Z6callerv()
124914d33bSMatheus Izvekov // MSVC-LABEL: define{{.*}} void @"?caller@@YAXXZ"()
134914d33bSMatheus Izvekov // ARM: ptrtoint ptr {{.*}} to i32, !nosanitize !4
144914d33bSMatheus Izvekov // ARM: and i32 {{.*}}, -2, !nosanitize !4
154914d33bSMatheus Izvekov // ARM: inttoptr i32 {{.*}} to ptr, !nosanitize !4
164914d33bSMatheus Izvekov // CHECK: getelementptr <{ i32, i32 }>, ptr {{.*}}, i32 -1, i32 0, !nosanitize
174914d33bSMatheus Izvekov // CHECK: load i32, ptr {{.*}}, align {{.*}}, !nosanitize
184914d33bSMatheus Izvekov // CHECK: icmp eq i32 {{.*}}, -1056584962, !nosanitize
194914d33bSMatheus Izvekov // CHECK: br i1 {{.*}}, label %[[LABEL1:.*]], label %[[LABEL4:.*]], !nosanitize
204914d33bSMatheus Izvekov // CHECK: [[LABEL1]]:
214914d33bSMatheus Izvekov // CHECK: getelementptr <{ i32, i32 }>, ptr {{.*}}, i32 -1, i32 1, !nosanitize
224914d33bSMatheus Izvekov // CHECK: load i32, ptr {{.*}}, align {{.*}}, !nosanitize
234914d33bSMatheus Izvekov // GNU: icmp eq i32 {{.*}}, 905068220, !nosanitize
244914d33bSMatheus Izvekov // MSVC: icmp eq i32 {{.*}}, -1600339357, !nosanitize
254914d33bSMatheus Izvekov // CHECK: br i1 {{.*}}, label %[[LABEL3:.*]], label %[[LABEL2:[^,]*]], {{.*}}!nosanitize
264914d33bSMatheus Izvekov // CHECK: [[LABEL2]]:
274914d33bSMatheus Izvekov // 64: call void @__ubsan_handle_function_type_mismatch_abort(ptr @[[#]], i64 %[[#]]) #[[#]], !nosanitize
284914d33bSMatheus Izvekov // 32: call void @__ubsan_handle_function_type_mismatch_abort(ptr @[[#]], i32 %[[#]]) #[[#]], !nosanitize
294914d33bSMatheus Izvekov // CHECK-NEXT: unreachable, !nosanitize
304914d33bSMatheus Izvekov // CHECK-EMPTY:
314914d33bSMatheus Izvekov // CHECK-NEXT: [[LABEL3]]:
324914d33bSMatheus Izvekov // CHECK: br label %[[LABEL4]], !nosanitize
334914d33bSMatheus Izvekov // CHECK-EMPTY:
344914d33bSMatheus Izvekov // CHECK-NEXT: [[LABEL4]]:
354914d33bSMatheus Izvekov // CHECK-NEXT: call void
364914d33bSMatheus Izvekov // CHECK-NEXT: ret void
caller()374914d33bSMatheus Izvekov void caller() {
384914d33bSMatheus Izvekov auto a = fun;
394914d33bSMatheus Izvekov a();
404914d33bSMatheus Izvekov }
414914d33bSMatheus Izvekov
424914d33bSMatheus Izvekov // GNU: ![[FUNCSAN]] = !{i32 -1056584962, i32 905068220}
43*9c89b295SMatheus Izvekov // MSVC: ![[FUNCSAN]] = !{i32 -1056584962, i32 -1600339357}
44