Fix race condition in buildCFG

Summary:
switch to sequential execution when print-all is passed.
Since the function getDynoStats have an unsafe access
to the annotation allocators.

(cherry picked from FBD16503502)
This commit is contained in:
laith sakka 2019-07-25 14:41:57 -07:00 committed by Maksim Panchenko
parent 6443c46b9d
commit 1bce256e67
1 changed files with 2 additions and 5 deletions

View File

@ -2781,11 +2781,8 @@ void RewriteInstance::disassembleFunctions() {
if (!BF.buildCFG(AllocId))
return;
if (opts::PrintAll) {
static std::mutex CriticalSectionMutex;
std::lock_guard<std::mutex> Lock(CriticalSectionMutex);
if (opts::PrintAll)
BF.print(outs(), "while building cfg", true);
}
};
ParallelUtilities::PredicateTy SkipPredicate =
@ -2796,7 +2793,7 @@ void RewriteInstance::disassembleFunctions() {
ParallelUtilities::runOnEachFunctionWithUniqueAllocId(
*BC, ParallelUtilities::SchedulingPolicy::SP_INST_LINEAR, WorkFun,
SkipPredicate, "disassembleFunctions-buildCFG",
/*ForceSequential*/ opts::SequentialDisassembly);
/*ForceSequential*/ opts::SequentialDisassembly || opts::PrintAll);
}
BC->postProcessSymbolTable();