[llvm-branch-commits] [llvm] Add deactivation symbol operand to ConstantPtrAuth. (PR #133537)

2025-09-17 Thread Oliver Hunt via llvm-branch-commits
@@ -2135,6 +2135,11 @@ bool ConstantPtrAuth::hasSpecialAddressDiscriminator(uint64_t Value) const { bool ConstantPtrAuth::isKnownCompatibleWith(const Value *Key, const Value *Discriminator,

[llvm-branch-commits] [llvm] Add deactivation symbol operand to ConstantPtrAuth. (PR #133537)

2025-09-13 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: > > I have checked in with @ahmedbougacha and his feeling is that this is fine > > as it requires a bunch of work to opt in, and for places where the security > > is important enough that we don't want people using this it's easy enough > > to block. > > Thanks for checking. as

[llvm-branch-commits] [llvm] Add deactivation symbol operand to ConstantPtrAuth. (PR #133537)

2025-09-12 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: > > > I'm concerned about this - I initially thought this was for the purpose > > > of the structure field protection in the frontend, but this is modifying > > > the actual pointer auth intrinsics in the backend which is very > > > concerning given the work we need to do to merg

[llvm-branch-commits] [clang] Add pointer field protection feature. (PR #133538)

2025-09-12 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: > @pcc and I have been discussing this. > > * The perf issues I was concerned about were predicated on access to a > pointer loaded from a field continuing to be checked after the original field > load, this is not the case (and in hindsight doing so would imply passing the > po

[llvm-branch-commits] [llvm] Add deactivation symbol operand to ConstantPtrAuth. (PR #133537)

2025-09-12 Thread Oliver Hunt via llvm-branch-commits
@@ -2135,6 +2135,11 @@ bool ConstantPtrAuth::hasSpecialAddressDiscriminator(uint64_t Value) const { bool ConstantPtrAuth::isKnownCompatibleWith(const Value *Key, const Value *Discriminator,

[llvm-branch-commits] [llvm] Add deactivation symbol operand to ConstantPtrAuth. (PR #133537)

2025-09-12 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: > This isn't possible, the symbols are resolved at static link time. See the > RFC for more information: > https://discourse.llvm.org/t/rfc-deactivation-symbols/85556 Oh wait, I have completely misunderstood that - I have always assumed dynamic link and that's the reason for a b

[llvm-branch-commits] [llvm] [AllocToken, Clang] Implement __builtin_alloc_token_infer() and llvm.alloc.token.id (PR #156842)

2025-09-12 Thread Oliver Hunt via llvm-branch-commits
@@ -1274,6 +1274,12 @@ def AllocaWithAlignUninitialized : Builtin { let Prototype = "void*(size_t, _Constant size_t)"; } +def AllocTokenInfer : Builtin { + let Spellings = ["__builtin_alloc_token_infer"]; ojhunt wrote: I think `__builtin_infer_alloc_token`

[llvm-branch-commits] [llvm] [AllocToken, Clang] Implement __builtin_alloc_token_infer() and llvm.alloc.token.id (PR #156842)

2025-09-12 Thread Oliver Hunt via llvm-branch-commits
@@ -3352,10 +3352,15 @@ class CodeGenFunction : public CodeGenTypeCache { SanitizerAnnotateDebugInfo(ArrayRef Ordinals, SanitizerHandler Handler); - /// Emit additional metadata used by the AllocToken instrumentation. + /// Emit metadata used

[llvm-branch-commits] [llvm] [AllocToken, Clang] Implement __builtin_alloc_token_infer() and llvm.alloc.token.id (PR #156842)

2025-09-12 Thread Oliver Hunt via llvm-branch-commits
@@ -3352,10 +3352,15 @@ class CodeGenFunction : public CodeGenTypeCache { SanitizerAnnotateDebugInfo(ArrayRef Ordinals, SanitizerHandler Handler); - /// Emit additional metadata used by the AllocToken instrumentation. + /// Emit metadata used

[llvm-branch-commits] [llvm] [AllocToken, Clang] Implement __builtin_alloc_token_infer() and llvm.alloc.token.id (PR #156842)

2025-09-12 Thread Oliver Hunt via llvm-branch-commits
@@ -846,6 +836,22 @@ static void addSanitizers(const Triple &TargetTriple, } } +static void addAllocTokenPass(const Triple &TargetTriple, ojhunt wrote: I'd rather separate sema changes from codegen https://github.com/llvm/llvm-project/pull/156842 _

[llvm-branch-commits] [llvm] [AllocToken, Clang] Implement __builtin_alloc_token_infer() and llvm.alloc.token.id (PR #156842)

2025-09-12 Thread Oliver Hunt via llvm-branch-commits
@@ -5760,6 +5764,24 @@ bool Sema::BuiltinAllocaWithAlign(CallExpr *TheCall) { return false; } +bool Sema::BuiltinAllocTokenInfer(CallExpr *TheCall) { ojhunt wrote: I would prefer this not be a Sema member, and would prefer the static function with a `Sema&

[llvm-branch-commits] [llvm] [AllocToken, Clang] Implement __builtin_alloc_token_infer() and llvm.alloc.token.id (PR #156842)

2025-09-12 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt edited https://github.com/llvm/llvm-project/pull/156842 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] [clang] release/21.x: [clang][PAC] Fix builtins that claim address discriminated types are bitwise compatible (#154490) (PR #155513)

2025-08-26 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt milestoned https://github.com/llvm/llvm-project/pull/155513 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] [clang] release/21.x: [clang][PAC] Fix builtins that claim address discriminated types are bitwise compatible (#154490) (PR #155492)

2025-08-26 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: Superseded by https://github.com/llvm/llvm-project/pull/155513 https://github.com/llvm/llvm-project/pull/155492 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-b

[llvm-branch-commits] [clang] release/21.x: [clang][PAC] Fix builtins that claim address discriminated types are bitwise compatible (#154490) (PR #155492)

2025-08-26 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/155492 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] [clang] release/21.x: [clang][PAC] Fix builtins that claim address discriminated types are bitwise compatible (#154490) (PR #155513)

2025-08-26 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/155513 Backporting https://github.com/llvm/llvm-project/commit/d66b53738a29fb3a0551167efcb8d35320a539b7 Cherry-picked d66b53 with fixes to avoid ABI breakage. A number of builtins report some variation of "this type i

[llvm-branch-commits] [clang] release/21.x: [clang][PAC] Fix builtins that claim address discriminated types are bitwise compatible (#154490) (PR #155492)

2025-08-26 Thread Oliver Hunt via llvm-branch-commits
@@ -634,7 +634,7 @@ class ASTContext : public RefCountedBase { /// contain data that is address discriminated. This includes /// implicitly authenticated values like vtable pointers, as well as /// explicitly qualified fields. - bool containsAddressDiscriminatedPointerAu

[llvm-branch-commits] [clang] release/21.x: [clang][PAC] Fix builtins that claim address discriminated types are bitwise compatible (#154490) (PR #155492)

2025-08-26 Thread Oliver Hunt via llvm-branch-commits
@@ -634,7 +634,7 @@ class ASTContext : public RefCountedBase { /// contain data that is address discriminated. This includes /// implicitly authenticated values like vtable pointers, as well as /// explicitly qualified fields. - bool containsAddressDiscriminatedPointerAu

[llvm-branch-commits] [clang] Move rest of documentation problems that found their way to the SA section (PR #154608)

2025-08-26 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: > I had to squash and merge because of how stupid github is - I hope I got it > right :( it really is terrible :-/ https://github.com/llvm/llvm-project/pull/154608 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org

[llvm-branch-commits] [clang] release/21.x: [PAC] Fix codegen for polymorphic class variables with consteval constructors (#154858) (PR #155319)

2025-08-25 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt approved this pull request. https://github.com/llvm/llvm-project/pull/155319 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] [clang] release/21.x: [PAC] Fix codegen for polymorphic class variables with consteval constructors (#154858) (PR #155319)

2025-08-25 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: > @ojhunt What do you think about merging this PR to the release branch? LGTM https://github.com/llvm/llvm-project/pull/155319 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman

[llvm-branch-commits] [clang] [clang][PAC][ObjC] Merge the block metadata support for the arm64e abi to llvm 21 (PR #153725)

2025-08-22 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: > ping @AaronBallman for review @tru I've reached out as well, but i believe the original cherrypick request was approved (https://github.com/llvm/llvm-project/pull/153725#pullrequestreview-3123667711) and this PR is just the manual merge of the required commits https://github.

[llvm-branch-commits] [clang] Move rest of documentation problems that found their way to the SA sec. (PR #154608)

2025-08-21 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: > > Dammit, yeah I wish I could still see the conflict to work out how I > > misread it - I suspect the addition of "A new flag - > > `-static-libclosure`..." to new flags didn't conflict :-/ > > You can actually, `git show --remerge-diff > 30401b1f918ea359334b507a79118938ffe3c1

[llvm-branch-commits] [clang] Move rest of documentation problems that found their way to the SA sec. (PR #154608)

2025-08-21 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: Dammit, yeah I wish I could still see the conflict to work out how I misread it - I suspect the addition of "A new flag - `-static-libclosure`..." to new flags didn't conflict :-/ https://github.com/llvm/llvm-project/pull/154608 ___ l

[llvm-branch-commits] [clang] release/21.x: [NFC][Clang][Docs] Update Pointer Authentication documentation (#152596) (PR #154240)

2025-08-21 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: @EugeneZelenko @tru Once the last of the functional changes is merged I'll do a last sweep through the docs and release notes to ensure that the release notes and documentation are complete https://github.com/llvm/llvm-project/pull/154240

[llvm-branch-commits] [clang] release/21.x: [NFC][Clang][Docs] Update Pointer Authentication documentation (#152596) (PR #154240)

2025-08-20 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: > It probably makes sense to backport this to the release branch, but @ojhunt > would be much better to make that decision. @ojhunt : What do you think about > merging this back onto the LLVM 21 release branch? @kbeyls I initiated this back port request :D :D :D https://github.c

[llvm-branch-commits] [clang] release/21.x: [clang][PAC] ptrauth_qualifier and ptrauth_intrinsic should only be available on Darwin (#153912) (PR #154198)

2025-08-18 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: Oh, the bot already asked. Sigh. https://github.com/llvm/llvm-project/pull/154198 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] [clang] release/21.x: [clang][PAC] ptrauth_qualifier and ptrauth_intrinsic should only be available on Darwin (#153912) (PR #154198)

2025-08-18 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: This back port needs to be approved by @AaronBallman - I believe we're on the same page, but want to be safe https://github.com/llvm/llvm-project/pull/154198 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https:/

[llvm-branch-commits] [clang] [clang][PAC][ObjC] Merge the block metadata support for the arm64e abi to llvm 21 (PR #153725)

2025-08-15 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: > Not opposed but this is a pretty significant amount of change for being this > late in the rc cycles, and the changes haven't been upstream for very long. > How risky are these changes? This is the upstreaming of code we've had deployed for a few years at this point, the only

[llvm-branch-commits] [clang] [clang][PAC][ObjC] Merge the block metadata support for the arm64e abi to llvm 21 (PR #153725)

2025-08-14 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: This fixes #153726 -- (multiple comments to try and see if I can get the bot infra to understand) https://github.com/llvm/llvm-project/pull/153725 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm

[llvm-branch-commits] [clang] [clang][PAC][ObjC] Merge the block metadata support for the arm64e abi to llvm 21 (PR #153725)

2025-08-14 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt edited https://github.com/llvm/llvm-project/pull/153725 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] [clang] [clang][PAC][ObjC] Merge the block metadata support for the arm64e abi to llvm 21 (PR #153725)

2025-08-14 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: Ah, I see - the bot cherry-pick commands are not a requirement, it can be approved by a release manager manually. https://github.com/llvm/llvm-project/pull/153725 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org ht

[llvm-branch-commits] [clang] [clang][PAC][ObjC] Merge the block metadata support for the arm64e abi to llvm 21 (PR #153725)

2025-08-14 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt reopened https://github.com/llvm/llvm-project/pull/153725 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] [clang] release/21.x: [clang][Obj-C][PAC] Add support for authenticating block metadata (#152978) (PR #153665)

2025-08-14 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/153665 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] release/21.x: [clang][PAC] Fix PAC codegen for final class dynamic_cast optimization (#152227) (PR #152587)

2025-08-08 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: @tru this was me misunderstanding the back porting automation sorry :D https://github.com/llvm/llvm-project/pull/152587 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinf

[llvm-branch-commits] [clang] [clang][PAC] Fix PAC codegen for final class dynamic_cast optimization (#152227) (PR #152271)

2025-08-07 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/152271 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] [clang] [clang][PAC] Fix PAC codegen for final class dynamic_cast optimization (#152227) (PR #152271)

2025-08-07 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: /cherry-pick 726847829553079a13b1b7104f2c2db9dcda9c1d https://github.com/llvm/llvm-project/pull/152271 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-com

[llvm-branch-commits] [clang] [clang][PAC] Fix PAC codegen for final class dynamic_cast optimization (#152227) (PR #152271)

2025-08-07 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt milestoned https://github.com/llvm/llvm-project/pull/152271 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] [clang] [clang][PAC] Fix PAC codegen for final class dynamic_cast optimization (#152227) (PR #152271)

2025-08-06 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/152271 The codegen for the final class dynamic_cast optimization fails to consider pointer authentication. This change resolves this be simply disabling the optimization when pointer authentication enabled. >From 01bf

[llvm-branch-commits] [llvm] [CGP][PAC] Flip PHI and blends when all immediate modifiers are the same (PR #150226)

2025-07-28 Thread Oliver Hunt via llvm-branch-commits
@@ -0,0 +1,142 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: -p --version 5 ojhunt wrote: Tests look fine but I'd like a counter example with non-constant discriminator to track that behavior. https://github.com/llvm/l

[llvm-branch-commits] [llvm] [CGP][PAC] Flip PHI and blends when all immediate modifiers are the same (PR #150226)

2025-07-28 Thread Oliver Hunt via llvm-branch-commits
@@ -8309,6 +8316,74 @@ bool CodeGenPrepare::optimizeExtractElementInst(Instruction *Inst) { return false; } +// Given the instruction Inst, rewrite its discriminator operand Disc if it is +// a PHI node with all incoming values being @llvm.ptrauth.blend(addr, imm) +// with

[llvm-branch-commits] [llvm] [CGP][PAC] Flip PHI and blends when all immediate modifiers are the same (PR #150226)

2025-07-28 Thread Oliver Hunt via llvm-branch-commits
@@ -8309,6 +8316,74 @@ bool CodeGenPrepare::optimizeExtractElementInst(Instruction *Inst) { return false; } +// Given the instruction Inst, rewrite its discriminator operand Disc if it is +// a PHI node with all incoming values being @llvm.ptrauth.blend(addr, imm) +// with

[llvm-branch-commits] [llvm] [CGP][PAC] Flip PHI and blends when all immediate modifiers are the same (PR #150226)

2025-07-28 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt approved this pull request. r=me with additional tests for variable discriminators https://github.com/llvm/llvm-project/pull/150226 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org

[llvm-branch-commits] [llvm] [CGP][PAC] Flip PHI and blends when all immediate modifiers are the same (PR #150226)

2025-07-28 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt edited https://github.com/llvm/llvm-project/pull/150226 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] CodeGen: Fix implementation of __builtin_trivially_relocate. (PR #140312)

2025-05-16 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt requested changes to this pull request. https://github.com/llvm/llvm-project/pull/140312 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commi

[llvm-branch-commits] CodeGen: Fix implementation of __builtin_trivially_relocate. (PR #140312)

2025-05-16 Thread Oliver Hunt via llvm-branch-commits
@@ -8,7 +8,7 @@ struct S trivially_relocatable_if_eligible { }; // CHECK: @_Z4testP1SS0_ -// CHECK: call void @llvm.memmove.p0.p0.i64 +// CHECK: call void @llvm.memmove.p0.p0.i64({{.*}}, i64 8 ojhunt wrote: given this was a size issue, I think it's important

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-16 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: @pcc and I have been discussing this. * The perf issues I was concerned about were predicated on access to a pointer loaded from a field continuing to be checked after the original field load, this is not the case (and in hindsight doing so would imply passing the pointer as a p

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-15 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: > Hi Oliver, thanks for your comments! I'll address them below. > > > Thoughts: > > This should be opt-in on a field or struct granularity, not just a global > > behavior. > > This would certainly be easier if it were an opt-in behavior, as it would > allow avoiding a substantia

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -441,6 +445,254 @@ bool PreISelIntrinsicLowering::expandMemIntrinsicUses(Function &F) const { return Changed; } +namespace { + +enum class PointerEncoding { + Rotate, + PACCopyable, + PACNonCopyable, +}; + +bool expandProtectedFieldPtr(Function &Intr) { + Module &M =

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -7538,6 +7538,14 @@ static bool IsEligibleForTrivialRelocation(Sema &SemaRef, if (!SemaRef.IsCXXTriviallyRelocatableType(Field->getType())) return false; } + + // FIXME: PFP should not affect trivial relocatability, instead it should + // affect the implementat

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -2268,13 +2293,22 @@ CodeGenFunction::EmitNullInitialization(Address DestPtr, QualType Ty) { // Get and call the appropriate llvm.memcpy overload. Builder.CreateMemCpy(DestPtr, SrcPtr, SizeVal, false); -return; + } else { +// Otherwise, just memset the who

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -1319,14 +1319,66 @@ static llvm::Value *CoerceIntOrPtrToIntOrPtr(llvm::Value *Val, llvm::Type *Ty, /// This safely handles the case when the src type is smaller than the /// destination type; in this situation the values of bits which not /// present in the src are undefin

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -544,6 +544,7 @@ TYPE_TRAIT_2(__is_pointer_interconvertible_base_of, IsPointerInterconvertibleBas #include "clang/Basic/TransformTypeTraits.def" // Clang-only C++ Type Traits +TYPE_TRAIT_1(__has_non_relocatable_fields, HasNonRelocatableFields, KEYCXX) ojhu

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -544,6 +544,7 @@ TYPE_TRAIT_2(__is_pointer_interconvertible_base_of, IsPointerInterconvertibleBas #include "clang/Basic/TransformTypeTraits.def" // Clang-only C++ Type Traits +TYPE_TRAIT_1(__has_non_relocatable_fields, HasNonRelocatableFields, KEYCXX) ojhu

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -1415,6 +1469,52 @@ void CodeGenFunction::CreateCoercedStore(llvm::Value *Src, Address Dst, } } + // Coercion directly through memory does not work if the structure has pointer + // field protection because the struct passed by value has a different bit + // patt

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -441,6 +445,254 @@ bool PreISelIntrinsicLowering::expandMemIntrinsicUses(Function &F) const { return Changed; } +namespace { + +enum class PointerEncoding { + Rotate, + PACCopyable, + PACNonCopyable, +}; + +bool expandProtectedFieldPtr(Function &Intr) { + Module &M =

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt edited https://github.com/llvm/llvm-project/pull/133538 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt commented: unfortunately I really don't know enough about actual backend codegen to comment on the actual codegen implementation here, but I think there's some design issues with having the backend determine the discriminators rather than having those selected in the

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -2201,6 +2215,22 @@ void CodeGenFunction::EmitCXXConstructorCall( EmitTypeCheck(CodeGenFunction::TCK_ConstructorCall, Loc, This, getContext().getRecordType(ClassDecl), CharUnits::Zero()); + // When initializing an object that has pointer field protect

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -2268,13 +2293,22 @@ CodeGenFunction::EmitNullInitialization(Address DestPtr, QualType Ty) { // Get and call the appropriate llvm.memcpy overload. Builder.CreateMemCpy(DestPtr, SrcPtr, SizeVal, false); -return; + } else { +// Otherwise, just memset the who

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -928,6 +936,11 @@ namespace { if (PointerAuthQualifier Q = F->getType().getPointerAuth(); Q && Q.isAddressDiscriminated()) return false; + // Non-trivially-copyable fields with pointer field protection need to be ojhunt wrote: T

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -362,6 +362,17 @@ class LangOptionsBase { BKey }; + enum class PointerFieldProtectionKind { ojhunt wrote: I'm not sure I like this being solely a global decision - it makes custom allocators much harder, and it makes it hard for allocators that hav

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -2513,6 +2513,12 @@ def CountedByOrNull : DeclOrTypeAttr { let LangOpts = [COnly]; } +def NoPointerFieldProtection : DeclOrTypeAttr { ojhunt wrote: This an ABI break so I don't think it can reasonably an on by default for all structs - we can already se

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -3011,6 +3011,12 @@ defm experimental_omit_vtable_rtti : BoolFOption<"experimental-omit-vtable-rtti" NegFlag, BothFlags<[], [CC1Option], " the RTTI component from virtual tables">>; +def experimental_pointer_field_protection_EQ : Joined<["-"], "fexperimental-pointer-f

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -2976,7 +3006,15 @@ void CodeGenFunction::EmitForwardingCallToLambda( QualType resultType = FPT->getReturnType(); ReturnValueSlot returnSlot; if (!resultType->isVoidType() && - calleeFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect && + (calleeFnInfo

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt requested changes to this pull request. Thoughts: This should be opt-in on a field or struct granularity, not just a global behavior. In the RFC I think you mentioned not applying PFP to C types, but I'm unsure how you're deciding what is a C type? There are a lot o

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -1319,14 +1319,66 @@ static llvm::Value *CoerceIntOrPtrToIntOrPtr(llvm::Value *Val, llvm::Type *Ty, /// This safely handles the case when the src type is smaller than the /// destination type; in this situation the values of bits which not /// present in the src are undefin

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
@@ -7538,6 +7538,14 @@ static bool IsEligibleForTrivialRelocation(Sema &SemaRef, if (!SemaRef.IsCXXTriviallyRelocatableType(Field->getType())) return false; } + + // FIXME: PFP should not affect trivial relocatability, instead it should + // affect the implementat

[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

2025-05-14 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt edited https://github.com/llvm/llvm-project/pull/133538 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] [clang] [clang] Remove FEM_Indeterminable (#137661) (PR #138337)

2025-05-06 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: > > I agree, it's literally just a warning correction, and people building this > > release of llvm with a newer clang can configure it to disable this warning > > - I just wasn't sure what the general policy around this kind of thing was > > which is why I made a PR and asked fo

[llvm-branch-commits] [clang] [clang] Remove FEM_Indeterminable (#137661) (PR #138337)

2025-05-05 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: @zahiraam @AaronBallman I'm not sure if this warrants the cherry pick though - because we cannot actually trigger the use of FEM_Indeterminable the fact that the behavior would be wrong isn't relevant, the problem is just the warning spam you get while building with trunk clang

[llvm-branch-commits] [clang] [clang] Remove FEM_Indeterminable (#137661) (PR #138337)

2025-05-02 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: @tstellar hi, I'm not sure the process for merging to a release branch, this is a minor correctness fix but it prevents a massive amount of warning spam when building with more current clangs. cc'ing @AaronBallman and @zahiraam so they see this and can weigh in on whether it is r

[llvm-branch-commits] [clang] [clang] Remove FEM_Indeterminable (#137661) (PR #138337)

2025-05-02 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/138337 Remove FEM_Indeterminable as it is unused and cannot be stored safely in an unsigned bitfield >From f104804f217b31f6c41559fc3b388a9c8f0f7571 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Fri, 2 May 2025 13:0

[llvm-branch-commits] [clang] [clang] Implement pointer authentication for C++ virtual functions, v-tables, and VTTs (PR #94056)

2024-06-19 Thread Oliver Hunt via llvm-branch-commits
@@ -296,3 +296,21 @@ ConstantAggregateBuilderBase::finishStruct(llvm::StructType *ty) { buffer.erase(buffer.begin() + Begin, buffer.end()); return constant; } + ojhunt wrote: @asl Updating to resolve conflict required bringing this function in that was p

[llvm-branch-commits] [clang] [clang] Implement pointer authentication for C++ virtual functions, v-tables, and VTTs (PR #94056)

2024-06-10 Thread Oliver Hunt via llvm-branch-commits
@@ -7037,8 +7036,64 @@ void ItaniumMangleContextImpl::mangleCXXDtorComdat(const CXXDestructorDecl *D, Mangler.mangle(GlobalDecl(D, Dtor_Comdat)); } +static void mangleOverrideDiscrimination(CXXNameMangler &mangler, + ASTContext &conte

[llvm-branch-commits] [clang] [clang] Implement pointer authentication for C++ virtual functions, v-tables, and VTTs (PR #94056)

2024-06-07 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: Had to do a force push to resolve merge conflicts following @ahatanak's PR, so this change now includes `CodeGenFunction::EmitPointerAuthAuth` etc https://github.com/llvm/llvm-project/pull/94056 ___ llvm-branch-commits mailing list llvm-

[llvm-branch-commits] [clang] [clang] Implement pointer authentication for C++ virtual functions, v-tables, and VTTs (PR #94056)

2024-06-07 Thread Oliver Hunt via llvm-branch-commits
@@ -1261,6 +1262,10 @@ class ASTContext : public RefCountedBase { /// space. QualType removeAddrSpaceQualType(QualType T) const; + /// Return the "other" type-specific discriminator for the given type. ojhunt wrote: How would `/// Return the "other" disc

[llvm-branch-commits] [clang] [clang] Implement pointer authentication for C++ virtual functions, v-tables, and VTTs (PR #94056)

2024-06-07 Thread Oliver Hunt via llvm-branch-commits
@@ -1261,6 +1262,10 @@ class ASTContext : public RefCountedBase { /// space. QualType removeAddrSpaceQualType(QualType T) const; + /// Return the "other" type-specific discriminator for the given type. ojhunt wrote: @asl thoughts? https://github.com/llv

[llvm-branch-commits] [clang] [clang] Implement pointer authentication for C++ virtual functions, v-tables, and VTTs (PR #94056)

2024-06-01 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt ready_for_review https://github.com/llvm/llvm-project/pull/94056 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] [clang] [clang] Implement pointer authentication for C++ virtual functions, v-tables, and VTTs (PR #94054)

2024-05-31 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/94054 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] [clang] [clang] Implement pointer authentication for C++ virtual functions, v-tables, and VTTs (PR #94054)

2024-05-31 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt converted_to_draft https://github.com/llvm/llvm-project/pull/94054 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

[llvm-branch-commits] [clang] [clang] Update use of checkUInt32Argument to match on main (PR #93984)

2024-05-31 Thread Oliver Hunt via llvm-branch-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/93984 Minor correction to match current API >From 0262fdfddf50853d2f40ea86c37877168ad070a8 Mon Sep 17 00:00:00 2001 From: Oliver Hunt <4691426+ojh...@users.noreply.github.com> Date: Fri, 31 May 2024 09:36:32 -0700 Subje

[llvm-branch-commits] [clang] [clang] Implement pointer authentication for C++ virtual functions, v-tables, and VTTs. (PR #93907)

2024-05-31 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: Build fix is trivial `diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 82c4a3c86645..e9a867ff67ba 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -9246,7 +9246,7 @@ static void handleVTablePointerAuthenticati

[llvm-branch-commits] [clang] [clang] Implement pointer authentication for C++ virtual functions, v-tables, and VTTs. (PR #93907)

2024-05-30 Thread Oliver Hunt via llvm-branch-commits
ojhunt wrote: looking as well https://github.com/llvm/llvm-project/pull/93907 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits