[llvm] r333852 - [ORC] Add a constructor to create an IRMaterializationUnit from a module and

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 3 12:22:48 PDT 2018


Author: lhames
Date: Sun Jun  3 12:22:48 2018
New Revision: 333852

URL: http://llvm.org/viewvc/llvm-project?rev=333852&view=rev
Log:
[ORC] Add a constructor to create an IRMaterializationUnit from a module and
pre-existing SymbolFlags and SymbolToDefinition maps.

This constructor is useful when delegating work from an existing
IRMaterialiaztionUnit to a new one, as it avoids the cost of re-computing these
maps.

Modified:
    llvm/trunk/include/llvm/ExecutionEngine/Orc/Layer.h
    llvm/trunk/lib/ExecutionEngine/Orc/Layer.cpp

Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/Layer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/Layer.h?rev=333852&r1=333851&r2=333852&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/Layer.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/Layer.h Sun Jun  3 12:22:48 2018
@@ -59,11 +59,23 @@ private:
 /// their linkage is changed to available-externally.
 class IRMaterializationUnit : public MaterializationUnit {
 public:
+  using SymbolNameToDefinitionMap = std::map<SymbolStringPtr, GlobalValue *>;
+
+  /// Create an IRMaterializationLayer. Scans the module to build the
+  /// SymbolFlags and SymbolToDefinition maps.
   IRMaterializationUnit(ExecutionSession &ES, std::unique_ptr<Module> M);
 
+  /// Create an IRMaterializationLayer from a module, and pre-existing
+  /// SymbolFlags and SymbolToDefinition maps. The maps must provide
+  /// entries for each definition in M.
+  /// This constructor is useful for delegating work from one
+  /// IRMaterializationUnit to another.
+  IRMaterializationUnit(std::unique_ptr<Module> M, SymbolFlagsMap SymbolFlags,
+                        SymbolNameToDefinitionMap SymbolToDefinition);
+
 protected:
   std::unique_ptr<Module> M;
-  std::map<SymbolStringPtr, GlobalValue *> SymbolToDefinition;
+  SymbolNameToDefinitionMap SymbolToDefinition;
 
 private:
   void discard(const VSO &V, SymbolStringPtr Name) override;

Modified: llvm/trunk/lib/ExecutionEngine/Orc/Layer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/Layer.cpp?rev=333852&r1=333851&r2=333852&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/Layer.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/Layer.cpp Sun Jun  3 12:22:48 2018
@@ -51,6 +51,12 @@ IRMaterializationUnit::IRMaterialization
   }
 }
 
+IRMaterializationUnit::IRMaterializationUnit(
+    std::unique_ptr<Module> M, SymbolFlagsMap SymbolFlags,
+    SymbolNameToDefinitionMap SymbolToDefinition)
+    : MaterializationUnit(std::move(SymbolFlags)), M(std::move(M)),
+      SymbolToDefinition(std::move(SymbolToDefinition)) {}
+
 void IRMaterializationUnit::discard(const VSO &V, SymbolStringPtr Name) {
   auto I = SymbolToDefinition.find(Name);
   assert(I != SymbolToDefinition.end() &&




More information about the llvm-commits mailing list