Skip to content

Commit 84f9ba3

Browse files
committed
Use ModuleInputs instead of a Vector to build MergeModules
1 parent d29dcf8 commit 84f9ba3

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

lib/Driver/Compilation.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,12 @@ namespace driver {
11631163
continue;
11641164
}
11651165

1166-
// Can we run a cross-module incremental build at all? If not, fallback.
1166+
// Is this module out of date? If not, just keep searching.
1167+
if (Comp.getLastBuildTime() >= depStatus.getLastModificationTime())
1168+
continue;
1169+
1170+
// Can we run a cross-module incremental build at all?
1171+
// If not, fall back.
11671172
if (!Comp.getEnableCrossModuleIncrementalBuild()) {
11681173
fallbackToExternalBehavior(external);
11691174
continue;

lib/Driver/Driver.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
19361936
return;
19371937
}
19381938

1939-
SmallVector<const Action *, 2> AllModuleInputs;
1939+
ModuleInputs AllModuleInputs;
19401940
SmallVector<const Action *, 2> AllLinkerInputs;
19411941

19421942
switch (OI.CompilerMode) {
@@ -1977,18 +1977,16 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
19771977
// Source inputs always need to be compiled.
19781978
assert(file_types::isPartOfSwiftCompilation(InputType));
19791979

1980-
CompileJobAction::InputInfo previousBuildState = {
1981-
CompileJobAction::InputInfo::NeedsCascadingBuild,
1982-
llvm::sys::TimePoint<>::min()
1983-
};
1980+
auto previousBuildState =
1981+
IncrementalJobAction::InputInfo::makeNeedsCascadingRebuild();
19841982
if (OutOfDateMap)
19851983
previousBuildState = OutOfDateMap->lookup(InputArg);
19861984
if (Args.hasArg(options::OPT_embed_bitcode)) {
19871985
Current = C.createAction<CompileJobAction>(
19881986
Current, file_types::TY_LLVM_BC, previousBuildState);
19891987
if (PCH)
19901988
cast<JobAction>(Current)->addInput(PCH);
1991-
AllModuleInputs.push_back(Current);
1989+
AllModuleInputs.addInput(Current);
19921990
Current = C.createAction<BackendJobAction>(Current,
19931991
OI.CompilerOutputType, 0);
19941992
} else {
@@ -1997,7 +1995,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
19971995
previousBuildState);
19981996
if (PCH)
19991997
cast<JobAction>(Current)->addInput(PCH);
2000-
AllModuleInputs.push_back(Current);
1998+
AllModuleInputs.addInput(Current);
20011999
}
20022000
AllLinkerInputs.push_back(Current);
20032001
break;
@@ -2009,7 +2007,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
20092007
// When generating a .swiftmodule as a top-level output (as opposed
20102008
// to, for example, linking an image), treat .swiftmodule files as
20112009
// inputs to a MergeModule action.
2012-
AllModuleInputs.push_back(Current);
2010+
AllModuleInputs.addInput(Current);
20132011
break;
20142012
} else if (OI.shouldLink()) {
20152013
// Otherwise, if linking, pass .swiftmodule files as inputs to the
@@ -2091,7 +2089,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
20912089
// Create a single CompileJobAction and a single BackendJobAction.
20922090
JobAction *CA =
20932091
C.createAction<CompileJobAction>(file_types::TY_LLVM_BC);
2094-
AllModuleInputs.push_back(CA);
2092+
AllModuleInputs.addInput(CA);
20952093

20962094
int InputIndex = 0;
20972095
for (const InputPair &Input : Inputs) {
@@ -2127,7 +2125,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
21272125

21282126
CA->addInput(C.createAction<InputAction>(*InputArg, InputType));
21292127
}
2130-
AllModuleInputs.push_back(CA);
2128+
AllModuleInputs.addInput(CA);
21312129
AllLinkerInputs.push_back(CA);
21322130
break;
21332131
}
@@ -2176,7 +2174,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
21762174
!AllModuleInputs.empty()) {
21772175
// We're performing multiple compilations; set up a merge module step
21782176
// so we generate a single swiftmodule as output.
2179-
MergeModuleAction = C.createAction<MergeModuleJobAction>(AllModuleInputs);
2177+
MergeModuleAction = std::move(AllModuleInputs).intoAction(C);
21802178
}
21812179

21822180
bool shouldPerformLTO = OI.LTOVariant != OutputInfo::LTOKind::None;

0 commit comments

Comments
 (0)