|
1 | 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 |
2 | | -// 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 |
| 2 | +// 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 --check-prefixes=CHECK,CHECK-CXX %s |
3 | 3 |
|
4 | 4 | #ifdef __cplusplus |
5 | 5 | extern "C" { |
6 | 6 | #endif |
7 | 7 |
|
8 | 8 | void (*fptr)(void); |
9 | 9 | void (* __ptrauth(0, 0, 42) f2ptr_42_discm)(int); |
| 10 | +void f(int); |
| 11 | +void (* const __ptrauth(0, 0, 42) f_const_ptr)(int) = &f; |
10 | 12 |
|
11 | 13 | // CHECK-LABEL: define void @test_assign_to_qualified |
12 | 14 | void test_assign_to_qualified() { |
@@ -70,6 +72,24 @@ void test_assign_from_qualified() { |
70 | 72 | // CHECK-NEXT store void ()* [[FPTR10]], void ()** @f2ptr_42_discm |
71 | 73 | } |
72 | 74 |
|
| 75 | +// CHECK-LABEL: define void @test_const_ptr_function_call() |
| 76 | +void test_const_ptr_function_call(void) { |
| 77 | + f_const_ptr(1); |
| 78 | + |
| 79 | + // CHECK: call void ptrauth (ptr @f, i32 0, i64 2712)(i32 noundef 1) [ "ptrauth"(i32 0, i64 2712) ] |
| 80 | +} |
| 81 | + |
73 | 82 | #ifdef __cplusplus |
| 83 | +void (* get_fptr(void))(int); |
| 84 | +void (* __ptrauth(0, 0, 42) f_const_ptr2)(int) = get_fptr(); |
| 85 | +void (* const __ptrauth(0, 0, 42) &f_ref)(int) = f_const_ptr2; |
| 86 | + |
| 87 | +// CHECK-CXX-LABEL: define void @test_const_ptr_ref_function_call() |
| 88 | +void test_const_ptr_ref_function_call(void) { |
| 89 | + f_ref(1); |
| 90 | + |
| 91 | + // CHECK-CXX: %[[V0:.*]] = load ptr, ptr @f_const_ptr2, align 8 |
| 92 | + // CHECK-CXX: call void %[[V0]](i32 noundef 1) [ "ptrauth"(i32 0, i64 42) ] |
| 93 | +} |
74 | 94 | } |
75 | 95 | #endif |
0 commit comments