[llvm] 265d6bd - [JITLink] Add a shouldAddDefaultPasses predicate to JITLinkerBase.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 26 17:56:28 PDT 2023
Author: Lang Hames
Date: 2023-08-26T17:56:20-07:00
New Revision: 265d6bda95b1dc84fb37ac8a5f18d2b283a7aa3f
URL: https://github.com/llvm/llvm-project/commit/265d6bda95b1dc84fb37ac8a5f18d2b283a7aa3f
DIFF: https://github.com/llvm/llvm-project/commit/265d6bda95b1dc84fb37ac8a5f18d2b283a7aa3f.diff
LOG: [JITLink] Add a shouldAddDefaultPasses predicate to JITLinkerBase.
This allows JITLinkerBase implementations to check whether default passes
should be added. The ELF_x86_64 backend is updated to check this predicate
before installing the getOrCreateGOTSymbol pass.
This is an alternative solution to https://reviews.llvm.org/D158909.
Added:
Modified:
llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
index 1bdddd4c722bcd..4af2dff57399a4 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
@@ -242,8 +242,10 @@ class ELFJITLinker_x86_64 : public JITLinker<ELFJITLinker_x86_64> {
std::unique_ptr<LinkGraph> G,
PassConfiguration PassConfig)
: JITLinker(std::move(Ctx), std::move(G), std::move(PassConfig)) {
- getPassConfig().PostAllocationPasses.push_back(
- [this](LinkGraph &G) { return getOrCreateGOTSymbol(G); });
+
+ if (shouldAddDefaultTargetPasses(G->getTargetTriple()))
+ getPassConfig().PostAllocationPasses.push_back(
+ [this](LinkGraph &G) { return getOrCreateGOTSymbol(G); });
}
private:
diff --git a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h
index e69eddd6e11944..2dd6d5747f424b 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h
@@ -43,6 +43,13 @@ class JITLinkerBase {
using AllocResult = Expected<std::unique_ptr<InFlightAlloc>>;
using FinalizeResult = Expected<JITLinkMemoryManager::FinalizedAlloc>;
+ // Returns true if the context says that the linker should add default
+ // passes. This can be used by JITLinkerBase implementations when deciding
+ // whether they should add default passes.
+ bool shouldAddDefaultTargetPasses(const Triple &TT) {
+ return Ctx->shouldAddDefaultTargetPasses(TT);
+ }
+
// Returns the PassConfiguration for this instance. This can be used by
// JITLinkerBase implementations to add late passes that reference their
// own data structures (e.g. for ELF implementations to locate / construct
More information about the llvm-commits
mailing list