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
mlir
|
@ -60,7 +60,7 @@ private:
|
|||
/// 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 @@ public:
|
|||
/// 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.
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue