[ORC][JITLink] Move JITDylib name into JITLinkDylib base class.
authorLang Hames <lhames@gmail.com>
Sat, 20 Nov 2021 04:51:44 +0000 (20:51 -0800)
committerLang Hames <lhames@gmail.com>
Sat, 20 Nov 2021 04:54:28 +0000 (20:54 -0800)
This will enable better error messages and debug logs in JITLink.

llvm/include/llvm/ExecutionEngine/JITLink/JITLinkDylib.h
llvm/include/llvm/ExecutionEngine/Orc/Core.h
llvm/lib/ExecutionEngine/Orc/Core.cpp

index 2aa88cb..6bb1b5a 100644 (file)
 #ifndef LLVM_EXECUTIONENGINE_JITLINK_JITLINKDYLIB_H
 #define LLVM_EXECUTIONENGINE_JITLINK_JITLINKDYLIB_H
 
+#include <string>
+
 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
index 5cac65b..70256c1 100644 (file)
@@ -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;
index 64e5090..6b24d64 100644 (file)
@@ -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<uintptr_t>(&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});
 }