[llvm-branch-commits] [clang] [flang] [llvm] [Clang][OpenMP] Add permutation clause (PR #92030)
@@ -9861,13 +9842,19 @@ buildPreInits(ASTContext &Context, /// Build pre-init statement for the given statements. static Stmt *buildPreInits(ASTContext &Context, ArrayRef PreInits) { - if (PreInits.empty()) -return nullptr; - - SmallVector Stmts; - for (Stmt *S : PreInits) -appendFlattendedStmtList(Stmts, S); - return CompoundStmt::Create(Context, PreInits, FPOptionsOverride(), {}, {}); + if (!PreInits.empty()) { +SmallVector Stmts; +for (Stmt *S : PreInits) { + // Do not nest CompoundStmts. + if (auto *CS = dyn_cast(S)) { +llvm::append_range(Stmts, CS->body()); +continue; + } + Stmts.push_back(S); +} +return CompoundStmt::Create(Context, PreInits, FPOptionsOverride(), {}, {}); + } + return nullptr; Meinersbur wrote: I don't know why, but this patch contained the state before #91459's review. Fixed. https://github.com/llvm/llvm-project/pull/92030 ___ 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] [BOLT][NFCI] Use heuristic for matching split global functions (PR #90429)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/90429 ___ 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] [llvm] [Inline]Update value profile for non-call instructions (PR #83769)
minglotus-6 wrote: Close this. Going to update in https://github.com/llvm/llvm-project/pull/81442 https://github.com/llvm/llvm-project/pull/83769 ___ 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] [llvm] [Inline]Update value profile for non-call instructions (PR #83769)
https://github.com/minglotus-6 closed https://github.com/llvm/llvm-project/pull/83769 ___ 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] [llvm] [Inline]Update value profile for non-call instructions (PR #83769)
https://github.com/minglotus-6 edited https://github.com/llvm/llvm-project/pull/83769 ___ 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] [llvm] release/18.x: [DAGCombiner] In mergeTruncStore, make sure we aren't storing shifted in bits. (#90939) (PR #91038)
https://github.com/AtariDreams closed https://github.com/llvm/llvm-project/pull/91038 ___ 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] [lld] [llvm] release/18.x: [lld] Fix -ObjC load behavior with LTO (#92162) (PR #92478)
https://github.com/AtariDreams closed https://github.com/llvm/llvm-project/pull/92478 ___ 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] [mlir] 50cb216 - Revert "[mlir] Optimize ThreadLocalCache by removing atomic bottleneck (#93270)"
Author: Jacques Pienaar Date: 2024-05-24T07:45:37-07:00 New Revision: 50cb2160464ef916146c199ab8c9fe3ea9f054d6 URL: https://github.com/llvm/llvm-project/commit/50cb2160464ef916146c199ab8c9fe3ea9f054d6 DIFF: https://github.com/llvm/llvm-project/commit/50cb2160464ef916146c199ab8c9fe3ea9f054d6.diff LOG: Revert "[mlir] Optimize ThreadLocalCache by removing atomic bottleneck (#93270)" This reverts commit 1b803fe53dda11ca63f008f5ab8e206f3954ce48. Added: Modified: mlir/include/mlir/Support/ThreadLocalCache.h Removed: diff --git a/mlir/include/mlir/Support/ThreadLocalCache.h b/mlir/include/mlir/Support/ThreadLocalCache.h index d19257bf6e25e..1be94ca14bcfa 100644 --- a/mlir/include/mlir/Support/ThreadLocalCache.h +++ b/mlir/include/mlir/Support/ThreadLocalCache.h @@ -58,12 +58,11 @@ class ThreadLocalCache { /// ValueT. We use a weak reference here so that the object can be destroyed /// without needing to lock access to the cache itself. struct CacheType - : public llvm::SmallDenseMap, ValueT *>> { + : public llvm::SmallDenseMap> { ~CacheType() { // Remove the values of this cache that haven't already expired. for (auto &it : *this) -if (std::shared_ptr value = it.second.first.lock()) +if (std::shared_ptr value = it.second.lock()) it.first->remove(value.get()); } @@ -72,7 +71,7 @@ class ThreadLocalCache { void clearExpiredEntries() { for (auto it = this->begin(), e = this->end(); it != e;) { auto curIt = it++; -if (curIt->second.first.expired()) +if (curIt->second.expired()) this->erase(curIt); } } @@ -89,27 +88,22 @@ class ThreadLocalCache { ValueT &get() { // Check for an already existing instance for this thread. CacheType &staticCache = getStaticCache(); -std::pair, ValueT *> &threadInstance = -staticCache[perInstanceState.get()]; -if (ValueT *value = threadInstance.second) +std::weak_ptr &threadInstance = staticCache[perInstanceState.get()]; +if (std::shared_ptr value = threadInstance.lock()) return *value; // Otherwise, create a new instance for this thread. -{ - llvm::sys::SmartScopedLock threadInstanceLock( - perInstanceState->instanceMutex); - threadInstance.second = - perInstanceState->instances.emplace_back(std::make_unique()) - .get(); -} -threadInstance.first = -std::shared_ptr(perInstanceState, threadInstance.second); +llvm::sys::SmartScopedLock threadInstanceLock( +perInstanceState->instanceMutex); +perInstanceState->instances.push_back(std::make_unique()); +ValueT *instance = perInstanceState->instances.back().get(); +threadInstance = std::shared_ptr(perInstanceState, instance); // Before returning the new instance, take the chance to clear out any used // entries in the static map. The cache is only cleared within the same // thread to remove the need to lock the cache itself. staticCache.clearExpiredEntries(); -return *threadInstance.second; +return *instance; } ValueT &operator*() { return get(); } ValueT *operator->() { return &get(); } ___ 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] add fallback to expr in the template differ when comparing ValueDecl (PR #93266)
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/93266 >From e74a7e69381731465efb8332890e0ebdc061fbb1 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Thu, 23 May 2024 23:57:01 -0300 Subject: [PATCH 1/2] [clang] add fallback to expr in the template differ when comparing ValueDecl --- clang/docs/ReleaseNotes.rst | 1 + clang/lib/AST/ASTDiagnostic.cpp | 5 + clang/test/Misc/diag-template-diffing-cxx26.cpp | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 6e8687fadc6f7..5e217a76c81a1 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -784,6 +784,7 @@ Miscellaneous Bug Fixes - Fixed an infinite recursion in ASTImporter, on return type declared inside body of C++11 lambda without trailing return (#GH68775). - Fixed declaration name source location of instantiated function definitions (GH71161). +- Missing fallback to expression in the template differ when comparing ValueDecls. Miscellaneous Clang Crashes Fixed ^ diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index 7e4a5709a44ce..1885b21178666 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -1936,6 +1936,11 @@ class TemplateDiff { return; } +if (E) { + PrintExpr(E); + return; +} + OS << "(no argument)"; } diff --git a/clang/test/Misc/diag-template-diffing-cxx26.cpp b/clang/test/Misc/diag-template-diffing-cxx26.cpp index cc174d6c334fb..2b6dd86a9885d 100644 --- a/clang/test/Misc/diag-template-diffing-cxx26.cpp +++ b/clang/test/Misc/diag-template-diffing-cxx26.cpp @@ -19,10 +19,10 @@ namespace GH93068 { // expected-note@#A {{no known conversion from 'A<0>' to 'const A<&n[1]> &' for 1st argument}} // expected-note@#A {{no known conversion from 'A<0>' to 'A<&n[1]> &&' for 1st argument}} -// notree-error@#2 {{no viable conversion from 'A' to 'A<(no argument)>'}} +// notree-error@#2 {{no viable conversion from 'A' to 'A'}} /* tree-error@#2 {{no viable conversion A< -[n != (no argument)]>}}*/ +[n != n + 1]>}}*/ A v2 = A(); // #2 // expected-note@#A {{no known conversion from 'A' to 'const A<&n[1]> &' for 1st argument}} >From 4b12139395d8bcabd053ed6db11aa049ee95d5c3 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Fri, 24 May 2024 11:29:13 -0300 Subject: [PATCH 2/2] Update clang/docs/ReleaseNotes.rst Co-authored-by: Erich Keane --- clang/docs/ReleaseNotes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 5e217a76c81a1..a63b0c2460cd7 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -784,7 +784,7 @@ Miscellaneous Bug Fixes - Fixed an infinite recursion in ASTImporter, on return type declared inside body of C++11 lambda without trailing return (#GH68775). - Fixed declaration name source location of instantiated function definitions (GH71161). -- Missing fallback to expression in the template differ when comparing ValueDecls. +- Improve diagnostic output to print an expression instead of 'no argument` when comparing Values as template arguments. Miscellaneous Clang Crashes Fixed ^ ___ 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] add fallback to expr in the template differ when comparing ValueDecl (PR #93266)
https://github.com/erichkeane approved this pull request. Fine other than the release note not being clear enough https://github.com/llvm/llvm-project/pull/93266 ___ 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] add fallback to expr in the template differ when comparing ValueDecl (PR #93266)
@@ -784,6 +784,7 @@ Miscellaneous Bug Fixes - Fixed an infinite recursion in ASTImporter, on return type declared inside body of C++11 lambda without trailing return (#GH68775). - Fixed declaration name source location of instantiated function definitions (GH71161). +- Missing fallback to expression in the template differ when comparing ValueDecls. erichkeane wrote: ```suggestion - Improve diagnostic output to print an expression instead of 'no argument` when comparing Values as template arguments. ``` Or something like this? https://github.com/llvm/llvm-project/pull/93266 ___ 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] [Serialization] No transitive identifier change (PR #92085)
@@ -3896,7 +3903,7 @@ void ASTWriter::WriteIdentifierTable(Preprocessor &PP, // Write out identifiers if either the ID is local or the identifier has // changed since it was loaded. - if (ID >= FirstIdentID || !Chain || !II->isFromAST() || + if (isLocalIdentifierID(ID) || !Chain || !II->isFromAST() || jansvoboda11 wrote: This diff makes it seem that `ID >= FirstIdentID` is equivalent to `isLocalIdentifierID(ID)`, which I don't think is the case. Can you explain what's going on here? https://github.com/llvm/llvm-project/pull/92085 ___ 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] [Serialization] No transitive identifier change (PR #92085)
@@ -918,7 +918,7 @@ ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) { SelectorTable &SelTable = Reader.getContext().Selectors; unsigned N = endian::readNext(d); const IdentifierInfo *FirstII = Reader.getLocalIdentifier( - F, endian::readNext(d)); + F, endian::readNext(d)); jansvoboda11 wrote: I think having some kind of `static_assert` that `IdentifierID` is an integral type would be helpful. Maybe that'd be useful even within `endian::readNext()`? https://github.com/llvm/llvm-project/pull/92085 ___ 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] [Serialization] No transitive identifier change (PR #92085)
@@ -124,7 +124,7 @@ struct HeaderFileInfo { /// This ID number will be non-zero when there is a controlling /// macro whose IdentifierInfo may not yet have been loaded from /// external storage. - unsigned ControllingMacroID = 0; + uint64_t ControllingMacroID = 0; jansvoboda11 wrote: This increases the size of `HeaderFileInfo` from 32 to 40 bytes. Can we squash this member with `ControllingMacro` into some kind of tagged pointer & `uint64_t` union to save space? https://github.com/llvm/llvm-project/pull/92085 ___ 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] [mlir] 2790b4d - Revert "[mlir] Fix race condition introduced in ThreadLocalCache (#93280)"
Author: Kiran Chandramohan Date: 2024-05-24T11:18:55+01:00 New Revision: 2790b4d9e63c13d1e692cc301bbd373b10f28070 URL: https://github.com/llvm/llvm-project/commit/2790b4d9e63c13d1e692cc301bbd373b10f28070 DIFF: https://github.com/llvm/llvm-project/commit/2790b4d9e63c13d1e692cc301bbd373b10f28070.diff LOG: Revert "[mlir] Fix race condition introduced in ThreadLocalCache (#93280)" This reverts commit 6977bfb57c3efb9488aef463cd7ea521fd25a067. Added: Modified: mlir/include/mlir/Support/ThreadLocalCache.h Removed: diff --git a/mlir/include/mlir/Support/ThreadLocalCache.h b/mlir/include/mlir/Support/ThreadLocalCache.h index fe6c6fa3cf6bd..d19257bf6e25e 100644 --- a/mlir/include/mlir/Support/ThreadLocalCache.h +++ b/mlir/include/mlir/Support/ThreadLocalCache.h @@ -16,6 +16,7 @@ #include "mlir/Support/LLVM.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Mutex.h" namespace mlir { @@ -24,80 +25,28 @@ namespace mlir { /// cache has very large lock contention. template class ThreadLocalCache { - struct PerInstanceState; - - /// The "observer" is owned by a thread-local cache instance. It is - /// constructed the first time a `ThreadLocalCache` instance is accessed by a - /// thread, unless `perInstanceState` happens to get re-allocated to the same - /// address as a previous one. This class is destructed the thread in which - /// the `thread_local` cache lives is destroyed. - /// - /// This class is called the "observer" because while values cached in - /// thread-local caches are owned by `PerInstanceState`, a reference is stored - /// via this class in the TLC. With a double pointer, it knows when the - /// referenced value has been destroyed. - struct Observer { -/// This is the double pointer, explicitly allocated because we need to keep -/// the address stable if the TLC map re-allocates. It is owned by the -/// observer and shared with the value owner. -std::shared_ptr ptr = std::make_shared(nullptr); -/// Because `Owner` living inside `PerInstanceState` contains a reference to -/// the double pointer, and livkewise this class contains a reference to the -/// value, we need to synchronize destruction of the TLC and the -/// `PerInstanceState` to avoid racing. This weak pointer is acquired during -/// TLC destruction if the `PerInstanceState` hasn't entered its destructor -/// yet, and prevents it from happening. -std::weak_ptr keepalive; - }; - - /// This struct owns the cache entries. It contains a reference back to the - /// reference inside the cache so that it can be written to null to indicate - /// that the cache entry is invalidated. It needs to do this because - /// `perInstanceState` could get re-allocated to the same pointer and we don't - /// remove entries from the TLC when it is deallocated. Thus, we have to reset - /// the TLC entries to a starting state in case the `ThreadLocalCache` lives - /// shorter than the threads. - struct Owner { -/// Save a pointer to the reference and write it to the newly created entry. -Owner(Observer &observer) -: value(std::make_unique()), ptrRef(observer.ptr) { - *observer.ptr = value.get(); -} -~Owner() { - if (std::shared_ptr ptr = ptrRef.lock()) -*ptr = nullptr; -} - -Owner(Owner &&) = default; -Owner &operator=(Owner &&) = default; - -std::unique_ptr value; -std::weak_ptr ptrRef; - }; - // Keep a separate shared_ptr protected state that can be acquired atomically // instead of using shared_ptr's for each value. This avoids a problem // where the instance shared_ptr is locked() successfully, and then the // ThreadLocalCache gets destroyed before remove() can be called successfully. struct PerInstanceState { -/// Remove the given value entry. This is called when a thread local cache -/// is destructing but still contains references to values owned by the -/// `PerInstanceState`. Removal is required because it prevents writeback to -/// a pointer that was deallocated. +/// Remove the given value entry. This is generally called when a thread +/// local cache is destructing. void remove(ValueT *value) { // Erase the found value directly, because it is guaranteed to be in the // list. llvm::sys::SmartScopedLock threadInstanceLock(instanceMutex); - auto it = llvm::find_if(instances, [&](Owner &instance) { -return instance.value.get() == value; - }); + auto it = + llvm::find_if(instances, [&](std::unique_ptr &instance) { +return instance.get() == value; + }); assert(it != instances.end() && "expected value to exist in cache"); instances.erase(it); } /// Owning pointers to all of the values that have been constructed for this
[llvm-branch-commits] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
@@ -1694,6 +1718,35 @@ let Predicates = [HasPAuth] in { def BLRABZ : AuthOneOperand<0b001, 1, "blrabz">; } + // BLRA pseudo, generalized version of BLRAA/BLRAB/Z. + // This directly manipulates x16/x17, which are the only registers the OS + // guarantees are safe to use for sensitive operations. kovdan01 wrote: Yes, having a more detailed comment here would be nice. As for now, from the comment it was unclear that this is Darwin-specific. It's also probably worth mentioning that it's harmless for non-Darwin, as you said. https://github.com/llvm/llvm-project/pull/85736 ___ 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] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
@@ -817,10 +817,44 @@ bool AArch64ExpandPseudo::expandCALL_RVMARKER( MachineInstr &MI = *MBBI; MachineOperand &RVTarget = MI.getOperand(0); assert(RVTarget.isGlobal() && "invalid operand for attached call"); - MachineInstr *OriginalCall = - createCall(MBB, MBBI, TII, MI.getOperand(1), - // Regmask starts after the RV and call targets. - /*RegMaskStartIdx=*/2); + + MachineInstr *OriginalCall = nullptr; + + if (MI.getOpcode() == AArch64::BLRA_RVMARKER) { +// Pointer auth call. +MachineOperand &Key = MI.getOperand(2); +assert((Key.getImm() == 0 || Key.getImm() == 1) && + "invalid key for ptrauth call"); +MachineOperand &IntDisc = MI.getOperand(3); kovdan01 wrote: ```suggestion const MachineOperand &IntDisc = MI.getOperand(3); ``` https://github.com/llvm/llvm-project/pull/85736 ___ 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] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
@@ -817,10 +817,44 @@ bool AArch64ExpandPseudo::expandCALL_RVMARKER( MachineInstr &MI = *MBBI; MachineOperand &RVTarget = MI.getOperand(0); assert(RVTarget.isGlobal() && "invalid operand for attached call"); - MachineInstr *OriginalCall = - createCall(MBB, MBBI, TII, MI.getOperand(1), - // Regmask starts after the RV and call targets. - /*RegMaskStartIdx=*/2); + + MachineInstr *OriginalCall = nullptr; + + if (MI.getOpcode() == AArch64::BLRA_RVMARKER) { +// Pointer auth call. +MachineOperand &Key = MI.getOperand(2); +assert((Key.getImm() == 0 || Key.getImm() == 1) && + "invalid key for ptrauth call"); +MachineOperand &IntDisc = MI.getOperand(3); +MachineOperand &AddrDisc = MI.getOperand(4); + +OriginalCall = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(AArch64::BLRA)) + .getInstr(); +OriginalCall->addOperand(MI.getOperand(1)); +OriginalCall->addOperand(Key); +OriginalCall->addOperand(IntDisc); +OriginalCall->addOperand(AddrDisc); + +unsigned RegMaskStartIdx = 5; +// Skip register arguments. Those are added during ISel, but are not +// needed for the concrete branch. +while (!MI.getOperand(RegMaskStartIdx).isRegMask()) { + auto MOP = MI.getOperand(RegMaskStartIdx); kovdan01 wrote: Just above `auto` is not used in the same kind of assignments. IMHO things should be kept consistent, so either `const auto &` or `const MachineOperand &` should be used for all such cases in this context. https://github.com/llvm/llvm-project/pull/85736 ___ 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] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
@@ -9206,6 +9222,31 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) { LowerCallTo(I, Callee, I.isTailCall(), I.isMustTailCall()); } +void SelectionDAGBuilder::LowerCallSiteWithPtrAuthBundle( +const CallBase &CB, const BasicBlock *EHPadBB) { + auto PAB = CB.getOperandBundle("ptrauth"); + auto *CalleeV = CB.getCalledOperand(); kovdan01 wrote: ```suggestion const auto *CalleeV = CB.getCalledOperand(); ``` https://github.com/llvm/llvm-project/pull/85736 ___ 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] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
@@ -9206,6 +9222,31 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) { LowerCallTo(I, Callee, I.isTailCall(), I.isMustTailCall()); } +void SelectionDAGBuilder::LowerCallSiteWithPtrAuthBundle( +const CallBase &CB, const BasicBlock *EHPadBB) { + auto PAB = CB.getOperandBundle("ptrauth"); + auto *CalleeV = CB.getCalledOperand(); + + // Gather the call ptrauth data from the operand bundle: + // [ i32 , i64 ] + auto *Key = cast(PAB->Inputs[0]); + Value *Discriminator = PAB->Inputs[1]; kovdan01 wrote: ```suggestion const Value *Discriminator = PAB->Inputs[1]; ``` https://github.com/llvm/llvm-project/pull/85736 ___ 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] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
@@ -8640,6 +8642,15 @@ void SelectionDAGBuilder::LowerCallTo(const CallBase &CB, SDValue Callee, CB.countOperandBundlesOfType(LLVMContext::OB_preallocated) != 0) .setCFIType(CFIType) .setConvergenceControlToken(ConvControlToken); + + // Set the pointer authentication info if we have it. + if (PAI) { +if (!TLI.supportPtrAuthBundles()) + report_fatal_error( kovdan01 wrote: OK, your point makes sense, let's leave it "as is" if nobody else minds https://github.com/llvm/llvm-project/pull/85736 ___ 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] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
@@ -817,10 +817,44 @@ bool AArch64ExpandPseudo::expandCALL_RVMARKER( MachineInstr &MI = *MBBI; MachineOperand &RVTarget = MI.getOperand(0); assert(RVTarget.isGlobal() && "invalid operand for attached call"); - MachineInstr *OriginalCall = - createCall(MBB, MBBI, TII, MI.getOperand(1), - // Regmask starts after the RV and call targets. - /*RegMaskStartIdx=*/2); + + MachineInstr *OriginalCall = nullptr; + + if (MI.getOpcode() == AArch64::BLRA_RVMARKER) { +// Pointer auth call. +MachineOperand &Key = MI.getOperand(2); +assert((Key.getImm() == 0 || Key.getImm() == 1) && + "invalid key for ptrauth call"); +MachineOperand &IntDisc = MI.getOperand(3); +MachineOperand &AddrDisc = MI.getOperand(4); kovdan01 wrote: ```suggestion const MachineOperand &AddrDisc = MI.getOperand(4); ``` https://github.com/llvm/llvm-project/pull/85736 ___ 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] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
@@ -2642,6 +2642,20 @@ bool IRTranslator::translateCallBase(const CallBase &CB, } } + std::optional PAI; + if (CB.countOperandBundlesOfType(LLVMContext::OB_ptrauth)) { +// Functions should never be ptrauth-called directly. +assert(!CB.getCalledFunction() && "invalid direct ptrauth call"); + +auto PAB = CB.getOperandBundle("ptrauth"); +Value *Key = PAB->Inputs[0]; +Value *Discriminator = PAB->Inputs[1]; kovdan01 wrote: ```suggestion const Value *Discriminator = PAB->Inputs[1]; ``` https://github.com/llvm/llvm-project/pull/85736 ___ 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] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
@@ -9206,6 +9222,31 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) { LowerCallTo(I, Callee, I.isTailCall(), I.isMustTailCall()); } +void SelectionDAGBuilder::LowerCallSiteWithPtrAuthBundle( +const CallBase &CB, const BasicBlock *EHPadBB) { + auto PAB = CB.getOperandBundle("ptrauth"); + auto *CalleeV = CB.getCalledOperand(); + + // Gather the call ptrauth data from the operand bundle: + // [ i32 , i64 ] + auto *Key = cast(PAB->Inputs[0]); kovdan01 wrote: ```suggestion const auto *Key = cast(PAB->Inputs[0]); ``` https://github.com/llvm/llvm-project/pull/85736 ___ 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] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
https://github.com/kovdan01 requested changes to this pull request. @ahmedbougacha In terms of functionality, LGTM (but I'll prefer other guys also looking through the changes). I've left several minor style-related comments. One more overall style comment which might probably require an additional PR: sometimes identifiers use `PtrAuth`, sometimes `Ptrauth`. Is this intentional? If not, I suggest to use the same case style - it would keep things consistent and allow for case-sensitive search. https://github.com/llvm/llvm-project/pull/85736 ___ 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] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
@@ -1769,6 +1775,41 @@ void AArch64AsmPrinter::emitPtrauthAuthResign(const MachineInstr *MI) { OutStreamer->emitLabel(EndSym); } +void AArch64AsmPrinter::emitPtrauthBranch(const MachineInstr *MI) { + unsigned InstsEmitted = 0; + kovdan01 wrote: This blank line is probably unintentional and does not seem to improve readability, so IMHO should be deleted https://github.com/llvm/llvm-project/pull/85736 ___ 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] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
@@ -817,10 +817,44 @@ bool AArch64ExpandPseudo::expandCALL_RVMARKER( MachineInstr &MI = *MBBI; MachineOperand &RVTarget = MI.getOperand(0); assert(RVTarget.isGlobal() && "invalid operand for attached call"); - MachineInstr *OriginalCall = - createCall(MBB, MBBI, TII, MI.getOperand(1), - // Regmask starts after the RV and call targets. - /*RegMaskStartIdx=*/2); + + MachineInstr *OriginalCall = nullptr; + + if (MI.getOpcode() == AArch64::BLRA_RVMARKER) { +// Pointer auth call. +MachineOperand &Key = MI.getOperand(2); kovdan01 wrote: ```suggestion const MachineOperand &Key = MI.getOperand(2); ``` https://github.com/llvm/llvm-project/pull/85736 ___ 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] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
@@ -2642,6 +2642,20 @@ bool IRTranslator::translateCallBase(const CallBase &CB, } } + std::optional PAI; + if (CB.countOperandBundlesOfType(LLVMContext::OB_ptrauth)) { +// Functions should never be ptrauth-called directly. +assert(!CB.getCalledFunction() && "invalid direct ptrauth call"); + +auto PAB = CB.getOperandBundle("ptrauth"); +Value *Key = PAB->Inputs[0]; kovdan01 wrote: ```suggestion const Value *Key = PAB->Inputs[0]; ``` https://github.com/llvm/llvm-project/pull/85736 ___ 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] [llvm] [AArch64][PAC] Lower authenticated calls with ptrauth bundles. (PR #85736)
https://github.com/kovdan01 edited https://github.com/llvm/llvm-project/pull/85736 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits