Skip to content

Commit 4cebec2

Browse files
ahatanakahmedbougacha
authored andcommitted
Remove unused functions and add test case
1 parent 016baec commit 4cebec2

File tree

3 files changed

+28
-39
lines changed

3 files changed

+28
-39
lines changed

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3064,39 +3064,3 @@ void CodeGenFunction::EmitPointerAuthOperandBundle(
30643064
llvm::Value *args[] = {key, discriminator};
30653065
bundles.emplace_back("ptrauth", args);
30663066
}
3067-
3068-
static llvm::Value *EmitPointerAuthCommon(CodeGenFunction &CGF,
3069-
const CGPointerAuthInfo &pointerAuth,
3070-
llvm::Value *pointer,
3071-
unsigned intrinsicID) {
3072-
if (!pointerAuth)
3073-
return pointer;
3074-
3075-
auto key = CGF.Builder.getInt32(pointerAuth.getKey());
3076-
3077-
llvm::Value *discriminator = pointerAuth.getDiscriminator();
3078-
if (!discriminator) {
3079-
discriminator = CGF.Builder.getSize(0);
3080-
}
3081-
3082-
// Convert the pointer to intptr_t before signing it.
3083-
auto origType = pointer->getType();
3084-
pointer = CGF.Builder.CreatePtrToInt(pointer, CGF.IntPtrTy);
3085-
3086-
// call i64 @llvm.ptrauth.sign.i64(i64 %pointer, i32 %key, i64 %discriminator)
3087-
auto intrinsic = CGF.CGM.getIntrinsic(intrinsicID);
3088-
pointer = CGF.EmitRuntimeCall(intrinsic, {pointer, key, discriminator});
3089-
3090-
// Convert back to the original type.
3091-
pointer = CGF.Builder.CreateIntToPtr(pointer, origType);
3092-
return pointer;
3093-
}
3094-
3095-
llvm::Value *
3096-
CodeGenFunction::EmitPointerAuthSign(const CGPointerAuthInfo &pointerAuth,
3097-
llvm::Value *pointer) {
3098-
if (!pointerAuth.shouldSign())
3099-
return pointer;
3100-
return EmitPointerAuthCommon(*this, pointerAuth, pointer,
3101-
llvm::Intrinsic::ptrauth_sign);
3102-
}

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4420,9 +4420,6 @@ class CodeGenFunction : public CodeGenTypeCache {
44204420
llvm::Value *storageAddress,
44214421
GlobalDecl calleeDecl,
44224422
QualType calleeType);
4423-
llvm::Value *EmitPointerAuthSign(QualType pointeeType, llvm::Value *pointer);
4424-
llvm::Value *EmitPointerAuthSign(const CGPointerAuthInfo &info,
4425-
llvm::Value *pointer);
44264423
void EmitPointerAuthOperandBundle(
44274424
const CGPointerAuthInfo &info,
44284425
SmallVectorImpl<llvm::OperandBundleDef> &bundles);

clang/test/CodeGen/ptrauth-function.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm %s -o - | FileCheck -check-prefix=CHECK %s
2+
3+
void test_call();
4+
5+
// CHECK-LABEL: define void @test_direct_call()
6+
void test_direct_call() {
7+
// CHECK: call void @test_call(){{$}}
8+
test_call();
9+
}
10+
11+
void abort();
12+
// CHECK-LABEL: define void @test_direct_builtin_call()
13+
void test_direct_builtin_call() {
14+
// CHECK: call void @abort() {{#[0-9]+$}}
15+
abort();
16+
}
17+
18+
// CHECK-LABEL: define void @test_memcpy_inline(
19+
// CHECK-NOT: call{{.*}}memcpy
20+
21+
extern inline __attribute__((__always_inline__))
22+
void *memcpy(void *d, const void *s, unsigned long) {
23+
return 0;
24+
}
25+
26+
void test_memcpy_inline(char *d, char *s) {
27+
memcpy(d, s, 4);
28+
}

0 commit comments

Comments
 (0)