Skip to content

Commit 265d6bd

Browse files
committed
[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.
1 parent c95f23b commit 265d6bd

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,10 @@ class ELFJITLinker_x86_64 : public JITLinker<ELFJITLinker_x86_64> {
242242
std::unique_ptr<LinkGraph> G,
243243
PassConfiguration PassConfig)
244244
: JITLinker(std::move(Ctx), std::move(G), std::move(PassConfig)) {
245-
getPassConfig().PostAllocationPasses.push_back(
246-
[this](LinkGraph &G) { return getOrCreateGOTSymbol(G); });
245+
246+
if (shouldAddDefaultTargetPasses(G->getTargetTriple()))
247+
getPassConfig().PostAllocationPasses.push_back(
248+
[this](LinkGraph &G) { return getOrCreateGOTSymbol(G); });
247249
}
248250

249251
private:

llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ class JITLinkerBase {
4343
using AllocResult = Expected<std::unique_ptr<InFlightAlloc>>;
4444
using FinalizeResult = Expected<JITLinkMemoryManager::FinalizedAlloc>;
4545

46+
// Returns true if the context says that the linker should add default
47+
// passes. This can be used by JITLinkerBase implementations when deciding
48+
// whether they should add default passes.
49+
bool shouldAddDefaultTargetPasses(const Triple &TT) {
50+
return Ctx->shouldAddDefaultTargetPasses(TT);
51+
}
52+
4653
// Returns the PassConfiguration for this instance. This can be used by
4754
// JITLinkerBase implementations to add late passes that reference their
4855
// own data structures (e.g. for ELF implementations to locate / construct

0 commit comments

Comments
 (0)