[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.
This commit is contained in:
@@ -242,8 +242,10 @@ public:
|
||||
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:
|
||||
|
||||
@@ -43,6 +43,13 @@ protected:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user