Skip to content

Commit

Permalink
Revert "[ORC] Enable JITEventListeners in the RTDyldObjectLinkingLayer."
Browse files Browse the repository at this point in the history
This reverts commit 98f2bb4.

Reverting while I investigate bot failures.
  • Loading branch information
lhames committed Mar 15, 2020
1 parent 7f5b811 commit 9c57717
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 191 deletions.
3 changes: 1 addition & 2 deletions llvm/examples/OrcV2Examples/CMakeLists.txt
@@ -1,7 +1,6 @@
add_subdirectory(BasicOrcV2CBindings)
add_subdirectory(LLJITDumpObjects)
add_subdirectory(LLJITWithObjectCache)
add_subdirectory(LLJITWithCustomObjectLinkingLayer)
add_subdirectory(LLJITWithGDBRegistrationListener)
add_subdirectory(LLJITWithLazyReexports)
add_subdirectory(LLJITWithObjectCache)
add_subdirectory(LLJITWithObjectLinkingLayerPlugin)

This file was deleted.

This file was deleted.

19 changes: 3 additions & 16 deletions llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
Expand Up @@ -16,7 +16,6 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ExecutionEngine/JITEventListener.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/Layer.h"
Expand Down Expand Up @@ -116,23 +115,15 @@ class RTDyldObjectLinkingLayer : public ObjectLayer {
return *this;
}

/// Register a JITEventListener.
void registerJITEventListener(JITEventListener &L);

/// Unregister a JITEventListener.
void unregisterJITEventListener(JITEventListener &L);

private:
Error onObjLoad(VModuleKey K, MaterializationResponsibility &R,
object::ObjectFile &Obj, RuntimeDyld::MemoryManager *MemMgr,
object::ObjectFile &Obj,
std::unique_ptr<RuntimeDyld::LoadedObjectInfo> LoadedObjInfo,
std::map<StringRef, JITEvaluatedSymbol> Resolved,
std::set<StringRef> &InternalSymbols);

void onObjEmit(VModuleKey K, MaterializationResponsibility &R,
object::ObjectFile &Obj,
std::unique_ptr<MemoryBuffer> ObjBuffer,
RuntimeDyld::MemoryManager *MemMgr, Error Err);
void onObjEmit(VModuleKey K, std::unique_ptr<MemoryBuffer> ObjBuffer,
MaterializationResponsibility &R, Error Err);

mutable std::mutex RTDyldLayerMutex;
GetMemoryManagerFunction GetMemoryManager;
Expand All @@ -142,10 +133,6 @@ class RTDyldObjectLinkingLayer : public ObjectLayer {
bool OverrideObjectFlags = false;
bool AutoClaimObjectSymbols = false;
std::vector<std::unique_ptr<RuntimeDyld::MemoryManager>> MemMgrs;
std::vector<JITEventListener *> EventListeners;
DenseMap<RuntimeDyld::MemoryManager *,
std::unique_ptr<RuntimeDyld::LoadedObjectInfo>>
LoadedObjInfos;
};

