Commit ee18f390 by Ben Clayton Committed by Antonio Maiorano

LLVM: Replace legacy ORC JIT with new API

Also fix crashes when building with `REACTOR_EMIT_DEBUG_INFO`, but with a no-debug-info build. Change-Id: I183473a78235b938b44bf4a017f5239c78827285 Bug: b/171236524 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43811 Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent df17a761
......@@ -56,7 +56,12 @@ __pragma(warning(push))
std::pair<llvm::StringRef, llvm::StringRef> splitPath(const char *path)
{
return llvm::StringRef(path).rsplit('/');
auto dirAndFile = llvm::StringRef(path).rsplit('/');
if(dirAndFile.second == "")
{
dirAndFile.second = "<unknown>";
}
return dirAndFile;
}
// Note: createGDBRegistrationListener() returns a pointer to a singleton.
......@@ -82,11 +87,11 @@ DebugInfo::DebugInfo(
auto location = getCallerLocation();
auto fileAndDir = splitPath(location.function.file.c_str());
auto dirAndFile = splitPath(location.function.file.c_str());
diBuilder.reset(new llvm::DIBuilder(*module));
diCU = diBuilder->createCompileUnit(
llvm::dwarf::DW_LANG_C,
diBuilder->createFile(fileAndDir.first, fileAndDir.second),
diBuilder->createFile(dirAndFile.second, dirAndFile.first),
"Reactor",
0, "", 0);
......@@ -135,7 +140,10 @@ void DebugInfo::EmitLocation()
void DebugInfo::Flush()
{
emitPending(diScope.back(), builder);
if(!diScope.empty())
{
emitPending(diScope.back(), builder);
}
}
void DebugInfo::syncScope(Backtrace const &backtrace)
......@@ -376,17 +384,15 @@ void DebugInfo::emitPending(Scope &scope, IRBuilder *builder)
scope.pending = Pending{};
}
void DebugInfo::NotifyObjectEmitted(const llvm::object::ObjectFile &Obj, const llvm::LoadedObjectInfo &L)
void DebugInfo::NotifyObjectEmitted(uint64_t key, const llvm::object::ObjectFile &obj, const llvm::LoadedObjectInfo &l)
{
std::unique_lock<std::mutex> lock(jitEventListenerMutex);
auto key = reinterpret_cast<llvm::JITEventListener::ObjectKey>(&Obj);
jitEventListener->notifyObjectLoaded(key, Obj, static_cast<const llvm::RuntimeDyld::LoadedObjectInfo &>(L));
jitEventListener->notifyObjectLoaded(key, obj, static_cast<const llvm::RuntimeDyld::LoadedObjectInfo &>(l));
}
void DebugInfo::NotifyFreeingObject(const llvm::object::ObjectFile &Obj)
void DebugInfo::NotifyFreeingObject(uint64_t key)
{
std::unique_lock<std::mutex> lock(jitEventListenerMutex);
auto key = reinterpret_cast<llvm::JITEventListener::ObjectKey>(&Obj);
jitEventListener->notifyFreeingObject(key);
}
......@@ -432,7 +438,8 @@ void DebugInfo::registerBasicTypes()
Location DebugInfo::getCallerLocation() const
{
return getCallerBacktrace(1)[0];
auto backtrace = getCallerBacktrace(1);
return backtrace.empty() ? Location{} : backtrace[0];
}
Backtrace DebugInfo::getCallerBacktrace(size_t limit /* = 0 */) const
......
......@@ -92,11 +92,11 @@ public:
// NotifyObjectEmitted informs any attached debuggers of the JIT'd
// object.
static void NotifyObjectEmitted(const llvm::object::ObjectFile &Obj, const llvm::LoadedObjectInfo &L);
static void NotifyObjectEmitted(uint64_t key, const llvm::object::ObjectFile &obj, const llvm::LoadedObjectInfo &l);
// NotifyFreeingObject informs any attached debuggers that the JIT'd
// object is now invalid.
static void NotifyFreeingObject(const llvm::object::ObjectFile &Obj);
static void NotifyFreeingObject(uint64_t key);
private:
struct Token
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment