From 303e63dbd87fcd700990d9c79ee80be7896e529c Mon Sep 17 00:00:00 2001 From: Marc Auberer Date: Sun, 2 Aug 2026 02:32:48 +0200 Subject: [PATCH] [JITLink] Remove LTmp workaround now that LLVM requires C++17 (#213428) C++17 guarantees the postfix-expression naming the called function is sequenced before evaluation of its arguments, so L->linkPhase1(std::move(L)) is well-formed without the LTmp indirection. This should also be implemented by MSVC now. See here (P0145R3 and P0400R0): https://learn.microsoft.com/ar-sa/cpp/overview/visual-cpp-language-conformance?view=msvc-170 Disclaimer: As I have no LLVM Windows machine with MSVC at hand, I was not able to test it myself. Co-authored-by: Claude --- .../JITLink/JITLinkGeneric.cpp | 30 +++---------------- .../ExecutionEngine/JITLink/JITLinkGeneric.h | 8 ++--- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp index 17050b0a5248..c160f9d4e7f0 100644 --- a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp @@ -54,11 +54,7 @@ void JITLinkerBase::linkPhase1(std::unique_ptr Self) { Ctx->getMemoryManager().allocate( Ctx->getJITLinkDylib(), *G, [S = std::move(Self)](AllocResult AR) mutable { - // FIXME: Once MSVC implements c++17 order of evaluation rules for calls - // this can be simplified to - // S->linkPhase2(std::move(S), std::move(AR)); - auto *TmpSelf = S.get(); - TmpSelf->linkPhase2(std::move(S), std::move(AR)); + S->linkPhase2(std::move(S), std::move(AR)); }); } @@ -95,10 +91,7 @@ void JITLinkerBase::linkPhase2(std::unique_ptr Self, dbgs() << "No external symbols for " << G->getName() << ". Proceeding immediately with link phase 3.\n"; }); - // FIXME: Once MSVC implements c++17 order of evaluation rules for calls - // this can be simplified. See below. - auto &TmpSelf = *Self; - TmpSelf.linkPhase3(std::move(Self), AsyncLookupResult()); + Self->linkPhase3(std::move(Self), AsyncLookupResult()); return; } @@ -108,22 +101,11 @@ void JITLinkerBase::linkPhase2(std::unique_ptr Self, << " (may trigger materialization/linking of other graphs)...\n"; }); - // We're about to hand off ownership of ourself to the continuation. Grab a - // pointer to the context so that we can call it to initiate the lookup. - // - // FIXME: Once MSVC implements c++17 order of evaluation rules for calls this - // can be simplified to: - // - // Ctx->lookup(std::move(UnresolvedExternals), - // [Self=std::move(Self)](Expected Result) { - // Self->linkPhase3(std::move(Self), std::move(Result)); - // }); Ctx->lookup(std::move(ExternalSymbols), createLookupContinuation( [S = std::move(Self)]( Expected LookupResult) mutable { - auto &TmpSelf = *S; - TmpSelf.linkPhase3(std::move(S), std::move(LookupResult)); + S->linkPhase3(std::move(S), std::move(LookupResult)); })); } @@ -171,11 +153,7 @@ void JITLinkerBase::linkPhase3(std::unique_ptr Self, } Alloc->finalize([S = std::move(Self)](FinalizeResult FR) mutable { - // FIXME: Once MSVC implements c++17 order of evaluation rules for calls - // this can be simplified to - // S->linkPhase2(std::move(S), std::move(AR)); - auto *TmpSelf = S.get(); - TmpSelf->linkPhase4(std::move(S), std::move(FR)); + S->linkPhase4(std::move(S), std::move(FR)); }); } diff --git a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h index 0bf714d6fcdf..4892a394d9e5 100644 --- a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h +++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h @@ -116,12 +116,10 @@ public: // Ownership of the linker is passed into the linker's doLink function to // allow it to be passed on to async continuations. // - // FIXME: Remove LTmp once we have c++17. // C++17 sequencing rules guarantee that function name expressions are - // sequenced before arguments, so L->linkPhase1(std::move(L), ...) will be - // well formed. - auto <mp = *L; - LTmp.linkPhase1(std::move(L)); + // sequenced before arguments, so L->linkPhase1(std::move(L)) is well + // formed. + L->linkPhase1(std::move(L)); } private: