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 {
*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() &&
}
}
-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");
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() {}