Skip to content

Commit ab262e5

Browse files
committed
Add ELF tests for llvm#98847 (fptr resigning)
1 parent 559d880 commit ab262e5

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

clang/test/CodeGen/ptrauth-function-lvalue-cast-disc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- -fptrauth-function-pointer-type-discrimination | FileCheck -check-prefixes CHECK,TYPE %s
2+
// RUN: %clang_cc1 %s -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- -fptrauth-function-pointer-type-discrimination | FileCheck -check-prefixes CHECK,TYPE %s
23
// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- | FileCheck -check-prefixes CHECK,ZERO %s
4+
// RUN: %clang_cc1 %s -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- | FileCheck -check-prefixes CHECK,ZERO %s
35

46
typedef void (*fptr_t)(void);
57

68
char *cptr;
79
void (*fptr)(void);
810

9-
// CHECK-LABEL: define void @test1
11+
// CHECK-LABEL: define{{.*}} void @test1
1012
void test1() {
1113
// TYPE: [[LOAD:%.*]] = load ptr, ptr @cptr
1214
// TYPE: [[TOINT:%.*]] = ptrtoint ptr [[LOAD]] to i64
@@ -17,7 +19,7 @@ void test1() {
1719
(*(fptr_t)cptr)();
1820
}
1921

20-
// CHECK-LABEL: define i8 @test2
22+
// CHECK-LABEL: define{{.*}} i8 @test2
2123
char test2() {
2224
return *(char *)fptr;
2325

@@ -35,7 +37,7 @@ char test2() {
3537
// ZERO-NOT: @llvm.ptrauth.resign
3638
}
3739

38-
// CHECK-LABEL: define void @test4
40+
// CHECK-LABEL: define{{.*}} void @test4
3941
void test4() {
4042
(*((fptr_t)(&*((char *)(&*(fptr_t)cptr)))))();
4143

@@ -49,7 +51,7 @@ void test4() {
4951
}
5052

5153
void *vptr;
52-
// CHECK-LABEL: define void @test5
54+
// CHECK-LABEL: define{{.*}} void @test5
5355
void test5() {
5456
vptr = &*(char *)fptr;
5557

clang/test/CodeGen/ptrauth-function-type-discriminator-cast.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1-
// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,TYPE
2-
// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,ZERO
3-
// RUN: %clang_cc1 -xc++ %s -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,CHECKCXX,TYPE,TYPECXX
1+
// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics \
2+
// RUN: -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,TYPE
3+
4+
// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
5+
// RUN: -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,TYPE
6+
7+
// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics \
8+
// RUN: -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,ZERO
9+
10+
// RUN: %clang_cc1 %s -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
11+
// RUN: -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,ZERO
12+
13+
// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics \
14+
// RUN: -disable-llvm-passes -emit-llvm -xc++ -o- | FileCheck %s --check-prefixes=CHECK,CHECKCXX,TYPE,TYPECXX
15+
16+
// RUN: %clang_cc1 %s -fptrauth-function-pointer-type-discrimination -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics \
17+
// RUN: -disable-llvm-passes -emit-llvm -xc++ -o- | FileCheck %s --check-prefixes=CHECK,CHECKCXX,TYPE,TYPECXX
418

519
#ifdef __cplusplus
620
extern "C" {
@@ -19,12 +33,12 @@ struct ptr_member {
1933
ptr_member pm;
2034
void (*test_member)() = (void (*)())pm.fptr_;
2135

22-
// CHECKCXX-LABEL: define internal void @__cxx_global_var_init
36+
// CHECKCXX-LABEL: define{{.*}} internal void @__cxx_global_var_init
2337
// TYPECXX: call i64 @llvm.ptrauth.resign(i64 {{.*}}, i32 0, i64 2712, i32 0, i64 18983)
2438
#endif
2539

2640

27-
// CHECK-LABEL: define void @test_cast_to_opaque
41+
// CHECK-LABEL: define{{.*}} void @test_cast_to_opaque
2842
void test_cast_to_opaque() {
2943
opaque = (void *)f;
3044

@@ -33,7 +47,7 @@ void test_cast_to_opaque() {
3347
// ZERO-NOT: @llvm.ptrauth.resign
3448
}
3549

36-
// CHECK-LABEL: define void @test_cast_from_opaque
50+
// CHECK-LABEL: define{{.*}} void @test_cast_from_opaque
3751
void test_cast_from_opaque() {
3852
fptr = (void (*)(void))opaque;
3953

@@ -48,7 +62,7 @@ void test_cast_from_opaque() {
4862
// ZERO-NOT: @llvm.ptrauth.resign
4963
}
5064

51-
// CHECK-LABEL: define void @test_cast_to_intptr
65+
// CHECK-LABEL: define{{.*}} void @test_cast_to_intptr
5266
void test_cast_to_intptr() {
5367
uintptr = (unsigned long)fptr;
5468

@@ -69,14 +83,14 @@ void test_cast_to_intptr() {
6983
// ZERO-NOT: @llvm.ptrauth.resign
7084
}
7185

72-
// CHECK-LABEL: define void @test_function_to_function_cast
86+
// CHECK-LABEL: define{{.*}} void @test_function_to_function_cast
7387
void test_function_to_function_cast() {
7488
void (*fptr2)(int) = (void (*)(int))fptr;
7589
// TYPE: call i64 @llvm.ptrauth.resign(i64 {{.*}}, i32 0, i64 18983, i32 0, i64 2712)
7690
// ZERO-NOT: @llvm.ptrauth.resign
7791
}
7892

79-
// CHECK-LABEL: define void @test_call_lvalue_cast
93+
// CHECK-LABEL: define{{.*}} void @test_call_lvalue_cast
8094
void test_call_lvalue_cast() {
8195
(*(void (*)(int))f)(42);
8296

0 commit comments

Comments
 (0)