Skip to content

Commit bcefc0a

Browse files
committed
---
yaml --- r: 327518 b: refs/heads/tensorflow c: 859b37e h: refs/heads/master
1 parent 57247ca commit bcefc0a

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
@@ -816,7 +816,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
816816
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
817817
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
818818
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
819-
refs/heads/tensorflow: 01e65e18c445d31b09c064a6e94e3939631e9209
819+
refs/heads/tensorflow: 859b37e78207f601c77dffe70173212e153b6037
820820
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
821821
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
822822
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2

branches/tensorflow/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)