[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.

llvm-svn: 333852
This commit is contained in:
Lang Hames 2018-06-03 19:22:48 +00:00
parent f886b44693
commit d6155ff002
2 changed files with 19 additions and 1 deletions

View File

@ -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;

View File

@ -51,6 +51,12 @@ IRMaterializationUnit::IRMaterializationUnit(ExecutionSession &ES,
}
}
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() &&