[llvm] [JITLink] Remove LTmp workaround now that LLVM requires C++17 (PR #213428)
Marc Auberer via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 1 03:44:44 PDT 2026
https://github.com/marcauberer created https://github.com/llvm/llvm-project/pull/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.
>From b081ee75f0fe201dc5d8602ad15c67de195161d5 Mon Sep 17 00:00:00 2001
From: Claude <noreply at anthropic.com>
Date: Fri, 31 Jul 2026 10:43:55 +0000
Subject: [PATCH] [JITLink] Remove LTmp workaround now that LLVM requires C++17
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.
---
.../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 17050b0a52480..c160f9d4e7f05 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<JITLinkerBase> 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<JITLinkerBase> 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<JITLinkerBase> 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<AsyncLookupResult> Result) {
- // Self->linkPhase3(std::move(Self), std::move(Result));
- // });
Ctx->lookup(std::move(ExternalSymbols),
createLookupContinuation(
[S = std::move(Self)](
Expected<AsyncLookupResult> 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<JITLinkerBase> 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 0bf714d6fcdf3..4892a394d9e50 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h
@@ -116,12 +116,10 @@ template <typename LinkerImpl> class JITLinker : public JITLinkerBase {
// 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:
More information about the llvm-commits
mailing list