[llvm] a01c4ee - [ORC] Rename TargetProcessControl DynamicLibraryHandle and loadLibrary.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 25 15:21:58 PDT 2020


Author: Lang Hames
Date: 2020-07-25T15:21:43-07:00
New Revision: a01c4ee71cb2bcdd1fd93396af2ed6dc25f5f828

URL: https://github.com/llvm/llvm-project/commit/a01c4ee71cb2bcdd1fd93396af2ed6dc25f5f828
DIFF: https://github.com/llvm/llvm-project/commit/a01c4ee71cb2bcdd1fd93396af2ed6dc25f5f828.diff

LOG: [ORC] Rename TargetProcessControl DynamicLibraryHandle and loadLibrary.

The new names, DylibHandle and loadDylib, are more concise and make
clear that these utilities are for loading dynamic libraries, not static
ones.

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h
    llvm/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h
    llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp
    llvm/lib/ExecutionEngine/Orc/TargetProcessControl.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h b/llvm/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h
index 6c95e22a4257..d35c8abc84a2 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.h
@@ -27,10 +27,9 @@ class TPCDynamicLibrarySearchGenerator : public JITDylib::DefinitionGenerator {
   /// If the Allow predicate is given then only symbols matching the predicate
   /// will be searched for. If the predicate is not given then all symbols will
   /// be searched for.
-  TPCDynamicLibrarySearchGenerator(
-      TargetProcessControl &TPC,
-      TargetProcessControl::DynamicLibraryHandle DylibHandle)
-      : TPC(TPC), DylibHandle(DylibHandle) {}
+  TPCDynamicLibrarySearchGenerator(TargetProcessControl &TPC,
+                                   TargetProcessControl::DylibHandle H)
+      : TPC(TPC), H(H) {}
 
   /// Permanently loads the library at the given path and, on success, returns
   /// a DynamicLibrarySearchGenerator that will search it for symbol definitions
@@ -51,7 +50,7 @@ class TPCDynamicLibrarySearchGenerator : public JITDylib::DefinitionGenerator {
 
 private:
   TargetProcessControl &TPC;
-  TargetProcessControl::DynamicLibraryHandle DylibHandle;
+  TargetProcessControl::DylibHandle H;
 };
 
 } // end namespace orc

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h
index 887ac94e4d5c..e260c64bee51 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcessControl.h
@@ -110,15 +110,18 @@ class TargetProcessControl {
     }
   };
 
-  using DynamicLibraryHandle = JITTargetAddress;
-
-  /// Request lookup within a single library.
-  /// If Library is None then the whole target process should be searched.
+  /// A handle for a library opened via loadDylib.
+  ///
+  /// Note that this handle does not necessarily represent a JITDylib: it may
+  /// be a regular dynamic library or shared object (e.g. one opened via a
+  /// dlopen in the target process).
+  using DylibHandle = JITTargetAddress;
+
+  /// Request lookup within the given DylibHandle.
   struct LookupRequestElement {
-    LookupRequestElement(DynamicLibraryHandle Handle,
-                         const SymbolLookupSet &Symbols)
+    LookupRequestElement(DylibHandle Handle, const SymbolLookupSet &Symbols)
         : Handle(Handle), Symbols(Symbols) {}
-    DynamicLibraryHandle Handle;
+    DylibHandle Handle;
     const SymbolLookupSet &Symbols;
   };
 
@@ -140,11 +143,10 @@ class TargetProcessControl {
   /// Return a MemoryAccess object for the target process.
   MemoryAccess &getMemoryAccess() const { return *MemAccess; }
 
-  /// Load the library at the given path. Returns a handle to the loaded
-  /// library. If LibraryPath is null this function will return the global
-  /// handle for the target process.
-  virtual Expected<DynamicLibraryHandle>
-  loadLibrary(const char *LibraryPath) = 0;
+  /// Load the dynamic library at the given path and return a handle to it.
+  /// If LibraryPath is null this function will return the global handle for
+  /// the target process.
+  virtual Expected<DylibHandle> loadDylib(const char *DylibPath) = 0;
 
   /// Search for symbols in the target process.
   /// The result of the lookup is a 2-dimentional array of target addresses
@@ -167,7 +169,7 @@ class SelfTargetProcessControl : public TargetProcessControl,
 
   static Expected<std::unique_ptr<SelfTargetProcessControl>> Create();
 
-  Expected<DynamicLibraryHandle> loadLibrary(const char *LibraryPath) override;
+  Expected<DylibHandle> loadDylib(const char *DylibPath) override;
 
   Expected<LookupResult> lookupSymbols(LookupRequest Request) override;
 

diff  --git a/llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp b/llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp
index ea8bde971d1d..18de5b616eec 100644
--- a/llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp
@@ -14,7 +14,7 @@ namespace orc {
 Expected<std::unique_ptr<TPCDynamicLibrarySearchGenerator>>
 TPCDynamicLibrarySearchGenerator::Load(TargetProcessControl &TPC,
                                        const char *LibraryPath) {
-  auto Handle = TPC.loadLibrary(LibraryPath);
+  auto Handle = TPC.loadDylib(LibraryPath);
   if (!Handle)
     return Handle.takeError();
 
@@ -30,7 +30,7 @@ Error TPCDynamicLibrarySearchGenerator::tryToGenerate(
 
   SymbolMap NewSymbols;
 
-  TargetProcessControl::LookupRequestElement Request(DylibHandle, Symbols);
+  TargetProcessControl::LookupRequestElement Request(H, Symbols);
   auto Result = TPC.lookupSymbols(Request);
   if (!Result)
     return Result.takeError();

diff  --git a/llvm/lib/ExecutionEngine/Orc/TargetProcessControl.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcessControl.cpp
index 3f9a938db339..f17f5bf32856 100644
--- a/llvm/lib/ExecutionEngine/Orc/TargetProcessControl.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/TargetProcessControl.cpp
@@ -42,11 +42,11 @@ SelfTargetProcessControl::Create() {
   return std::make_unique<SelfTargetProcessControl>(std::move(TT), *PageSize);
 }
 
-Expected<TargetProcessControl::DynamicLibraryHandle>
-SelfTargetProcessControl::loadLibrary(const char *LibraryPath) {
+Expected<TargetProcessControl::DylibHandle>
+SelfTargetProcessControl::loadDylib(const char *DylibPath) {
   std::string ErrMsg;
   auto Dylib = std::make_unique<sys::DynamicLibrary>(
-      sys::DynamicLibrary::getPermanentLibrary(LibraryPath, &ErrMsg));
+      sys::DynamicLibrary::getPermanentLibrary(DylibPath, &ErrMsg));
   if (!Dylib->isValid())
     return make_error<StringError>(std::move(ErrMsg), inconvertibleErrorCode());
   DynamicLibraries.push_back(std::move(Dylib));


        


More information about the llvm-commits mailing list