forked from OSchip/llvm-project
[mlir] [ExecutionEngine] add option to enable/disable GDB notification listener
Summary: This way, clients can opt-out of the GDB notification listener. Also, this changes the semantics of enabling the object cache, which seemed the wrong way around. Reviewers: rriddle, nicolasvasilache, ftynse, andydavis1 Reviewed By: nicolasvasilache Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75787
This commit is contained in:
parent
cdeeb548bb
commit
d1186fcb04
|
@ -60,7 +60,7 @@ private:
|
||||||
/// be used to invoke the JIT-compiled function.
|
/// be used to invoke the JIT-compiled function.
|
||||||
class ExecutionEngine {
|
class ExecutionEngine {
|
||||||
public:
|
public:
|
||||||
ExecutionEngine(bool enableObjectCache);
|
ExecutionEngine(bool enableObjectCache, bool enableGDBNotificationListener);
|
||||||
|
|
||||||
/// Creates an execution engine for the given module. If `transformer` is
|
/// Creates an execution engine for the given module. If `transformer` is
|
||||||
/// provided, it will be called on the LLVM module during JIT-compilation and
|
/// provided, it will be called on the LLVM module during JIT-compilation and
|
||||||
|
@ -68,12 +68,16 @@ public:
|
||||||
/// when provided, is used as the optimization level for target code
|
/// when provided, is used as the optimization level for target code
|
||||||
/// generation. If `sharedLibPaths` are provided, the underlying
|
/// generation. If `sharedLibPaths` are provided, the underlying
|
||||||
/// JIT-compilation will open and link the shared libraries for symbol
|
/// JIT-compilation will open and link the shared libraries for symbol
|
||||||
/// resolution. If `objectCache` is provided, JIT compiler will use it to
|
/// resolution. If `enableObjectCache` is set, the JIT compiler will create
|
||||||
/// store the object generated for the given module.
|
/// one to store the object generated for the given module. If enable
|
||||||
static llvm::Expected<std::unique_ptr<ExecutionEngine>> create(
|
// `enableGDBNotificationListener` is set, the JIT compiler will notify
|
||||||
ModuleOp m, std::function<llvm::Error(llvm::Module *)> transformer = {},
|
/// the llvm's global GDB notification listener.
|
||||||
Optional<llvm::CodeGenOpt::Level> jitCodeGenOptLevel = llvm::None,
|
static llvm::Expected<std::unique_ptr<ExecutionEngine>>
|
||||||
ArrayRef<StringRef> sharedLibPaths = {}, bool enableObjectCache = false);
|
create(ModuleOp m,
|
||||||
|
std::function<llvm::Error(llvm::Module *)> transformer = {},
|
||||||
|
Optional<llvm::CodeGenOpt::Level> jitCodeGenOptLevel = llvm::None,
|
||||||
|
ArrayRef<StringRef> sharedLibPaths = {}, bool enableObjectCache = true,
|
||||||
|
bool enableGDBNotificationListener = true);
|
||||||
|
|
||||||
/// Looks up a packed-argument function with the given name and returns a
|
/// Looks up a packed-argument function with the given name and returns a
|
||||||
/// pointer to it. Propagates errors in case of failure.
|
/// pointer to it. Propagates errors in case of failure.
|
||||||
|
|
|
@ -182,15 +182,20 @@ static void packFunctionArguments(Module *module) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecutionEngine::ExecutionEngine(bool enableObjectCache)
|
ExecutionEngine::ExecutionEngine(bool enableObjectCache,
|
||||||
: cache(enableObjectCache ? nullptr : new SimpleObjectCache()),
|
bool enableGDBNotificationListener)
|
||||||
gdbListener(llvm::JITEventListener::createGDBRegistrationListener()) {}
|
: cache(enableObjectCache ? new SimpleObjectCache() : nullptr),
|
||||||
|
gdbListener(enableGDBNotificationListener
|
||||||
|
? llvm::JITEventListener::createGDBRegistrationListener()
|
||||||
|
: nullptr) {}
|
||||||
|
|
||||||
Expected<std::unique_ptr<ExecutionEngine>> ExecutionEngine::create(
|
Expected<std::unique_ptr<ExecutionEngine>> ExecutionEngine::create(
|
||||||
ModuleOp m, std::function<Error(llvm::Module *)> transformer,
|
ModuleOp m, std::function<Error(llvm::Module *)> transformer,
|
||||||
Optional<llvm::CodeGenOpt::Level> jitCodeGenOptLevel,
|
Optional<llvm::CodeGenOpt::Level> jitCodeGenOptLevel,
|
||||||
ArrayRef<StringRef> sharedLibPaths, bool enableObjectCache) {
|
ArrayRef<StringRef> sharedLibPaths, bool enableObjectCache,
|
||||||
auto engine = std::make_unique<ExecutionEngine>(enableObjectCache);
|
bool enableGDBNotificationListener) {
|
||||||
|
auto engine = std::make_unique<ExecutionEngine>(
|
||||||
|
enableObjectCache, enableGDBNotificationListener);
|
||||||
|
|
||||||
std::unique_ptr<llvm::LLVMContext> ctx(new llvm::LLVMContext);
|
std::unique_ptr<llvm::LLVMContext> ctx(new llvm::LLVMContext);
|
||||||
auto llvmModule = translateModuleToLLVMIR(m);
|
auto llvmModule = translateModuleToLLVMIR(m);
|
||||||
|
@ -228,9 +233,11 @@ Expected<std::unique_ptr<ExecutionEngine>> ExecutionEngine::create(
|
||||||
[engine = engine.get()](
|
[engine = engine.get()](
|
||||||
llvm::orc::VModuleKey, const llvm::object::ObjectFile &object,
|
llvm::orc::VModuleKey, const llvm::object::ObjectFile &object,
|
||||||
const llvm::RuntimeDyld::LoadedObjectInfo &objectInfo) {
|
const llvm::RuntimeDyld::LoadedObjectInfo &objectInfo) {
|
||||||
uint64_t key = static_cast<uint64_t>(
|
if (engine->gdbListener) {
|
||||||
reinterpret_cast<uintptr_t>(object.getData().data()));
|
uint64_t key = static_cast<uint64_t>(
|
||||||
engine->gdbListener->notifyObjectLoaded(key, object, objectInfo);
|
reinterpret_cast<uintptr_t>(object.getData().data()));
|
||||||
|
engine->gdbListener->notifyObjectLoaded(key, object, objectInfo);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Resolve symbols from shared libraries.
|
// Resolve symbols from shared libraries.
|
||||||
|
|
Loading…
Reference in New Issue