llvm-project/clang/test/CodeGen/ptrauth-function-lvalue-cast.c
Ahmed Bougacha e23250ecb7
[clang] Implement function pointer signing and authenticated function calls (#93906)
The functions are currently always signed/authenticated with zero
discriminator.

Co-Authored-By: John McCall <rjmccall@apple.com>
2024-06-21 10:20:15 -07:00

25 lines
722 B
C

// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- | FileCheck %s
// RUN: %clang_cc1 %s -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- | FileCheck %s
typedef void (*fptr_t)(void);
char *cptr;
void (*fptr)(void);
// CHECK: define {{(dso_local )?}}void @test1
void test1() {
// CHECK: [[LOAD:%.*]] = load ptr, ptr @cptr
// CHECK: call void [[LOAD]]() [ "ptrauth"(i32 0, i64 0) ]
// CHECK: ret void
(*(fptr_t)cptr)();
}
// CHECK: define {{(dso_local )?}}i8 @test2
char test2() {
return *(char *)fptr;
// CHECK: [[LOAD:%.*]] = load ptr, ptr @fptr
// CHECK: [[LOAD1:%.*]] = load i8, ptr [[LOAD]]
// CHECK: ret i8 [[LOAD1]]
}