[Mlir-commits] [mlir] d1186fc - [mlir] [ExecutionEngine] add option to enable/disable GDB notification listener
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Mar 9 09:27:35 PDT 2020
Author: aartbik
Date: 2020-03-09T09:26:03-07:00
New Revision: d1186fcb0428437b07390b6664a30829a0e5701e
URL: https://github.com/llvm/llvm-project/commit/d1186fcb0428437b07390b6664a30829a0e5701e
DIFF: https://github.com/llvm/llvm-project/commit/d1186fcb0428437b07390b6664a30829a0e5701e.diff
LOG: [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
Added:
Modified:
mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
mlir/lib/ExecutionEngine/ExecutionEngine.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
index 9bd5d05e5544..958a8b11ac24 100644
--- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
+++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
@@ -60,7 +60,7 @@ class SimpleObjectCache : public llvm::ObjectCache {
/// be used to invoke the JIT-compiled function.
class ExecutionEngine {
public:
- ExecutionEngine(bool enableObjectCache);
+ ExecutionEngine(bool enableObjectCache, bool enableGDBNotificationListener);
/// Creates an execution engine for the given module. If `transformer` is
/// provided, it will be called on the LLVM module during JIT-compilation and
@@ -68,12 +68,16 @@ class ExecutionEngine {
/// when provided, is used as the optimization level for target code
/// generation. If `sharedLibPaths` are provided, the underlying
/// JIT-compilation will open and link the shared libraries for symbol
- /// resolution. If `objectCache` is provided, JIT compiler will use it to
- /// store the object generated for the given module.
- static llvm::Expected<std::unique_ptr<ExecutionEngine>> create(
- ModuleOp m, std::function<llvm::Error(llvm::Module *)> transformer = {},
- Optional<llvm::CodeGenOpt::Level> jitCodeGenOptLevel = llvm::None,
- ArrayRef<StringRef> sharedLibPaths = {}, bool enableObjectCache = false);
+ /// resolution. If `enableObjectCache` is set, the JIT compiler will create
+ /// one to store the object generated for the given module. If enable
+ // `enableGDBNotificationListener` is set, the JIT compiler will notify
+ /// the llvm's global GDB notification listener.
+ static llvm::Expected<std::unique_ptr<ExecutionEngine>>
+ 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
/// pointer to it. Propagates errors in case of failure.
diff --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
index 5399693802ed..f5feddc63606 100644
--- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -182,15 +182,20 @@ static void packFunctionArguments(Module *module) {
}
}
-ExecutionEngine::ExecutionEngine(bool enableObjectCache)
- : cache(enableObjectCache ? nullptr : new SimpleObjectCache()),
- gdbListener(llvm::JITEventListener::createGDBRegistrationListener()) {}
+ExecutionEngine::ExecutionEngine(bool enableObjectCache,
+ bool enableGDBNotificationListener)
+ : cache(enableObjectCache ? new SimpleObjectCache() : nullptr),
+ gdbListener(enableGDBNotificationListener
+ ? llvm::JITEventListener::createGDBRegistrationListener()
+ : nullptr) {}
Expected<std::unique_ptr<ExecutionEngine>> ExecutionEngine::create(
ModuleOp m, std::function<Error(llvm::Module *)> transformer,
Optional<llvm::CodeGenOpt::Level> jitCodeGenOptLevel,
- ArrayRef<StringRef> sharedLibPaths, bool enableObjectCache) {
- auto engine = std::make_unique<ExecutionEngine>(enableObjectCache);
+ ArrayRef<StringRef> sharedLibPaths, bool enableObjectCache,
+ bool enableGDBNotificationListener) {
+ auto engine = std::make_unique<ExecutionEngine>(
+ enableObjectCache, enableGDBNotificationListener);
std::unique_ptr<llvm::LLVMContext> ctx(new llvm::LLVMContext);
auto llvmModule = translateModuleToLLVMIR(m);
@@ -228,9 +233,11 @@ Expected<std::unique_ptr<ExecutionEngine>> ExecutionEngine::create(
[engine = engine.get()](
llvm::orc::VModuleKey, const llvm::object::ObjectFile &object,
const llvm::RuntimeDyld::LoadedObjectInfo &objectInfo) {
- uint64_t key = static_cast<uint64_t>(
- reinterpret_cast<uintptr_t>(object.getData().data()));
- engine->gdbListener->notifyObjectLoaded(key, object, objectInfo);
+ if (engine->gdbListener) {
+ uint64_t key = static_cast<uint64_t>(
+ reinterpret_cast<uintptr_t>(object.getData().data()));
+ engine->gdbListener->notifyObjectLoaded(key, object, objectInfo);
+ }
});
// Resolve symbols from shared libraries.
More information about the Mlir-commits
mailing list