[llvm] [ORC] Add absoluteSymbolsLinkGraph to expose absolute symbols to platform (PR #77008)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 5 14:17:54 PST 2024
================
@@ -48,15 +48,22 @@ void JITLinkerBase::linkPhase1(std::unique_ptr<JITLinkerBase> Self) {
if (auto Err = runPasses(Passes.PostPrunePasses))
return Ctx->notifyFailed(std::move(Err));
- 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));
- });
+ auto LinkPhase2 = [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));
+ };
+
+ if (G->allocActions().empty() && llvm::all_of(G->sections(), [](Section &S) {
+ return S.getMemLifetime() == orc::MemLifetime::NoAlloc;
+ })) {
+ LinkPhase2(nullptr);
+ } else {
+ Ctx->getMemoryManager().allocate(Ctx->getJITLinkDylib(), *G,
+ std::move(LinkPhase2));
+ }
----------------
lhames wrote:
Alternatively this could also be:
```c++
// Skip straight to phase 2 if the graph is empty and has no associated actions.
if (G->allocActions().empty() && llvm::all_of(G->sections(), [](Section &S) {
return S.getMemLifetime() == orc::MemLifetime::NoAlloc;
})) {
linkPhase2(std::move(Self), nullptr);
return;
}
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));
});
```
Similarly for the call to phase 4.
That reads more clearly to me, but only marginally.
https://github.com/llvm/llvm-project/pull/77008
More information about the llvm-commits
mailing list