[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-18 Thread Akira Hatanaka via cfe-commits
https://github.com/ahatanak closed https://github.com/llvm/llvm-project/pull/98847 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-17 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 approved this pull request. LGTM, thanks @ahatanak ! https://github.com/llvm/llvm-project/pull/98847 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Akira Hatanaka via cfe-commits
@@ -0,0 +1,55 @@ +// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- -fptrauth-function-pointer-type-discrimination | FileCheck %s ahatanak wrote: Thanks! Please add a line to test linux after this PR is merged

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Akira Hatanaka via cfe-commits
@@ -351,3 +434,125 @@ CodeGenModule::getVTablePointerAuthInfo(CodeGenFunction *CGF, /* IsIsaPointer */ false, /* AuthenticatesNullValues */ false, Discriminator); } + +llvm::Value *CodeGenFunction::AuthPointerToPointerCast(

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Akira Hatanaka via cfe-commits
@@ -0,0 +1,77 @@ +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm %s -o - | FileCheck -check-prefix=CHECK -check-prefix=NOPCH %s ahatanak wrote: Sorry, I just realized th

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Akira Hatanaka via cfe-commits
@@ -165,6 +166,88 @@ CGPointerAuthInfo CodeGenModule::getPointerAuthInfoForType(QualType T) { return ::getPointerAuthInfoForType(*this, T); } +static bool isZeroConstant(llvm::Value *value) { + if (auto ci = dyn_cast(value)) +return ci->isZero(); + return false; +} +

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Akira Hatanaka via cfe-commits
@@ -165,6 +166,88 @@ CGPointerAuthInfo CodeGenModule::getPointerAuthInfoForType(QualType T) { return ::getPointerAuthInfoForType(*this, T); } +static bool isZeroConstant(llvm::Value *value) { + if (auto ci = dyn_cast(value)) +return ci->isZero(); + return false; +} +

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Akira Hatanaka via cfe-commits
@@ -165,6 +166,88 @@ CGPointerAuthInfo CodeGenModule::getPointerAuthInfoForType(QualType T) { return ::getPointerAuthInfoForType(*this, T); } +static bool isZeroConstant(llvm::Value *value) { ahatanak wrote: I fixed the names of variables and functions add

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Akira Hatanaka via cfe-commits
@@ -3126,3 +3137,57 @@ CodeGenFunction::EmitPointerAuthAuth(const CGPointerAuthInfo &PointerAuth, return EmitPointerAuthCommon(*this, PointerAuth, Pointer, llvm::Intrinsic::ptrauth_auth); } + +llvm::Value *CodeGenFunction::EmitPointerAuthSign(Q

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Akira Hatanaka via cfe-commits
@@ -2373,7 +2373,9 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { DestLV.setTBAAInfo(TBAAAccessInfo::getMayAliasInfo()); return EmitLoadOfLValue(DestLV, CE->getExprLoc()); } -return Builder.CreateBitCast(Src, DstTy); + +llvm::Value *Result =

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 edited https://github.com/llvm/llvm-project/pull/98847 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 commented: Mostly LGTM. There are several new pretty minor comments, but they can be addressed in a follor-up PR. The thing which is better to be addressed as a part of this PR is deleting three unneeded member functions from `CodeGenFunction`. IMHO there is no reas

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Daniil Kovalev via cfe-commits
@@ -351,3 +434,125 @@ CodeGenModule::getVTablePointerAuthInfo(CodeGenFunction *CGF, /* IsIsaPointer */ false, /* AuthenticatesNullValues */ false, Discriminator); } + +llvm::Value *CodeGenFunction::AuthPointerToPointerCast(

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Daniil Kovalev via cfe-commits
@@ -3126,3 +3137,57 @@ CodeGenFunction::EmitPointerAuthAuth(const CGPointerAuthInfo &PointerAuth, return EmitPointerAuthCommon(*this, PointerAuth, Pointer, llvm::Intrinsic::ptrauth_auth); } + +llvm::Value *CodeGenFunction::EmitPointerAuthSign(Q

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 edited https://github.com/llvm/llvm-project/pull/98847 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Daniil Kovalev via cfe-commits
@@ -2373,7 +2373,9 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { DestLV.setTBAAInfo(TBAAAccessInfo::getMayAliasInfo()); return EmitLoadOfLValue(DestLV, CE->getExprLoc()); } -return Builder.CreateBitCast(Src, DstTy); + +llvm::Value *Result =

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-16 Thread Daniil Kovalev via cfe-commits
@@ -4434,16 +4433,41 @@ class CodeGenFunction : public CodeGenTypeCache { llvm::Value *StorageAddress, GlobalDecl SchemaDecl, QualType SchemaType); + llvm:

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 edited https://github.com/llvm/llvm-project/pull/98847 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -3126,3 +3137,57 @@ CodeGenFunction::EmitPointerAuthAuth(const CGPointerAuthInfo &PointerAuth, return EmitPointerAuthCommon(*this, PointerAuth, Pointer, llvm::Intrinsic::ptrauth_auth); } + +llvm::Value *CodeGenFunction::EmitPointerAuthSign(Q

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -165,6 +166,88 @@ CGPointerAuthInfo CodeGenModule::getPointerAuthInfoForType(QualType T) { return ::getPointerAuthInfoForType(*this, T); } +static bool isZeroConstant(llvm::Value *value) { + if (auto ci = dyn_cast(value)) +return ci->isZero(); + return false; +} +

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -3126,3 +3137,57 @@ CodeGenFunction::EmitPointerAuthAuth(const CGPointerAuthInfo &PointerAuth, return EmitPointerAuthCommon(*this, PointerAuth, Pointer, llvm::Intrinsic::ptrauth_auth); } + +llvm::Value *CodeGenFunction::EmitPointerAuthSign(Q

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -165,6 +166,88 @@ CGPointerAuthInfo CodeGenModule::getPointerAuthInfoForType(QualType T) { return ::getPointerAuthInfoForType(*this, T); } +static bool isZeroConstant(llvm::Value *value) { + if (auto ci = dyn_cast(value)) kovdan01 wrote: Nit ```suggest

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -165,6 +166,88 @@ CGPointerAuthInfo CodeGenModule::getPointerAuthInfoForType(QualType T) { return ::getPointerAuthInfoForType(*this, T); } +static bool isZeroConstant(llvm::Value *value) { + if (auto ci = dyn_cast(value)) +return ci->isZero(); + return false; +} +

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -0,0 +1,77 @@ +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm %s -o - | FileCheck -check-prefix=CHECK -check-prefix=NOPCH %s kovdan01 wrote: Nit: long RUN lines shoul

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -0,0 +1,77 @@ +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm %s -o - | FileCheck -check-prefix=CHECK -check-prefix=NOPCH %s +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrim

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -0,0 +1,55 @@ +// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- -fptrauth-function-pointer-type-discrimination | FileCheck %s kovdan01 wrote: Nit: it would also be nice to have RUN lines against linux trip

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -165,6 +166,88 @@ CGPointerAuthInfo CodeGenModule::getPointerAuthInfoForType(QualType T) { return ::getPointerAuthInfoForType(*this, T); } +static bool isZeroConstant(llvm::Value *value) { + if (auto ci = dyn_cast(value)) +return ci->isZero(); + return false; +} +

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -165,6 +166,88 @@ CGPointerAuthInfo CodeGenModule::getPointerAuthInfoForType(QualType T) { return ::getPointerAuthInfoForType(*this, T); } +static bool isZeroConstant(llvm::Value *value) { + if (auto ci = dyn_cast(value)) +return ci->isZero(); + return false; +} +

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -190,8 +190,8 @@ class CGBuilderTy : public CGBuilderBaseTy { const llvm::Twine &Name = "") { if (!Addr.hasOffset()) return Address(CreateAddrSpaceCast(Addr.getBasePointer(), Ty, Name), - ElementTy, Addr.getAlignmen

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -3126,3 +3137,57 @@ CodeGenFunction::EmitPointerAuthAuth(const CGPointerAuthInfo &PointerAuth, return EmitPointerAuthCommon(*this, PointerAuth, Pointer, llvm::Intrinsic::ptrauth_auth); } + +llvm::Value *CodeGenFunction::EmitPointerAuthSign(Q

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
kovdan01 wrote: Could you please clarify what tests should go to ptrauth.c? The test name is very generic, and we have more than 10 tests with clang/test/CodeGen/ptrauth*.c names. Maybe this should be renamed to smth more specific? https://github.com/llvm/llv

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 edited https://github.com/llvm/llvm-project/pull/98847 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -351,3 +434,125 @@ CodeGenModule::getVTablePointerAuthInfo(CodeGenFunction *CGF, /* IsIsaPointer */ false, /* AuthenticatesNullValues */ false, Discriminator); } + +llvm::Value *CodeGenFunction::AuthPointerToPointerCast(

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -0,0 +1,55 @@ +// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -emit-llvm -o- -fptrauth-function-pointer-type-discrimination | FileCheck %s + +typedef void (*fptr_t)(void); + +char *cptr; +void (*fptr)(void); + +// CHECK-LABEL: define vo

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -3126,3 +3137,57 @@ CodeGenFunction::EmitPointerAuthAuth(const CGPointerAuthInfo &PointerAuth, return EmitPointerAuthCommon(*this, PointerAuth, Pointer, llvm::Intrinsic::ptrauth_auth); } + +llvm::Value *CodeGenFunction::EmitPointerAuthSign(Q

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -165,6 +166,88 @@ CGPointerAuthInfo CodeGenModule::getPointerAuthInfoForType(QualType T) { return ::getPointerAuthInfoForType(*this, T); } +static bool isZeroConstant(llvm::Value *value) { + if (auto ci = dyn_cast(value)) +return ci->isZero(); + return false; +} +

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -3126,3 +3137,57 @@ CodeGenFunction::EmitPointerAuthAuth(const CGPointerAuthInfo &PointerAuth, return EmitPointerAuthCommon(*this, PointerAuth, Pointer, llvm::Intrinsic::ptrauth_auth); } + +llvm::Value *CodeGenFunction::EmitPointerAuthSign(Q

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
https://github.com/kovdan01 commented: I've left a bunch of mostly cosmetic comments and minor nits which are non-blocking in terms of merging that. However, I'll take another look at this "with fresh eyes" within a day - I need a bit more time to drill into actual logic. https://github.com/l

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -3126,3 +3137,57 @@ CodeGenFunction::EmitPointerAuthAuth(const CGPointerAuthInfo &PointerAuth, return EmitPointerAuthCommon(*this, PointerAuth, Pointer, llvm::Intrinsic::ptrauth_auth); } + +llvm::Value *CodeGenFunction::EmitPointerAuthSign(Q

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -0,0 +1,77 @@ +// RUN: %clang_cc1 -fptrauth-function-pointer-type-discrimination -triple arm64-apple-ios -fptrauth-calls -fptrauth-intrinsics -emit-llvm %s -o - | FileCheck -check-prefix=CHECK -check-prefix=NOPCH %s kovdan01 wrote: Nit: maybe use `-check-pr

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -195,34 +195,45 @@ CodeGenFunction::CGFPOptionsRAII::~CGFPOptionsRAII() { CGF.Builder.setDefaultConstrainedRounding(OldRounding); } -static LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T, - bool ForPointeeType, -

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Daniil Kovalev via cfe-commits
@@ -165,6 +166,88 @@ CGPointerAuthInfo CodeGenModule::getPointerAuthInfoForType(QualType T) { return ::getPointerAuthInfoForType(*this, T); } +static bool isZeroConstant(llvm::Value *value) { + if (auto ci = dyn_cast(value)) +return ci->isZero(); + return false; +} +

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Anatoly Trosinenko via cfe-commits
@@ -192,14 +215,18 @@ class Address { /// Return the IR name of the pointer value. llvm::StringRef getName() const { return Pointer.getPointer()->getName(); } + const CGPointerAuthInfo &getPointerAuthInfo() const { return PtrAuthInfo; } + void setPointerAuthInfo(const CG

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Anatoly Trosinenko via cfe-commits
@@ -165,6 +166,88 @@ CGPointerAuthInfo CodeGenModule::getPointerAuthInfoForType(QualType T) { return ::getPointerAuthInfoForType(*this, T); } +static bool isZeroConstant(llvm::Value *value) { + if (auto ci = dyn_cast(value)) +return ci->isZero(); + return false; +} +

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-15 Thread Anatoly Trosinenko via cfe-commits
@@ -165,6 +166,88 @@ CGPointerAuthInfo CodeGenModule::getPointerAuthInfoForType(QualType T) { return ::getPointerAuthInfoForType(*this, T); } +static bool isZeroConstant(llvm::Value *value) { atrosinenko wrote: The existing code in `CGPointerAuth.cpp` seem

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-14 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: Akira Hatanaka (ahatanak) Changes Re-signing occurs when function type discrimination is enabled and a function pointer is converted to another function pointer type that requires signing using a different discriminator. A functio

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-14 Thread Akira Hatanaka via cfe-commits
https://github.com/ahatanak ready_for_review https://github.com/llvm/llvm-project/pull/98847 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [PAC] Implement function pointer re-signing (PR #98847)

2024-07-14 Thread Akira Hatanaka via cfe-commits
https://github.com/ahatanak edited https://github.com/llvm/llvm-project/pull/98847 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits