[ORC] Allow IRTransformLayer2's transform to be modified after initialization.

Also give the constructor's transform parameter a default no-op transform value.

llvm-svn: 335665
This commit is contained in:
Lang Hames 2018-06-26 20:59:51 +00:00
parent 2795a0a06e
commit afc2758f55
1 changed files with 10 additions and 3 deletions

View File

@ -29,13 +29,20 @@ public:
using TransformFunction =
std::function<Expected<std::unique_ptr<Module>>(std::unique_ptr<Module>)>;
IRTransformLayer2(ExecutionSession &ES,
IRLayer &BaseLayer,
TransformFunction Transform);
IRTransformLayer2(ExecutionSession &ES, IRLayer &BaseLayer,
TransformFunction Transform = identityTransform);
void setTransform(TransformFunction Transform) {
this->Transform = std::move(Transform);
}
void emit(MaterializationResponsibility R, VModuleKey K,
std::unique_ptr<Module> M) override;
static std::unique_ptr<Module> identityTransform(std::unique_ptr<Module> M) {
return M;
}
private:
IRLayer &BaseLayer;
TransformFunction Transform;