class LegacyRTDyldObjectLinkingLayerBase {
Expand Down
49 changes: 7 additions & 42 deletions llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
Expand Up @@ -81,12 +81,8 @@ RTDyldObjectLinkingLayer::RTDyldObjectLinkingLayer(

RTDyldObjectLinkingLayer::~RTDyldObjectLinkingLayer() {
std::lock_guard<std::mutex> Lock(RTDyldLayerMutex);
for (auto &MemMgr : MemMgrs) {
for (auto *L : EventListeners)
L->notifyFreeingObject(
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(MemMgr.get())));
for (auto &MemMgr : MemMgrs)
MemMgr->deregisterEHFrames();
}
}

void RTDyldObjectLinkingLayer::emit(MaterializationResponsibility R,
Expand Down Expand Up @@ -159,35 +155,19 @@ void RTDyldObjectLinkingLayer::emit(MaterializationResponsibility R,

jitLinkForORC(
**Obj, std::move(O), *MemMgr, Resolver, ProcessAllSections,
[this, K, SharedR, &Obj, MemMgr, InternalSymbols](
[this, K, SharedR, &Obj, InternalSymbols](
std::unique_ptr<RuntimeDyld::LoadedObjectInfo> LoadedObjInfo,
std::map<StringRef, JITEvaluatedSymbol> ResolvedSymbols) {
return onObjLoad(K, *SharedR, **Obj, MemMgr, std::move(LoadedObjInfo),
return onObjLoad(K, *SharedR, **Obj, std::move(LoadedObjInfo),
ResolvedSymbols, *InternalSymbols);
},
[this, K, SharedR, &Obj, O = std::move(O), MemMgr](Error Err) mutable {
onObjEmit(K, *SharedR, **Obj, std::move(O), MemMgr, std::move(Err));
[this, K, SharedR, O = std::move(O)](Error Err) mutable {
onObjEmit(K, std::move(O), *SharedR, std::move(Err));
});
}

void RTDyldObjectLinkingLayer::registerJITEventListener(JITEventListener &L) {
std::lock_guard<std::mutex> Lock(RTDyldLayerMutex);
assert(llvm::none_of(EventListeners,
[&](JITEventListener *O) { return O == &L; }) &&
"Listener has already been registered");
EventListeners.push_back(&L);
}

void RTDyldObjectLinkingLayer::unregisterJITEventListener(JITEventListener &L) {
std::lock_guard<std::mutex> Lock(RTDyldLayerMutex);
auto I = llvm::find(EventListeners, &L);
assert(I != EventListeners.end() && "Listener not registered");
EventListeners.erase(I);
}

Error RTDyldObjectLinkingLayer::onObjLoad(
VModuleKey K, MaterializationResponsibility &R, object::ObjectFile &Obj,
RuntimeDyld::MemoryManager *MemMgr,
std::unique_ptr<RuntimeDyld::LoadedObjectInfo> LoadedObjInfo,
std::map<StringRef, JITEvaluatedSymbol> Resolved,
std::set<StringRef> &InternalSymbols) {
Expand Down Expand Up @@ -272,17 +252,12 @@ Error RTDyldObjectLinkingLayer::onObjLoad(
if (NotifyLoaded)
NotifyLoaded(K, Obj, *LoadedObjInfo);

std::lock_guard<std::mutex> Lock(RTDyldLayerMutex);
assert(!LoadedObjInfos.count(MemMgr) && "Duplicate loaded info for MemMgr");
LoadedObjInfos[MemMgr] = std::move(LoadedObjInfo);

return Error::success();
}

void RTDyldObjectLinkingLayer::onObjEmit(
VModuleKey K, MaterializationResponsibility &R, object::ObjectFile &Obj,
std::unique_ptr<MemoryBuffer> ObjBuffer, RuntimeDyld::MemoryManager *MemMgr,
Error Err) {
VModuleKey K, std::unique_ptr<MemoryBuffer> ObjBuffer,
MaterializationResponsibility &R, Error Err) {
if (Err) {
getExecutionSession().reportError(std::move(Err));
R.failMaterialization();
Expand All @@ -297,16 +272,6 @@ void RTDyldObjectLinkingLayer::onObjEmit(

if (NotifyEmitted)
NotifyEmitted(K, std::move(ObjBuffer));

// Run EventListener notifyLoaded callbacks.
std::lock_guard<std::mutex> Lock(RTDyldLayerMutex);
auto LOIItr = LoadedObjInfos.find(MemMgr);
assert(LOIItr != LoadedObjInfos.end() && "LoadedObjInfo missing");
for (auto *L : EventListeners)
L->notifyObjectLoaded(
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(MemMgr)), Obj,
*LOIItr->second);
LoadedObjInfos.erase(MemMgr);
}

LegacyRTDyldObjectLinkingLayer::LegacyRTDyldObjectLinkingLayer(
Expand Down
6 changes: 0 additions & 6 deletions llvm/tools/lli/lli.cpp
Expand Up @@ -30,7 +30,6 @@
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
#include "llvm/ExecutionEngine/Orc/MachOPlatform.h"
#include "llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h"
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/OrcMCJITReplacement.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/IRBuilder.h"
Expand Down Expand Up @@ -893,11 +892,6 @@ int runOrcLazyJIT(const char *ProgName) {

auto J = ExitOnErr(Builder.create());

if (TT->isOSBinFormatELF())
static_cast<llvm::orc::RTDyldObjectLinkingLayer &>(J->getObjLinkingLayer())
.registerJITEventListener(
*JITEventListener::createGDBRegistrationListener());

if (PerModuleLazy)
J->setPartitionFunction(orc::CompileOnDemandLayer::compileWholeModule);

Expand Down

0 comments on commit 9c57717

Please sign in to comment.