| 1 |
// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm %s -o - | FileCheck -check-prefix=CHECK %s |
| 2 |
// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-intrinsics -emit-llvm %s -o - | FileCheck -check-prefix=CHECK %s |
| 3 |
|
| 4 |
void test_call(); |
| 5 |
|
| 6 |
// CHECK: define {{(dso_local )?}}void @test_direct_call() |
| 7 |
void test_direct_call() { |
| 8 |
// CHECK: call void @test_call(){{$}} |
| 9 |
test_call(); |
| 10 |
} |
| 11 |
|
| 12 |
// CHECK: define {{(dso_local )?}}void @test_indirect_call(ptr noundef %[[FP:.*]]) |
| 13 |
void test_indirect_call(void (*fp(void))) { |
| 14 |
// CHECK: %[[FP_ADDR:.*]] = alloca ptr, align 8 |
| 15 |
// CHECK: store ptr %[[FP]], ptr %[[FP_ADDR]], align 8 |
| 16 |
// CHECK: %[[V0:.*]] = load ptr, ptr %[[FP_ADDR]], align 8 |
| 17 |
// CHECK: %[[CALL:.*]] = call ptr %[[V0]]() [ "ptrauth"(i32 0, i64 0) ] |
| 18 |
fp(); |
| 19 |
} |
| 20 |
|
| 21 |
void abort(); |
| 22 |
// CHECK: define {{(dso_local )?}}void @test_direct_builtin_call() |
| 23 |
void test_direct_builtin_call() { |
| 24 |
// CHECK: call void @abort() {{#[0-9]+$}} |
| 25 |
abort(); |
| 26 |
} |
| 27 |
|
| 28 |
// CHECK-LABEL: define {{(dso_local )?}}void @test_memcpy_inline( |
| 29 |
// CHECK-NOT: call{{.*}}memcpy |
| 30 |
|
| 31 |
extern inline __attribute__((__always_inline__)) |
| 32 |
void *memcpy(void *d, const void *s, unsigned long) { |
| 33 |
return 0; |
| 34 |
} |
| 35 |
|
| 36 |
void test_memcpy_inline(char *d, char *s) { |
| 37 |
memcpy(d, s, 4); |
| 38 |
} |