Skip to content

Commit 2ed0453

Browse files
committed
-fsanitize=function: Add a MSVC test case
1 parent 2147e9e commit 2ed0453

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

clang/test/CodeGen/ubsan-function.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -fsanitize=function -fno-sanitize-recover=all | FileCheck %s --check-prefixes=CHECK,64
2-
// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s -fsanitize=function -fno-sanitize-recover=all | FileCheck %s --check-prefixes=CHECK,64
3-
// RUN: %clang_cc1 -triple aarch64_be-linux-gnu -emit-llvm -o - %s -fsanitize=function -fno-sanitize-recover=all | FileCheck %s --check-prefixes=CHECK,64
4-
// RUN: %clang_cc1 -triple arm-none-eabi -emit-llvm -o - %s -fsanitize=function -fno-sanitize-recover=all | FileCheck %s --check-prefixes=CHECK,ARM,32
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
56

6-
// CHECK: define{{.*}} void @_Z3funv() #0 !func_sanitize ![[FUNCSAN:.*]] {
7+
// GNU: define{{.*}} void @_Z3funv() #0 !func_sanitize ![[FUNCSAN:.*]] {
8+
// MSVC: define{{.*}} void @"?fun@@YAXXZ"() #0 !func_sanitize ![[FUNCSAN:.*]] {
79
void fun() {}
810

9-
// CHECK-LABEL: define{{.*}} void @_Z6callerPFvvE(ptr noundef %f)
11+
// GNU-LABEL: define{{.*}} void @_Z6callerPFvvE(ptr noundef %f)
12+
// MSVC-LABEL: define{{.*}} void @"?caller@@YAXP6AXXZ@Z"(ptr noundef %f)
1013
// ARM: ptrtoint ptr {{.*}} to i32, !nosanitize !5
1114
// ARM: and i32 {{.*}}, -2, !nosanitize !5
1215
// ARM: inttoptr i32 {{.*}} to ptr, !nosanitize !5
@@ -17,7 +20,8 @@ void fun() {}
1720
// CHECK: [[LABEL1]]:
1821
// CHECK: getelementptr <{ i32, i32 }>, ptr {{.*}}, i32 -1, i32 1, !nosanitize
1922
// CHECK: load i32, ptr {{.*}}, align {{.*}}, !nosanitize
20-
// CHECK: icmp eq i32 {{.*}}, 905068220, !nosanitize
23+
// GNU: icmp eq i32 {{.*}}, 905068220, !nosanitize
24+
// MSVC: icmp eq i32 {{.*}}, -1600339357, !nosanitize
2125
// CHECK: br i1 {{.*}}, label %[[LABEL3:.*]], label %[[LABEL2:[^,]*]], {{.*}}!nosanitize
2226
// CHECK: [[LABEL2]]:
2327
// 64: call void @__ubsan_handle_function_type_mismatch_abort(ptr @[[#]], i64 %[[#]]) #[[#]], !nosanitize
@@ -32,4 +36,5 @@ void fun() {}
3236
// CHECK-NEXT: ret void
3337
void caller(void (*f)()) { f(); }
3438

35-
// CHECK: ![[FUNCSAN]] = !{i32 -1056584962, i32 905068220}
39+
// GNU: ![[FUNCSAN]] = !{i32 -1056584962, i32 905068220}
40+
// MSVC: ![[FUNCSAN]] = !{i32 -1056584962, i32 -1600339357}

0 commit comments

Comments
 (0)