[llvm] r332993 - [ORC] Move symbol-scanning and discard from BasicIRLayerMaterializationUnit in
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Tue May 22 09:15:38 PDT 2018
Author: lhames
Date: Tue May 22 09:15:38 2018
New Revision: 332993
URL: http://llvm.org/viewvc/llvm-project?rev=332993&view=rev
Log:
[ORC] Move symbol-scanning and discard from BasicIRLayerMaterializationUnit in
to a base class (IRMaterializationUnit).
The new class, IRMaterializationUnit, provides a convenient base for any client
that wants to write a materializer for LLVM IR.
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=332993&r1=332992&r2=332993&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/Layer.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/Layer.h Tue May 22 09:15:38 2018
@@ -46,19 +46,29 @@ private:
ExecutionSession &ES;
};
-class BasicIRLayerMaterializationUnit : public MaterializationUnit {
+class IRMaterializationUnit : public MaterializationUnit {
+public:
+ IRMaterializationUnit(ExecutionSession &ES, std::unique_ptr<Module> M);
+
+protected:
+ std::unique_ptr<Module> M;
+
+private:
+ void discard(const VSO &V, SymbolStringPtr Name) override;
+
+ std::map<SymbolStringPtr, GlobalValue *> Discardable;
+};
+
+class BasicIRLayerMaterializationUnit : public IRMaterializationUnit {
public:
BasicIRLayerMaterializationUnit(IRLayer &L, VModuleKey K,
std::unique_ptr<Module> M);
-
private:
+
void materialize(MaterializationResponsibility R) override;
- void discard(const VSO &V, SymbolStringPtr Name) override;
IRLayer &L;
VModuleKey K;
- std::unique_ptr<Module> M;
- std::map<SymbolStringPtr, GlobalValue *> Discardable;
};
class ObjectLayer {
Modified: llvm/trunk/lib/ExecutionEngine/Orc/Layer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/Layer.cpp?rev=332993&r1=332992&r2=332993&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/Layer.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/Layer.cpp Tue May 22 09:15:38 2018
@@ -35,12 +35,10 @@ Error IRLayer::add(VSO &V, VModuleKey K,
*this, std::move(K), std::move(M)));
}
-BasicIRLayerMaterializationUnit::BasicIRLayerMaterializationUnit(
- IRLayer &L, VModuleKey K, std::unique_ptr<Module> M)
- : MaterializationUnit(SymbolFlagsMap()), L(L), K(std::move(K)),
- M(std::move(M)) {
+IRMaterializationUnit::IRMaterializationUnit(ExecutionSession &ES,
+ std::unique_ptr<Module> M)
+ : MaterializationUnit(SymbolFlagsMap()), M(std::move(M)) {
- auto &ES = L.getExecutionSession();
MangleAndInterner Mangle(ES, this->M->getDataLayout());
for (auto &G : this->M->global_values()) {
if (G.hasName() && !G.isDeclaration() &&
@@ -53,13 +51,7 @@ BasicIRLayerMaterializationUnit::BasicIR
}
}
-void BasicIRLayerMaterializationUnit::materialize(
- MaterializationResponsibility R) {
- L.emit(std::move(R), std::move(K), std::move(M));
-}
-
-void BasicIRLayerMaterializationUnit::discard(const VSO &V,
- SymbolStringPtr Name) {
+void IRMaterializationUnit::discard(const VSO &V, SymbolStringPtr Name) {
auto I = Discardable.find(Name);
assert(I != Discardable.end() &&
"Symbol not provided by this MU, or previously discarded");
@@ -67,6 +59,16 @@ void BasicIRLayerMaterializationUnit::di
Discardable.erase(I);
}
+BasicIRLayerMaterializationUnit::BasicIRLayerMaterializationUnit(
+ IRLayer &L, VModuleKey K, std::unique_ptr<Module> M)
+ : IRMaterializationUnit(L.getExecutionSession(), std::move(M)),
+ L(L), K(std::move(K)) {}
+
+void BasicIRLayerMaterializationUnit::materialize(
+ MaterializationResponsibility R) {
+ L.emit(std::move(R), std::move(K), std::move(M));
+}
+
ObjectLayer::ObjectLayer(ExecutionSession &ES) : ES(ES) {}
ObjectLayer::~ObjectLayer() {}
More information about the llvm-commits
mailing list