[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits
@@ -30,6 +30,46 @@ EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT, _Unwind_Personality_Fn); #endif +#if __has_include() +#include +#endif + +#if defined(__APPLE__) && __has_feature(ptrauth_qualifier

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits
@@ -1877,6 +1946,32 @@ inline Registers_arm64::Registers_arm64(const void *registers) { memcpy(_vectorHalfRegisters, static_cast(registers) + sizeof(GPRs), sizeof(_vectorHalfRegisters)); +#if __has_feature(ptrauth_calls) ojhunt wrote: - [

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits
@@ -93,6 +98,13 @@ class _LIBUNWIND_HIDDEN Registers_x86 { uint32_t getEDI() const { return _registers.__edi; } void setEDI(uint32_t value) { _registers.__edi = value; } + typedef uint32_t reg_t; + typedef uint32_t link_reg_t; + void loadAndAuthenticateLin

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits
@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 { uint64_t getSP() const { return _registers.__sp; } void setSP(uint64_t value) { _registers.__sp = value; } - uint64_t getIP() const { return _registers.__pc; } - void setIP(uint

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits
@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 { uint64_t getSP() const { return _registers.__sp; } void setSP(uint64_t value) { _registers.__sp = value; } - uint64_t getIP() const { return _registers.__pc; } - void setIP(uint

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits
@@ -83,7 +83,13 @@ __llvm_profile_iterate_data(const __llvm_profile_data *Data) { /* This method is only used in value profiler mock testing. */ COMPILER_RT_VISIBILITY void * __llvm_get_function_addr(const __llvm_profile_data *Data) { - return Data->FunctionPointer; + void

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits
@@ -1845,10 +1871,53 @@ class _LIBUNWIND_HIDDEN Registers_arm64 { uint64_t getSP() const { return _registers.__sp; } void setSP(uint64_t value) { _registers.__sp = value; } - uint64_t getIP() const { return _registers.__pc; } - void setIP(uint

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits
@@ -83,7 +83,13 @@ __llvm_profile_iterate_data(const __llvm_profile_data *Data) { /* This method is only used in value profiler mock testing. */ COMPILER_RT_VISIBILITY void * __llvm_get_function_addr(const __llvm_profile_data *Data) { - return Data->FunctionPointer; + void

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits
@@ -694,7 +705,12 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_arm64_jumpto) gcspushm x30 Lnogcs: #endif + +#if __has_feature(ptrauth_calls) + retab +#else ojhunt wrote: see earlier comment - do we want to just adopt a single flag instead of the cur

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-18 Thread Oliver Hunt via cfe-commits
@@ -1877,6 +1946,32 @@ inline Registers_arm64::Registers_arm64(const void *registers) { memcpy(_vectorHalfRegisters, static_cast(registers) + sizeof(GPRs), sizeof(_vectorHalfRegisters)); +#if __has_feature(ptrauth_calls) + uint64_t pcRegister = 0; + memcp

[clang] [clang][PAC] Support trivially_relocating polymorphic objects (PR #144420)

2025-06-18 Thread Oliver Hunt via cfe-commits
ojhunt wrote: Converting to draft so I don't accidentally hit the big green commit button (that is big and green despite no approvals ?!?!) https://github.com/llvm/llvm-project/pull/144420 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https:

[clang] [clang][PAC] Support trivially_relocating polymorphic objects (PR #144420)

2025-06-18 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt converted_to_draft https://github.com/llvm/llvm-project/pull/144420 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][PAC] Support trivially_relocating polymorphic objects (PR #144420)

2025-06-18 Thread Oliver Hunt via cfe-commits
ojhunt wrote: > It is very common for type traits to factor into the ABI of a template > specialization, such that `my_variant` has a different layout depending on > `is_amazing_v`. That is why changing the value of a type trait generally > has to be considered an ABI break. ah right, it's no

[clang] [clang][PAC] Support trivially_relocating polymorphic objects (PR #144420)

2025-06-17 Thread Oliver Hunt via cfe-commits
ojhunt wrote: > I think we should make a point of implementing this for address-discriminated > `__ptrauth` qualifiers before we release it, because changing the type trait > in a future release will be an ABI break. I had been talking to @cor3ntin and decided we could do it later as this is a

[clang] [clang][PAC] Support trivially_relocating polymorphic objects (PR #144420)

2025-06-17 Thread Oliver Hunt via cfe-commits
@@ -4467,17 +4467,25 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_trivially_relocate: case Builtin::BImemmove: case Builtin::BI__builtin_memmove: { +QualType CopiedType = E->getArg(0)->getType()->getPoi

[clang] [clang][PAC] Support trivially_relocating polymorphic objects (PR #144420)

2025-06-16 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/144420 >From b43a7e9295dfdbe0a11fb7dff669b82d8ed0630c Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Mon, 16 Jun 2025 20:48:57 +0300 Subject: [PATCH 1/2] [clang][PAC] Support trivially_relocating polymorphic objects

[clang] [clang][PAC] Support trivially_relocating polymorphic objects (PR #144420)

2025-06-16 Thread Oliver Hunt via cfe-commits
@@ -420,6 +420,222 @@ void CodeGenFunction::EmitPointerAuthCopy(PointerAuthQualifier Qual, QualType T, Builder.CreateStore(Value, DestAddress); } +static const ConstantArrayType *tryGetTypeAsConstantArrayType(QualType T) { + if (!T->isConstantArrayType()) +return nullp

[clang] [clang][PAC] Support trivially_relocating polymorphic objects (PR #144420)

2025-06-16 Thread Oliver Hunt via cfe-commits
@@ -1727,6 +1727,11 @@ ASTContext::PointerAuthContent ASTContext::findPointerAuthContent(QualType T) { T = T.getCanonicalType(); if (T.hasAddressDiscriminatedPointerAuth()) return PointerAuthContent::AddressDiscriminatedData; + + T = getBaseElementType(T).getCanonical

[clang] [clang][PAC] Support trivially_relocating polymorphic objects (PR #144420)

2025-06-16 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/144420 Adds support for trivial relocation of polymorphic objects with address discriminated vtable pointers. This is implemented as a post-memmove fixup pass over the impacted objects. We do this by traversing the ob

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-16 Thread Oliver Hunt via cfe-commits
ojhunt wrote: > LLVM Buildbot has detected a new failure on builder > `ppc64le-flang-rhel-clang` running on `ppc64le-flang-rhel-test` while > building `clang` at step 6 "test-build-unified-tree-check-flang". > > Full details are available at: > https://lab.llvm.org/buildbot/#/builders/157/bui

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-16 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/143969 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-16 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/143969 >From f47680310ed68a9f8e8cb15bc1cd474740072463 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 12 Jun 2025 13:17:11 -0700 Subject: [PATCH 1/7] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-16 Thread Oliver Hunt via cfe-commits
@@ -629,25 +629,46 @@ class ASTContext : public RefCountedBase { void setRelocationInfoForCXXRecord(const CXXRecordDecl *, CXXRecordDeclRelocationInfo); - /// Examines a given type, and returns whether the T itself + /// Examines a give

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-16 Thread Oliver Hunt via cfe-commits
@@ -629,25 +629,46 @@ class ASTContext : public RefCountedBase { void setRelocationInfoForCXXRecord(const CXXRecordDecl *, CXXRecordDeclRelocationInfo); - /// Examines a given type, and returns whether the T itself + /// Examines a give

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-16 Thread Oliver Hunt via cfe-commits
@@ -629,25 +629,46 @@ class ASTContext : public RefCountedBase { void setRelocationInfoForCXXRecord(const CXXRecordDecl *, CXXRecordDeclRelocationInfo); - /// Examines a given type, and returns whether the T itself + /// Examines a give

[clang] [clang][bytecode] Fix calling operator new with nothrow/align parameter (PR #144271)

2025-06-15 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt approved this pull request. Looks reasonable to me -- I spent a bunch of time trying to induce some case where this would do the wrong thing and I couldn't come up with anything as all the failure modes that would be possible outside of constexpr already fail in const

[clang] [Clang] Improve diagnostics for 'placement new' with const storage argument (PR #144270)

2025-06-15 Thread Oliver Hunt via cfe-commits
@@ -2753,10 +2753,18 @@ static bool resolveAllocationOverloadInterior( if (Diagnose) { // If this is an allocation of the form 'new (p) X' for some object // pointer p (or an expression that will decay to such a pointer), - // diagnose the missing inclusion

[clang] [Clang] Improve diagnostics for 'placement new' with const storage argument (PR #144270)

2025-06-15 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt requested changes to this pull request. https://github.com/llvm/llvm-project/pull/144270 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Improve diagnostics for 'placement new' with const storage argument (PR #144270)

2025-06-15 Thread Oliver Hunt via cfe-commits
@@ -2753,10 +2753,18 @@ static bool resolveAllocationOverloadInterior( if (Diagnose) { // If this is an allocation of the form 'new (p) X' for some object // pointer p (or an expression that will decay to such a pointer), - // diagnose the missing inclusion

[clang] [Clang] Fix typo in is_replaceable diagnostic (PR #144247)

2025-06-15 Thread Oliver Hunt via cfe-commits
ojhunt wrote: Sure thing :D https://github.com/llvm/llvm-project/pull/144247 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Fix typo in is_replaceable diagnostic (PR #144247)

2025-06-15 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/144247 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Fix typo in is_replaceable diagnostic (PR #144247)

2025-06-15 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt approved this pull request. lgtm https://github.com/llvm/llvm-project/pull/144247 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-15 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/143969 >From f47680310ed68a9f8e8cb15bc1cd474740072463 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 12 Jun 2025 13:17:11 -0700 Subject: [PATCH 1/6] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-15 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/143969 >From f47680310ed68a9f8e8cb15bc1cd474740072463 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 12 Jun 2025 13:17:11 -0700 Subject: [PATCH 1/5] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-15 Thread Oliver Hunt via cfe-commits
ojhunt wrote: found how to unmark the approval as the next update will change this fairly substantially https://github.com/llvm/llvm-project/pull/143969 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/lis

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-15 Thread Oliver Hunt via cfe-commits
ojhunt wrote: Actually I've given this a lot of thought, I think we should not consider explicitly __ptrauth qualified types to be relocatable, how does that sound? https://github.com/llvm/llvm-project/pull/143969 ___ cfe-commits mailing list cfe-comm

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-15 Thread Oliver Hunt via cfe-commits
ojhunt wrote: Very glad I didn't just assume my local build was sufficient and waited for the bots :D https://github.com/llvm/llvm-project/pull/143969 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listi

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-15 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/143969 >From f47680310ed68a9f8e8cb15bc1cd474740072463 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 12 Jun 2025 13:17:11 -0700 Subject: [PATCH 1/4] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-14 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/143969 >From f47680310ed68a9f8e8cb15bc1cd474740072463 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 12 Jun 2025 13:17:11 -0700 Subject: [PATCH 1/3] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-12 Thread Oliver Hunt via cfe-commits
@@ -628,10 +628,13 @@ class ASTContext : public RefCountedBase { getRelocationInfoForCXXRecord(const CXXRecordDecl *) const; void setRelocationInfoForCXXRecord(const CXXRecordDecl *, CXXRecordDeclRelocationInfo); + bool containsAddressD

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-12 Thread Oliver Hunt via cfe-commits
@@ -15121,6 +15155,21 @@ ASTContext::baseForVTableAuthentication(const CXXRecordDecl *ThisClass) { return PrimaryBase; } +bool ASTContext::hasAddressDiscriminatedVTableAuthentication( ojhunt wrote: Which function? https://github.com/llvm/llvm-project/pull

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-12 Thread Oliver Hunt via cfe-commits
@@ -1705,6 +1705,40 @@ void ASTContext::setRelocationInfoForCXXRecord( RelocatableClasses.insert({D, Info}); } +bool ASTContext::containsAddressDiscriminatedPointerAuth(QualType T) { + if (!LangOpts.PointerAuthCalls && !LangOpts.PointerAuthIntrinsics) +return false; + +

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

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

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-12 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/143969 >From f47680310ed68a9f8e8cb15bc1cd474740072463 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 12 Jun 2025 13:17:11 -0700 Subject: [PATCH 1/2] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-12 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/143969 >From f47680310ed68a9f8e8cb15bc1cd474740072463 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 12 Jun 2025 13:17:11 -0700 Subject: [PATCH 1/2] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-12 Thread Oliver Hunt via cfe-commits
@@ -557,7 +596,19 @@ set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context, reinterpret_cast(unwind_exception)); _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), static_cast(results.ttypeIndex)); +#if defined(__A

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-12 Thread Oliver Hunt via cfe-commits
@@ -807,7 +812,12 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) strd31, [x0, #0x208] #endif movx0, #0 // return UNW_ESUCCESS + +#if __has_feature(ptrauth_calls) + retab +#else ojhunt wrote: This is what we have downstream, i

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-12 Thread Oliver Hunt via cfe-commits
@@ -126,6 +130,36 @@ _LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum, // First, get the FDE for the old location and then update it. co->getInfo(&info); co->setInfoBasedOnIPRegister(false); + +#if __has_feature(ptrauth_calls) +

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-12 Thread Oliver Hunt via cfe-commits
@@ -32,22 +32,23 @@ #endif #if defined(_WIN32) - #if defined(_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCXXABI_BUILDING_LIBRARY)) - #define _LIBCXXABI_HIDDEN - #define _LIBCXXABI_DATA_VIS - #define _LIBCXXABI_FUNC_VIS - #define _LI

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-12 Thread Oliver Hunt via cfe-commits
@@ -32,22 +32,23 @@ #endif #if defined(_WIN32) - #if defined(_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCXXABI_BUILDING_LIBRARY)) - #define _LIBCXXABI_HIDDEN - #define _LIBCXXABI_DATA_VIS - #define _LIBCXXABI_FUNC_VIS - #define _LI

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143969)

2025-06-12 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/143969 This adds a function to ASTContext to query whether a type contains values with address discriminated pointer auth, and performs the required semantic checks to ensure correct reporting of relocatablity in those

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143796)

2025-06-12 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/143796 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143796)

2025-06-12 Thread Oliver Hunt via cfe-commits
ojhunt wrote: Closing this PR because there's a lot of noise in it that is just completely reverted/gone at this point. https://github.com/llvm/llvm-project/pull/143796 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143796)

2025-06-12 Thread Oliver Hunt via cfe-commits
@@ -292,77 +294,129 @@ Sema::CheckCXX2CRelocatableAndReplaceable(const CXXRecordDecl *D) { return HasSuitableSMP(); // is a union with no user-declared special member functions, or -if (IsUnion()) +if (IsTrivialUnion()) return HasSuitableSMP();

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143796)

2025-06-12 Thread Oliver Hunt via cfe-commits
@@ -292,77 +294,129 @@ Sema::CheckCXX2CRelocatableAndReplaceable(const CXXRecordDecl *D) { return HasSuitableSMP(); // is a union with no user-declared special member functions, or -if (IsUnion()) +if (IsTrivialUnion()) return HasSuitableSMP();

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143796)

2025-06-12 Thread Oliver Hunt via cfe-commits
@@ -10615,7 +10615,7 @@ void Sema::checkIllFormedTrivialABIStruct(CXXRecordDecl &RD) { } } - if (IsCXXTriviallyRelocatableType(RD)) + if (CheckCXX2CRelocatableAndReplaceable(&RD).IsRelocatable) ojhunt wrote: I think I did restore it for QualType an

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143796)

2025-06-12 Thread Oliver Hunt via cfe-commits
@@ -621,17 +621,24 @@ class ASTContext : public RefCountedBase { public: struct CXXRecordDeclRelocationInfo { +static CXXRecordDeclRelocationInfo NonRelocatable() { + return {false, false}; +} + unsigned IsRelocatable; unsigned IsReplaceable; -

[clang] [clang] Fix PointerAuth semantics of cpp_trivially_relocatable (PR #143796)

2025-06-11 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/143796 This reworks the way we compute relocatability and replaceability of types. We do this by having a single interface the provides a full `TypeRelocationInfo` for a QualType. This simplifies the reasoning for all

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-06-11 Thread Oliver Hunt via cfe-commits
@@ -65,6 +65,17 @@ enum class PointerAuthenticationMode : unsigned { SignAndAuth }; +static constexpr llvm::StringLiteral PointerAuthenticationOptionStrip = "strip"; ojhunt wrote: ah so what @erichkeane was suggesting is that places needing the string woul

[clang] [Clang] _default-movable_ should be based on the first declaration (PR #143661)

2025-06-11 Thread Oliver Hunt via cfe-commits
@@ -121,8 +121,10 @@ static bool hasSuitableConstructorForRelocation(Sema &SemaRef, CXXMethodDecl *Decl = LookupSpecialMemberFromXValue(SemaRef, D, /*Assign=*/false); ojhunt wrote: Is it reasonable to have LookupSpecialMemberFromXValue simply return

[clang] [clang][NFC] Remove dead PassTypeToPlacementDelete field (PR #143448)

2025-06-09 Thread Oliver Hunt via cfe-commits
ojhunt wrote: > Thank you for the fix! sorry for the delay, just completely forgot about it https://github.com/llvm/llvm-project/pull/143448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-co

[clang] [clang][NFC] Remove dead PassTypeToPlacementDelete field (PR #143448)

2025-06-09 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/143448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-06-09 Thread Oliver Hunt via cfe-commits
@@ -1434,10 +1446,13 @@ namespace { QualType ArgType; }; -unsigned NumPlacementArgs : 31; -LLVM_PREFERRED_TYPE(bool) +unsigned NumPlacementArgs : 30; +LLVM_PREFERRED_TYPE(AlignedAllocationMode) unsigned PassAlignmentToPlacementDelete : 1; +LL

[clang] [clang][NFC] Remove dead PassTypeToPlacementDelete field (PR #143448)

2025-06-09 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/143448 The CallDeleteDuringNew::PassTypeToPlacementDelete field became unneeded during the many refactorings of P2719 but I didn't actually remove it. >From c1fa0ea448210ab10e71bd7b2f4dc4d575056b39 Mon Sep 17 00:00:00

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-06-09 Thread Oliver Hunt via cfe-commits
@@ -1434,10 +1446,13 @@ namespace { QualType ArgType; }; -unsigned NumPlacementArgs : 31; -LLVM_PREFERRED_TYPE(bool) +unsigned NumPlacementArgs : 30; +LLVM_PREFERRED_TYPE(AlignedAllocationMode) unsigned PassAlignmentToPlacementDelete : 1; +LL

[clang] [Clang] Fix a crash when diagnosing a non relocatable with no copy ctr (PR #143350)

2025-06-09 Thread Oliver Hunt via cfe-commits
@@ -2052,7 +2052,7 @@ static void DiagnoseNonTriviallyRelocatableReason(Sema &SemaRef, } if (!D->hasSimpleMoveConstructor() && !D->hasSimpleCopyConstructor()) { -const auto *Decl = cast( +const auto *Decl = cast_or_null( ojhunt wrote: I didn't re

[clang] [Clang] Fix a crash when diagnosing a non relocatable with no copy ctr (PR #143350)

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

[clang] [Clang] Fix a crash when diagnosing a non relocatable with no copy ctr (PR #143350)

2025-06-09 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt approved this pull request. Looks good https://github.com/llvm/llvm-project/pull/143350 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-08 Thread Oliver Hunt via cfe-commits
ojhunt wrote: unused variable errors are likely fallout from refactoring and workaround removals I did as part of the prep, will do some cleanup/diagnostics work later this week. I mostly wanted to get this available to others to see whether they were ok adopting this rather than rolling thei

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-06 Thread Oliver Hunt via cfe-commits
ojhunt wrote: Updating formatting before review - had discussed with Louis and he expressed a preference for some of it, but this llvm.org style bot complains many other cases (likely a local config issue when I was trying to cleanup the downstream code. So I've updated with a direct clang-fo

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-06 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/143230 >From 637245f9be6ed0163c9129d27a572f153b6f8523 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Fri, 6 Jun 2025 18:50:28 -0700 Subject: [PATCH] [runtimes][PAC] Harden unwinding when possible (#138571) This harde

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-06 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/143230 >From 68103962b254565fdfad069c350af90ede7109b4 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Fri, 6 Jun 2025 18:50:28 -0700 Subject: [PATCH] [runtimes][PAC] Harden unwinding when possible (#138571) This harde

[libunwind] [libunwind][AArch64] Protect PC within libunwind's context. (PR #113368)

2025-06-06 Thread Oliver Hunt via cfe-commits
ojhunt wrote: I've finally got our downstream hardening to the point where it should be sane: https://github.com/llvm/llvm-project/pull/143230 https://github.com/llvm/llvm-project/pull/113368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org htt

[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

2025-06-06 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/143230 This hardens the unwinding logic and datastructures on systems that support pointer authentication. The approach taken to hardening is to harden the schemas of as many high value fields in the myriad structs as

[clang] [ubsan] Remove -fsanitizer=vptr from -fsanitizer=undefined (PR #121115)

2025-06-06 Thread Oliver Hunt via cfe-commits
ojhunt wrote: This obviously cases https://github.com/llvm/llvm-project/issues/143065 @AaronBallman @erichkeane @zygoloid commented in the RFC - this change regresses the checks in ubsan for default compilation modes in order to make the use of sanitize=undefined easier in non-default scenario

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-06-06 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/136828 >From 927380bdf377581e6e40507a12c374023352c613 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Wed, 30 Apr 2025 22:26:59 -0700 Subject: [PATCH 1/6] [clang][PAC] add support for options parameter to __ptrauth T

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-06-06 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/138482 >From ecea44f2965cda3a4e6e1ccec096066830ddfa41 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Sun, 4 May 2025 21:07:33 -0700 Subject: [PATCH 1/2] [clang][ptrauth] Add support for querying the ptrauth schema of

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-06-05 Thread Oliver Hunt via cfe-commits
@@ -605,6 +605,11 @@ KEYWORD(__private_extern__ , KEYALL) KEYWORD(__module_private__ , KEYALL) UNARY_EXPR_OR_TYPE_TRAIT(__builtin_ptrauth_type_discriminator, PtrAuthTypeDiscriminator, KEYALL) +UNARY_EXPR_OR_TYPE_TRAIT(__builtin_ptrauth_has_authentication, P

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-06-05 Thread Oliver Hunt via cfe-commits
@@ -9619,6 +9620,65 @@ ObjCInterfaceDecl *ASTContext::getObjCProtocolDecl() const { return ObjCProtocolClassDecl; } +std::optional +ASTContext::getExplicitOrImplicitPointerAuth(QualType T) { + auto ExplicitQualifier = T.getPointerAuth(); ojhunt wrote: god

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-06-05 Thread Oliver Hunt via cfe-commits
@@ -9619,6 +9620,65 @@ ObjCInterfaceDecl *ASTContext::getObjCProtocolDecl() const { return ObjCProtocolClassDecl; } +std::optional +ASTContext::getExplicitOrImplicitPointerAuth(QualType T) { + auto ExplicitQualifier = T.getPointerAuth(); ojhunt wrote: - [

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-06-05 Thread Oliver Hunt via cfe-commits
@@ -3981,7 +3981,9 @@ class Parser : public CodeCompletionHandler { ExprResult ParseArrayTypeTrait(); ExprResult ParseExpressionTrait(); + ExprResult ParseBuiltinUnaryExprOrTypeTrait(UnaryExprOrTypeTrait ExprKind); ojhunt wrote: ... if something like `Pa

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-06-05 Thread Oliver Hunt via cfe-commits
@@ -9619,6 +9620,65 @@ ObjCInterfaceDecl *ASTContext::getObjCProtocolDecl() const { return ObjCProtocolClassDecl; } +std::optional +ASTContext::getExplicitOrImplicitPointerAuth(QualType T) { + auto ExplicitQualifier = T.getPointerAuth(); + if (ExplicitQualifier.isPresent(

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-06-05 Thread Oliver Hunt via cfe-commits
@@ -3981,7 +3981,9 @@ class Parser : public CodeCompletionHandler { ExprResult ParseArrayTypeTrait(); ExprResult ParseExpressionTrait(); + ExprResult ParseBuiltinUnaryExprOrTypeTrait(UnaryExprOrTypeTrait ExprKind); ojhunt wrote: @cor3ntin @AaronBallman

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-06-05 Thread Oliver Hunt via cfe-commits
@@ -9619,6 +9620,65 @@ ObjCInterfaceDecl *ASTContext::getObjCProtocolDecl() const { return ObjCProtocolClassDecl; } +std::optional +ASTContext::getExplicitOrImplicitPointerAuth(QualType T) { + auto ExplicitQualifier = T.getPointerAuth(); + if (ExplicitQualifier.isPresent(

[clang] [PAuth] Use different discriminators for __int128_t / __uint128_t / _BitInt(n) (PR #140276)

2025-06-05 Thread Oliver Hunt via cfe-commits
@@ -1883,6 +1883,9 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args, Args.addOptInFlag( CmdArgs, options::OPT_fptrauth_function_pointer_type_discrimination, options::OPT_fno_ptrauth_function_pointer_type_discrimination); + Args.addOptInFlag( --

[clang] [AArch64][FMV] Enable PAuth and BTI hardening of resolver functions (PR #141573)

2025-06-05 Thread Oliver Hunt via cfe-commits
@@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -triple aarch64-linux-gnu -mbranch-target-enforce -msign-return-address=all -emit-llvm %s -o - | FileCheck --check-prefixes=CHECK,BTI-SIGNRA %s ojhunt wrote: none of the other ptrauth tests are in a subdirectory, are yo

[libunwind] [libunwind][AArch64] Protect PC within libunwind's context. (PR #113368)

2025-06-04 Thread Oliver Hunt via cfe-commits
ojhunt wrote: Sorry, I missed this Now that the ptrauth qualifier is available I'm going to be preparing and pushing the darwin libunwind+personality function changes, which are very aggressive in there protection of data and pointers https://github.com/llvm/llvm-project/pull/113368 _

[clang] [clang][CGObjC] Sign the v-table pointer in ObjC exception RTTI. (PR #135562)

2025-06-04 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/135562 >From 5dc1e5fbb57f88e412e044605d8fe30a66255a35 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Sun, 13 Apr 2025 13:21:49 -0700 Subject: [PATCH 1/4] [clang][CGObjC] Sign the v-table pointer in ObjC exception RTT

[clang] [PAuth] Use different discriminators for __int128_t / __uint128_t / _BitInt(n) (PR #140276)

2025-06-04 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt edited https://github.com/llvm/llvm-project/pull/140276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][PAC] Add __builtin_get_vtable_pointer (PR #139790)

2025-06-04 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/139790 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [PAuth] Use different discriminators for __int128_t / __uint128_t / _BitInt(n) (PR #140276)

2025-06-04 Thread Oliver Hunt via cfe-commits
@@ -1883,6 +1883,9 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args, Args.addOptInFlag( CmdArgs, options::OPT_fptrauth_function_pointer_type_discrimination, options::OPT_fno_ptrauth_function_pointer_type_discrimination); + Args.addOptInFlag( --

[clang] [PAuth] Use different discriminators for __int128_t / __uint128_t / _BitInt(n) (PR #140276)

2025-06-04 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt commented: This basically looks good to me, sans the "can this just be on by default for elf/linux/etc" question https://github.com/llvm/llvm-project/pull/140276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https:/

[clang] [PAuth] Use different discriminators for __int128_t / __uint128_t / _BitInt(n) (PR #140276)

2025-06-04 Thread Oliver Hunt via cfe-commits
@@ -4451,6 +4451,8 @@ defm ptrauth_init_fini_address_discrimination : OptInCC1FFlag<"ptrauth-init-fini "Enable address discrimination of function pointers in init/fini arrays">; defm ptrauth_elf_got : OptInCC1FFlag<"ptrauth-elf-got", "Enable authentication of pointers from G

[clang] [clang][PAC] Add __builtin_get_vtable_pointer (PR #139790)

2025-06-03 Thread Oliver Hunt via cfe-commits
@@ -3074,6 +3074,39 @@ following way: Query for this feature with ``__has_builtin(__builtin_offsetof)``. +``__builtin_get_vtable_pointer`` + + +``__builtin_get_vtable_pointer`` loads and authenticates the primary vtable +pointer from an instanc

[clang] [clang][PAC] Add __builtin_get_vtable_pointer (PR #139790)

2025-06-03 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/139790 >From a933679801bde89b53584c4c65118658477db4da Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Tue, 13 May 2025 13:35:55 -0700 Subject: [PATCH 1/5] [clang][PAC] Add __builtin_get_vtable_pointer With pointer aut

[clang] [clang][PAC] Add __builtin_get_vtable_pointer (PR #139790)

2025-06-03 Thread Oliver Hunt via cfe-commits
@@ -1825,6 +1825,37 @@ static ExprResult PointerAuthStringDiscriminator(Sema &S, CallExpr *Call) { return Call; } +static ExprResult GetVTablePointer(Sema &S, CallExpr *Call) { + if (S.checkArgCount(Call, 1)) +return ExprError(); + ExprResult ThisArg = S.DefaultFuncti

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread Oliver Hunt via cfe-commits
ojhunt wrote: The docs failure is #142387 https://github.com/llvm/llvm-project/pull/141148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][docs] Fix docs-clang-html. (PR #142387)

2025-06-03 Thread Oliver Hunt via cfe-commits
ojhunt wrote: this is tripping on CI and my machine. To repro I need to delete `$BUILD_DIR/tools/clang/docs` and build with `TZ=UTC ninja docs-clang-man` I find it necessary to delete the doc directory to trigger this. https://github.com/llvm/llvm-project/pull/142387 ___

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread Oliver Hunt via cfe-commits
ojhunt wrote: I can't reproduce this locally so I've ensured my tree is up to date and pushing again to see if it fails again https://github.com/llvm/llvm-project/pull/141148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.o

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-06-03 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/141148 >From 0db205bb8f6925dd725885395f58a688000c7b8b Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 22 May 2025 02:38:26 -0700 Subject: [PATCH 1/5] [clang] Correct FixIt ranges for unused capture warnings Fixes

  1   2   3   4   5   6   >