Skip to content

Commit f19befd

Browse files
committed
---
yaml --- r: 343645 b: refs/heads/master-rebranch c: 859b37e h: refs/heads/master i: 343643: 87b7597
1 parent 5919112 commit f19befd

File tree

2 files changed

+47
-52
lines changed

2 files changed

+47
-52
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14551455
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14561456
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14571457
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1458-
refs/heads/master-rebranch: 01e65e18c445d31b09c064a6e94e3939631e9209
1458+
refs/heads/master-rebranch: 859b37e78207f601c77dffe70173212e153b6037
14591459
refs/heads/rdar-53901732: 9bd06af3284e18a109cdbf9aa59d833b24eeca7b
14601460
refs/heads/revert-26776-subst-always-returns-a-type: 1b8e18fdd391903a348970a4c848995d4cdd789c
14611461
refs/heads/tensorflow-merge: 8b854f62f80d4476cb383d43c4aac2001dde3cec

branches/master-rebranch/lib/FrontendTool/FrontendTool.cpp

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
#include "llvm/Support/YAMLTraits.h"
8383
#include "llvm/Target/TargetMachine.h"
8484

85-
#include <deque>
8685
#include <memory>
8786
#include <unordered_set>
8887
#include <utility>
@@ -648,13 +647,6 @@ createOptRecordFile(StringRef Filename, DiagnosticEngine &DE) {
648647
return File;
649648
}
650649

