Skip to content

Commit d1f35a5

Browse files
committed
Remove unused functions and add test case
1 parent 0e85001 commit d1f35a5

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

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4410,9 +4410,6 @@ class CodeGenFunction : public CodeGenTypeCache {
44104410
llvm::Value *storageAddress,
44114411
GlobalDecl calleeDecl,
44124412
QualType calleeType);
4413-
llvm::Value *EmitPointerAuthSign(QualType pointeeType, llvm::Value *pointer);
4414-
llvm::Value *EmitPointerAuthSign(const CGPointerAuthInfo &info,
4415-
llvm::Value *pointer);
44164413
void EmitPointerAuthOperandBundle(
44174414
const CGPointerAuthInfo &info,
44184415
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)