Make in-process sym lookup configurable.
This commit is contained in:
parent
7347463577
commit
0362d3fcda
@ -68,13 +68,13 @@ IncrementalJIT::IncrementalJIT(
|
||||
m_CompiledModules[Unsafe] = std::move(TSM);
|
||||
});
|
||||
|
||||
// FIXME: Make host process symbol lookup optional on a per-query basis
|
||||
|
||||
char LinkerPrefix = this->TM->createDataLayout().getGlobalPrefix();
|
||||
|
||||
// Process symbol resolution
|
||||
Expected<std::unique_ptr<DynamicLibrarySearchGenerator>> HostProcessLookup =
|
||||
DynamicLibrarySearchGenerator::GetForCurrentProcess(LinkerPrefix);
|
||||
auto HostProcessLookup = DynamicLibrarySearchGenerator::GetForCurrentProcess(
|
||||
LinkerPrefix,
|
||||
[&](const SymbolStringPtr &Sym) {
|
||||
return !m_ForbidDlSymbols.contains(*Sym); });
|
||||
if (!HostProcessLookup) {
|
||||
Err = HostProcessLookup.takeError();
|
||||
return;
|
||||
@ -179,7 +179,18 @@ void* IncrementalJIT::getSymbolAddress(StringRef Name, bool IncludeHostSymbols)
|
||||
if (!IncludeHostSymbols)
|
||||
G.lock();
|
||||
|
||||
std::pair<llvm::StringMapIterator<llvm::NoneType>, bool> insertInfo;
|
||||
if (!IncludeHostSymbols)
|
||||
insertInfo = m_ForbidDlSymbols.insert(Name);
|
||||
|
||||
Expected<JITEvaluatedSymbol> Symbol = Jit->lookup(Name);
|
||||
|
||||
// If m_ForbidDlSymbols already contained Name before we tried to insert it
|
||||
// then some calling frame has added it and will remove it later because its
|
||||
// insertInfo.second is true.
|
||||
if (!IncludeHostSymbols && insertInfo.second)
|
||||
m_ForbidDlSymbols.erase(insertInfo.first);
|
||||
|
||||
if (!Symbol) {
|
||||
// This interface is allowed to return nullptr on a missing symbol without
|
||||
// diagnostics.
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "llvm/ADT/FunctionExtras.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/StringSet.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/ExecutionEngine/Orc/Core.h"
|
||||
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
|
||||
@ -84,6 +85,7 @@ private:
|
||||
std::unique_ptr<llvm::orc::LLJIT> Jit;
|
||||
llvm::orc::SymbolMap m_InjectedSymbols;
|
||||
SharedAtomicFlag SkipHostProcessLookup;
|
||||
llvm::StringSet<> m_ForbidDlSymbols;
|
||||
|
||||
/// FIXME: If the relation between modules and transactions is a bijection, the
|
||||
/// mapping via module pointers here is unnecessary. The transaction should
|
||||
|
Loading…
x
Reference in New Issue
Block a user