[Bridging PCH] Move dependency-on-bridging-PCH to -emit-bc JobAction itself.

This commit is contained in:
Graydon Hoare
2017-06-30 15:13:41 -07:00
parent e4fbb381aa
commit d4ff4537b9
2 changed files with 29 additions and 15 deletions

View File

@@ -1329,6 +1329,27 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
OI.SelectedSanitizer);
}
static void
currentDependsOnPCHIfPresent(JobAction *PCH,
std::unique_ptr<Action> &Current,
ActionList &Actions) {
if (PCH) {
// FIXME: When we have a PCH job, it's officially owned by the Actions
// array; but it's also a secondary input to each of the current
// JobActions, which means that we need to flip the "owns inputs" bit
// on the JobActions so they don't try to free it. That in turn means
// we need to transfer ownership of all the JobActions' existing
// inputs to the Actions array, since the JobActions either own or
// don't own _all_ of their inputs. Ownership can't vary
// input-by-input.
auto *job = cast<JobAction>(Current.get());
auto inputs = job->getInputs();
Actions.append(inputs.begin(), inputs.end());
job->setOwnsInputs(false);
job->addInput(PCH);
}
}
void Driver::buildActions(const ToolChain &TC,
const DerivedArgList &Args,
const InputFileList &Inputs,
@@ -1393,6 +1414,7 @@ void Driver::buildActions(const ToolChain &TC,
Current.reset(new CompileJobAction(Current.release(),
types::TY_LLVM_BC,
previousBuildState));
currentDependsOnPCHIfPresent(PCH, Current, Actions);
AllModuleInputs.push_back(Current.get());
Current.reset(new BackendJobAction(Current.release(),
OI.CompilerOutputType, 0));
@@ -1400,23 +1422,9 @@ void Driver::buildActions(const ToolChain &TC,
Current.reset(new CompileJobAction(Current.release(),
OI.CompilerOutputType,
previousBuildState));
currentDependsOnPCHIfPresent(PCH, Current, Actions);
AllModuleInputs.push_back(Current.get());
}
if (PCH) {
// FIXME: When we have a PCH job, it's officially owned by the Actions
// array; but it's also a secondary input to each of the current
// JobActions, which means that we need to flip the "owns inputs" bit
// on the JobActions so they don't try to free it. That in turn means
// we need to transfer ownership of all the JobActions' existing
// inputs to the Actions array, since the JobActions either own or
// don't own _all_ of their inputs. Ownership can't vary
// input-by-input.
auto *job = cast<JobAction>(Current.get());
auto inputs = job->getInputs();
Actions.append(inputs.begin(), inputs.end());
job->setOwnsInputs(false);
job->addInput(PCH);
}
AllLinkerInputs.push_back(Current.release());
break;
}