1 // RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-intrinsics -emit-llvm %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -triple aarch64-elf -fptrauth-intrinsics -emit-llvm %s -o - | FileCheck %s
6 // CHECK: @ptr1 = global ptr ptrauth (ptr @external, i32 0)
7 void *ptr1
= __builtin_ptrauth_sign_constant(&external
, 0, 0);
9 // CHECK: @ptr2 = global ptr ptrauth (ptr @external, i32 0, i64 1234)
10 void *ptr2
= __builtin_ptrauth_sign_constant(&external
, 0, 1234);
12 // CHECK: @ptr3 = global ptr ptrauth (ptr @external, i32 2, i64 0, ptr @ptr3)
13 void *ptr3
= __builtin_ptrauth_sign_constant(&external
, 2, &ptr3
);
15 // CHECK: @ptr4 = global ptr ptrauth (ptr @external, i32 2, i64 26, ptr @ptr4)
16 void *ptr4
= __builtin_ptrauth_sign_constant(&external
, 2, __builtin_ptrauth_blend_discriminator(&ptr4
, 26));
18 // CHECK: @ptr5 = global ptr null
21 void test_sign_constant_code() {
22 // CHECK-LABEL: define {{.*}}void @test_sign_constant_code()
24 // CHECK-NEXT: store ptr ptrauth (ptr @external, i32 0), ptr @ptr1, align 8
25 // CHECK-NEXT: store ptr ptrauth (ptr @external, i32 2, i64 1234), ptr @ptr2, align 8
26 // CHECK-NEXT: store ptr ptrauth (ptr @external, i32 2, i64 0, ptr @ptr3), ptr @ptr3, align 8
27 // CHECK-NEXT: store ptr ptrauth (ptr @external, i32 2, i64 1234, ptr @ptr4), ptr @ptr4, align 8
28 // CHECK-NEXT: ret void
29 ptr1
= __builtin_ptrauth_sign_constant(&external
, 0, 0);
30 ptr2
= __builtin_ptrauth_sign_constant(&external
, 2, 1234);
31 ptr3
= __builtin_ptrauth_sign_constant(&external
, 2, &ptr3
);
32 ptr4
= __builtin_ptrauth_sign_constant(&external
, 2, __builtin_ptrauth_blend_discriminator(&ptr4
, 1234));