Commit 5f55d405 by Jim Stichnoth

Subzero: Make -translate-only work with nonzero -threads=<N>.

When we skip translating an item due to the -translate-only option, we still need to add a dummy item to the work queue with the proper sequence number, otherwise the emitter thread waits endlessly for the next sequence number and never emits the rest of the items. BUG= none R=jpp@chromium.org Review URL: https://codereview.chromium.org/2099293002 .
parent 00b9edba
......@@ -362,6 +362,7 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, Ostream *OsError,
void GlobalContext::translateFunctions() {
TimerMarker Timer(TimerStack::TT_translateFunctions, this);
while (std::unique_ptr<OptWorkItem> OptItem = optQueueBlockingPop()) {
std::unique_ptr<EmitterWorkItem> Item;
auto Func = OptItem->getParsedCfg();
// Install Func in TLS for Cfg-specific container allocators.
CfgLocalAllocatorScope _(Func.get());
......@@ -379,11 +380,14 @@ void GlobalContext::translateFunctions() {
!getFlags().matchTranslateOnly(Func->getFunctionName(),
Func->getSequenceNumber())) {
Func->dump();
// Add a dummy work item as a placeholder. This maintains sequence
// numbers so that the emitter thread will emit subsequent functions.
Item = makeUnique<EmitterWorkItem>(Func->getSequenceNumber());
emitQueueBlockingPush(std::move(Item));
continue; // Func goes out of scope and gets deleted
}
Func->translate();
std::unique_ptr<EmitterWorkItem> Item;
if (Func->hasError()) {
getErrorStatus()->assign(EC_Translation);
OstreamLocker L(this);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment