Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit a8a2dc9

Browse files
author
Jan Voung
committed
Always use a FunctionPassManager in pnacl-llc. MPPassManager breaks threading.
Otherwise every thread will translate every function and we end up with duplicates. I.e., we cannot leave out -streaming-bitcode and translate with more than one thread (which is the default in pnacl-translate). The -streaming-bitcode flag still affects how the bitcode is read in however (everything materialized at once or lazily), so "createPNaClABIVerifyModulePass(&ABIErrorReporter, LazyBitcode)" is left alone. Ultimately, this is to help make it easy to temporarily leave off "-streaming-bitcode" until we find the source of non-determinism. Switching to FunctionPassManager does not affect the non-determinism either way (so the problem may be in the materialization or something else instead): BUG= https://code.google.com/p/nativeclient/issues/detail?id=4101 BUG= https://code.google.com/p/chromium/issues/detail?id=429358 [email protected] Review URL: https://codereview.chromium.org/1121433002
1 parent bc6d8c6 commit a8a2dc9

File tree

1 file changed

+43
-50
lines changed

1 file changed

+43
-50
lines changed

tools/pnacl-llc/pnacl-llc.cpp

Lines changed: 43 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,9 @@ static int runCompilePasses(Module *ModuleRef,
428428
}
429429

430430
// Build up all of the passes that we want to do to the module.
431-
std::unique_ptr<PassManagerBase> PM;
432-
if (LazyBitcode)
433-
PM.reset(new FunctionPassManager(ModuleRef));
434-
else
435-
PM.reset(new PassManager());
431+
// We always use a FunctionPassManager to divide up the functions
432+
// among threads (instead of a whole-module PassManager).
433+
std::unique_ptr<FunctionPassManager> PM(new FunctionPassManager(ModuleRef));
436434

437435
// Add the target data from the target machine, if it exists, or the module.
438436
if (const DataLayout *DL = Target.getSubtargetImpl()->getDataLayout())
@@ -475,59 +473,54 @@ static int runCompilePasses(Module *ModuleRef,
475473
return 1;
476474
}
477475

478-
if (LazyBitcode) {
479-
auto FPM = static_cast<FunctionPassManager *>(PM.get());
480-
FPM->doInitialization();
481-
unsigned FuncIndex = 0;
482-
switch (SplitModuleSched) {
483-
case SplitModuleStatic:
484-
for (Function &F : *ModuleRef) {
485-
if (FuncQueue->GrabFunctionStatic(FuncIndex, ModuleIndex)) {
486-
FPM->run(F);
487-
CheckABIVerifyErrors(ABIErrorReporter, "Function " + F.getName());
488-
F.Dematerialize();
489-
}
490-
++FuncIndex;
476+
PM->doInitialization();
477+
unsigned FuncIndex = 0;
478+
switch (SplitModuleSched) {
479+
case SplitModuleStatic:
480+
for (Function &F : *ModuleRef) {
481+
if (FuncQueue->GrabFunctionStatic(FuncIndex, ModuleIndex)) {
482+
PM->run(F);
483+
CheckABIVerifyErrors(ABIErrorReporter, "Function " + F.getName());
484+
F.Dematerialize();
491485
}
492-
break;
493-
case SplitModuleDynamic:
494-
unsigned ChunkSize = 0;
495-
unsigned NumFunctions = FuncQueue->Size();
496-
Module::iterator I = ModuleRef->begin();
497-
while (FuncIndex < NumFunctions) {
498-
ChunkSize = FuncQueue->RecommendedChunkSize();
499-
unsigned NextIndex;
500-
bool grabbed = FuncQueue->GrabFunctionDynamic(FuncIndex, ChunkSize,
501-
NextIndex);
502-
if (grabbed) {
503-
while (FuncIndex < NextIndex) {
504-
if (!I->isMaterializable() && I->isDeclaration()) {
505-
++I;
506-
continue;
507-
}
508-
FPM->run(*I);
509-
CheckABIVerifyErrors(ABIErrorReporter, "Function " + I->getName());
510-
I->Dematerialize();
511-
++FuncIndex;
486+
++FuncIndex;
487+
}
488+
break;
489+
case SplitModuleDynamic:
490+
unsigned ChunkSize = 0;
491+
unsigned NumFunctions = FuncQueue->Size();
492+
Module::iterator I = ModuleRef->begin();
493+
while (FuncIndex < NumFunctions) {
494+
ChunkSize = FuncQueue->RecommendedChunkSize();
495+
unsigned NextIndex;
496+
bool grabbed =
497+
FuncQueue->GrabFunctionDynamic(FuncIndex, ChunkSize, NextIndex);
498+
if (grabbed) {
499+
while (FuncIndex < NextIndex) {
500+
if (!I->isMaterializable() && I->isDeclaration()) {
512501
++I;
502+
continue;
513503
}
514-
} else {
515-
while (FuncIndex < NextIndex) {
516-
if (!I->isMaterializable() && I->isDeclaration()) {
517-
++I;
518-
continue;
519-
}
520-
++FuncIndex;
504+
PM->run(*I);
505+
CheckABIVerifyErrors(ABIErrorReporter, "Function " + I->getName());
506+
I->Dematerialize();
507+
++FuncIndex;
508+
++I;
509+
}
510+
} else {
511+
while (FuncIndex < NextIndex) {
512+
if (!I->isMaterializable() && I->isDeclaration()) {
521513
++I;
514+
continue;
522515
}
516+
++FuncIndex;
517+
++I;
523518
}
524519
}
525-
break;
526520
}
527-
FPM->doFinalization();
528-
} else
529-
static_cast<PassManager *>(PM.get())->run(*ModuleRef);
530-
521+
break;
522+
}
523+
PM->doFinalization();
531524
return 0;
532525
}
533526

0 commit comments

Comments
 (0)