651-
struct PostSILGenInputs {
652-
std::unique_ptr<SILModule> TheSILModule;
653-
bool ASTGuaranteedToCorrespondToSIL;
654-
ModuleOrSourceFile ModuleOrPrimarySourceFile;
655-
PrimarySpecificPaths PSPs;
656-
};
657-
658650
static bool precompileBridgingHeader(CompilerInvocation &Invocation,
659651
CompilerInstance &Instance) {
660652
auto clangImporter = static_cast<ClangImporter *>(
@@ -896,15 +888,27 @@ static bool writeTBDIfNeeded(CompilerInvocation &Invocation,
896888
return writeTBD(Instance.getMainModule(), TBDPath, tbdOpts);
897889
}
898890

899-
static std::deque<PostSILGenInputs>
900-
generateSILModules(CompilerInvocation &Invocation, CompilerInstance &Instance) {
891+
static bool performCompileStepsPostSILGen(
892+
CompilerInstance &Instance, CompilerInvocation &Invocation,
893+
std::unique_ptr<SILModule> SM, bool astGuaranteedToCorrespondToSIL,
894+
ModuleOrSourceFile MSF, const PrimarySpecificPaths &PSPs,
895+
bool moduleIsPublic, int &ReturnValue, FrontendObserver *observer,
896+
UnifiedStatsReporter *Stats);
897+
898+
static bool
899+
performCompileStepsPostSema(CompilerInvocation &Invocation,
900+
CompilerInstance &Instance,
901+
bool moduleIsPublic, int &ReturnValue,
902+
FrontendObserver *observer,
903+
UnifiedStatsReporter *Stats) {
901904
auto mod = Instance.getMainModule();
902905
if (auto SM = Instance.takeSILModule()) {
903-
std::deque<PostSILGenInputs> PSGIs;
904906
const PrimarySpecificPaths PSPs =
905907
Instance.getPrimarySpecificPathsForAtMostOnePrimary();
906-
PSGIs.push_back(PostSILGenInputs{std::move(SM), false, mod, PSPs});
907-
return PSGIs;
908+
return performCompileStepsPostSILGen(Instance, Invocation, std::move(SM),
909+
/*ASTGuaranteedToCorrespondToSIL=*/false,
910+
mod, PSPs, moduleIsPublic,
911+
ReturnValue, observer, Stats);
908912
}
909913

910914
SILOptions &SILOpts = Invocation.getSILOptions();
@@ -918,40 +922,51 @@ generateSILModules(CompilerInvocation &Invocation, CompilerInstance &Instance) {
918922
// If there are no primary inputs the compiler is in WMO mode and builds one
919923
// SILModule for the entire module.
920924
auto SM = performSILGeneration(mod, Instance.getSILTypes(), SILOpts);
921-
std::deque<PostSILGenInputs> PSGIs;
922925
const PrimarySpecificPaths PSPs =
923926
Instance.getPrimarySpecificPathsForWholeModuleOptimizationMode();
924-
PSGIs.push_back(PostSILGenInputs{
925-
std::move(SM), llvm::none_of(mod->getFiles(), fileIsSIB), mod, PSPs});
926-
return PSGIs;
927+
bool astGuaranteedToCorrespondToSIL =
928+
llvm::none_of(mod->getFiles(), fileIsSIB);
929+
return performCompileStepsPostSILGen(Instance, Invocation, std::move(SM),
930+
astGuaranteedToCorrespondToSIL,
931+
mod, PSPs, moduleIsPublic,
932+
ReturnValue, observer, Stats);
927933
}
928934
// If there are primary source files, build a separate SILModule for
929935
// each source file, and run the remaining SILOpt-Serialize-IRGen-LLVM
930936
// once for each such input.
931-
std::deque<PostSILGenInputs> PSGIs;
932-
for (auto *PrimaryFile : Instance.getPrimarySourceFiles()) {
933-
auto SM = performSILGeneration(*PrimaryFile, Instance.getSILTypes(), SILOpts);
934-
const PrimarySpecificPaths PSPs =
935-
Instance.getPrimarySpecificPathsForSourceFile(*PrimaryFile);
936-
PSGIs.push_back(PostSILGenInputs{std::move(SM), true, PrimaryFile, PSPs});
937+
if (!Instance.getPrimarySourceFiles().empty()) {
938+
bool result = false;
939+
for (auto *PrimaryFile : Instance.getPrimarySourceFiles()) {
940+
auto SM = performSILGeneration(*PrimaryFile, Instance.getSILTypes(), SILOpts);
941+
const PrimarySpecificPaths PSPs =
942+
Instance.getPrimarySpecificPathsForSourceFile(*PrimaryFile);
943+
result |= performCompileStepsPostSILGen(Instance, Invocation, std::move(SM),
944+
/*ASTGuaranteedToCorrespondToSIL*/true,
945+
PrimaryFile, PSPs, moduleIsPublic,
946+
ReturnValue, observer, Stats);
947+
}
948+
949+
return result;
937950
}
938-
if (!PSGIs.empty())
939-
return PSGIs;
951+
940952
// If there are primary inputs but no primary _source files_, there might be
941953
// a primary serialized input.
954+
bool result = false;
942955
for (FileUnit *fileUnit : mod->getFiles()) {
943956
if (auto SASTF = dyn_cast<SerializedASTFile>(fileUnit))
944957
if (Invocation.getFrontendOptions().InputsAndOutputs.isInputPrimary(
945958
SASTF->getFilename())) {
946-
assert(PSGIs.empty() && "Can only handle one primary AST input");
947959
auto SM = performSILGeneration(*SASTF, Instance.getSILTypes(), SILOpts);
948960
const PrimarySpecificPaths &PSPs =
949961
Instance.getPrimarySpecificPathsForPrimary(SASTF->getFilename());
950-
PSGIs.push_back(
951-
PostSILGenInputs{std::move(SM), !fileIsSIB(SASTF), mod, PSPs});
962+
result |= performCompileStepsPostSILGen(Instance, Invocation, std::move(SM),
963+
!fileIsSIB(SASTF),
964+
mod, PSPs, moduleIsPublic,
965+
ReturnValue, observer, Stats);
952966
}
953967
}
954-
return PSGIs;
968+
969+
return result;
955970
}
956971

957972
/// Emits index data for all primary inputs, or the main module.
@@ -1002,13 +1017,6 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
10021017
return hadAnyError;
10031018
}
10041019

1005-
static bool performCompileStepsPostSILGen(
1006-
CompilerInstance &Instance, CompilerInvocation &Invocation,
1007-
std::unique_ptr<SILModule> SM, bool astGuaranteedToCorrespondToSIL,
1008-
ModuleOrSourceFile MSF, const PrimarySpecificPaths &PSPs,
1009-
bool moduleIsPublic, int &ReturnValue, FrontendObserver *observer,
1010-
UnifiedStatsReporter *Stats);
1011-
10121020
/// Performs the compile requested by the user.
10131021
/// \param Instance Will be reset after performIRGeneration when the verifier
10141022
/// mode is NoVerify and there were no errors.
@@ -1125,21 +1133,8 @@ static bool performCompile(CompilerInstance &Instance,
11251133
assert(FrontendOptions::doesActionGenerateSIL(Action) &&
11261134
"All actions not requiring SILGen must have been handled!");
11271135

1128-
std::deque<PostSILGenInputs> PSGIs = generateSILModules(Invocation, Instance);
1129-
1130-
while (!PSGIs.empty()) {
1131-
auto PSGI = std::move(PSGIs.front());
1132-
PSGIs.pop_front();
1133-
if (performCompileStepsPostSILGen(Instance, Invocation,
1134-
std::move(PSGI.TheSILModule),
1135-
PSGI.ASTGuaranteedToCorrespondToSIL,
1136-
PSGI.ModuleOrPrimarySourceFile,
1137-
PSGI.PSPs,
1138-
moduleIsPublic,
1139-
ReturnValue, observer, Stats))
1140-
return true;
1141-
}
1142-
return false;
1136+
return performCompileStepsPostSema(Invocation, Instance, moduleIsPublic,
1137+
ReturnValue, observer, Stats);
11431138
}
11441139

11451140
/// Get the main source file's private discriminator and attach it to

0 commit comments

Comments
 (0)