[ORC] Set setCloneToNewContextOnEmit on LLJIT's transform layer when needed.

Based on Don Hinton's patch in https://reviews.llvm.org/D72406. This feature
was accidentally left out of e9e26c01cd, and
would have pessimized concurrent compilation in the default case.

Thanks for spotting this Don!
This commit is contained in:
Lang Hames 2020-01-15 10:20:10 -08:00
parent 2e39ea726e
commit c75180258e
1 changed files with 2 additions and 3 deletions

View File

@ -150,10 +150,11 @@ LLJIT::LLJIT(LLJITBuilderState &S, Error &Err)
}
CompileLayer = std::make_unique<IRCompileLayer>(
*ES, ObjTransformLayer, std::move(*CompileFunction));
TransformLayer = std::make_unique<IRTransformLayer>(*ES, *CompileLayer);
}
if (S.NumCompileThreads > 0) {
CompileLayer->setCloneToNewContextOnEmit(true);
TransformLayer->setCloneToNewContextOnEmit(true);
CompileThreads = std::make_unique<ThreadPool>(S.NumCompileThreads);
ES->setDispatchMaterialization(
[this](JITDylib &JD, std::unique_ptr<MaterializationUnit> MU) {
@ -163,8 +164,6 @@ LLJIT::LLJIT(LLJITBuilderState &S, Error &Err)
CompileThreads->async(std::move(Work));
});
}
TransformLayer = std::make_unique<IRTransformLayer>(*ES, *CompileLayer);
}
std::string LLJIT::mangle(StringRef UnmangledName) {