From 43f5f6916f0e2b0095a943eb19d06dfb8e13c727 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Fri, 19 Nov 2021 20:51:44 -0800 Subject: [PATCH] [ORC][JITLink] Move JITDylib name into JITLinkDylib base class. This will enable better error messages and debug logs in JITLink. --- llvm/include/llvm/ExecutionEngine/JITLink/JITLinkDylib.h | 13 ++++++++++++- llvm/include/llvm/ExecutionEngine/Orc/Core.h | 4 ---- llvm/lib/ExecutionEngine/Orc/Core.cpp | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkDylib.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkDylib.h index 2aa88cb..6bb1b5a 100644 --- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkDylib.h +++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkDylib.h @@ -13,10 +13,21 @@ #ifndef LLVM_EXECUTIONENGINE_JITLINK_JITLINKDYLIB_H #define LLVM_EXECUTIONENGINE_JITLINK_JITLINKDYLIB_H +#include + namespace llvm { namespace jitlink { -class JITLinkDylib {}; +class JITLinkDylib { +public: + JITLinkDylib(std::string Name) : Name(std::move(Name)) {} + + /// Get the name for this JITLinkDylib. + const std::string &getName() const { return Name; } + +private: + std::string Name; +}; } // end namespace jitlink } // end namespace llvm diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h index 5cac65b..70256c1 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h @@ -935,9 +935,6 @@ public: JITDylib(JITDylib &&) = delete; JITDylib &operator=(JITDylib &&) = delete; - /// Get the name for this JITDylib. - const std::string &getName() const { return JITDylibName; } - /// Get a reference to the ExecutionSession for this JITDylib. ExecutionSession &getExecutionSession() const { return ES; } @@ -1200,7 +1197,6 @@ private: failSymbols(FailedSymbolsWorklist); ExecutionSession &ES; - std::string JITDylibName; std::mutex GeneratorsMutex; bool Open = true; SymbolTable Symbols; diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp index 64e5090..6b24d64 100644 --- a/llvm/lib/ExecutionEngine/Orc/Core.cpp +++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp @@ -1364,7 +1364,7 @@ Error JITDylib::remove(const SymbolNameSet &Names) { void JITDylib::dump(raw_ostream &OS) { ES.runSessionLocked([&, this]() { - OS << "JITDylib \"" << JITDylibName << "\" (ES: " + OS << "JITDylib \"" << getName() << "\" (ES: " << format("0x%016" PRIx64, reinterpret_cast(&ES)) << "):\n" << "Link order: " << LinkOrder << "\n" << "Symbol table:\n"; @@ -1450,7 +1450,7 @@ JITDylib::MaterializingInfo::takeQueriesMeeting(SymbolState RequiredState) { } JITDylib::JITDylib(ExecutionSession &ES, std::string Name) - : ES(ES), JITDylibName(std::move(Name)) { + : JITLinkDylib(std::move(Name)), ES(ES) { LinkOrder.push_back({this, JITDylibLookupFlags::MatchAllSymbols}); } -- 2.7.4