mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Separated out the Onone module handling from stdlib handling
Also refactored the Onone module predicate. I believe there is no functional change, but I don't understand the correctness of what was there.
This commit is contained in:
@@ -449,7 +449,7 @@ public:
|
|||||||
void freeContextAndSIL();
|
void freeContextAndSIL();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool loadStdlibAndMaybeSwiftOnoneSupport();
|
bool loadStdlib();
|
||||||
ModuleDecl *importUnderlyingModule();
|
ModuleDecl *importUnderlyingModule();
|
||||||
ModuleDecl *importBridgingHeader();
|
ModuleDecl *importBridgingHeader();
|
||||||
|
|
||||||
|
|||||||
@@ -195,6 +195,15 @@ public:
|
|||||||
EmitObject, ///< Emit object file
|
EmitObject, ///< Emit object file
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool isCreatingSIL() { return RequestedAction >= EmitSILGen; }
|
||||||
|
bool shouldImportSwiftOnoneModuleIfNoneOrImplicitOptimization() {
|
||||||
|
return
|
||||||
|
RequestedAction == EmitObject ||
|
||||||
|
RequestedAction == Immediate ||
|
||||||
|
RequestedAction == EmitSIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Indicates the action the user requested that the frontend perform.
|
/// Indicates the action the user requested that the frontend perform.
|
||||||
ActionType RequestedAction = NoneAction;
|
ActionType RequestedAction = NoneAction;
|
||||||
|
|
||||||
|
|||||||
@@ -294,15 +294,15 @@ addAdditionalInitialImportsTo(SourceFile *SF, CompilerInstance::ImplicitImports
|
|||||||
/// builds. This allows for use of popular specialized functions
|
/// builds. This allows for use of popular specialized functions
|
||||||
/// from the standard library, which makes the non-optimized builds
|
/// from the standard library, which makes the non-optimized builds
|
||||||
/// execute much faster.
|
/// execute much faster.
|
||||||
static bool shouldImplicityImportSwiftOnoneSupportModule(
|
static bool shouldImplicityImportSwiftOnoneSupportModule(CompilerInvocation &Invocation) {
|
||||||
SILOptions::SILOptMode optimization,
|
if (Invocation.getImplicitModuleImportKind() != SourceFile::ImplicitModuleImportKind::Stdlib)
|
||||||
FrontendOptions::ActionType requestedAction) {
|
return false;
|
||||||
return ((optimization <= SILOptions::SILOptMode::None &&
|
SILOptions::SILOptMode optimization = Invocation.getSILOptions().Optimization;
|
||||||
(requestedAction == FrontendOptions::EmitObject ||
|
if (optimization <= SILOptions::SILOptMode::None &&
|
||||||
requestedAction == FrontendOptions::Immediate ||
|
Invocation.getFrontendOptions().shouldImportSwiftOnoneModuleIfNoneOrImplicitOptimization()) {
|
||||||
requestedAction == FrontendOptions::EmitSIL)) ||
|
return true;
|
||||||
(optimization == SILOptions::SILOptMode::None &&
|
}
|
||||||
requestedAction >= FrontendOptions::EmitSILGen));
|
return optimization == SILOptions::SILOptMode::None && Invocation.getFrontendOptions().isCreatingSIL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilerInstance::performSema() {
|
void CompilerInstance::performSema() {
|
||||||
@@ -316,9 +316,12 @@ void CompilerInstance::performSema() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Invocation.getImplicitModuleImportKind() == SourceFile::ImplicitModuleImportKind::Stdlib) {
|
if (Invocation.getImplicitModuleImportKind() == SourceFile::ImplicitModuleImportKind::Stdlib) {
|
||||||
if (!loadStdlibAndMaybeSwiftOnoneSupport())
|
if (!loadStdlib())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (shouldImplicityImportSwiftOnoneSupportModule(Invocation)) {
|
||||||
|
Invocation.getFrontendOptions().ImplicitImportModuleNames.push_back(SWIFT_ONONE_SUPPORT);
|
||||||
|
}
|
||||||
|
|
||||||
ImplicitImports implicitImports(*this);
|
ImplicitImports implicitImports(*this);
|
||||||
|
|
||||||
@@ -359,8 +362,8 @@ CompilerInstance::ImplicitImports::ImplicitImports(CompilerInstance &compiler) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return true if should continue, i.e. no error
|
// Return true if should continue, i.e. no error
|
||||||
bool CompilerInstance::loadStdlibAndMaybeSwiftOnoneSupport() {
|
bool CompilerInstance::loadStdlib() {
|
||||||
SharedTimer timer("performSema-loadStdlibAndMaybeSwiftOnoneSupport");
|
SharedTimer timer("performSema-loadStdlib");
|
||||||
ModuleDecl *M = Context->getStdlibModule(true);
|
ModuleDecl *M = Context->getStdlibModule(true);
|
||||||
|
|
||||||
if (!M) {
|
if (!M) {
|
||||||
@@ -375,12 +378,6 @@ bool CompilerInstance::loadStdlibAndMaybeSwiftOnoneSupport() {
|
|||||||
"Module failed to load but nothing was diagnosed?");
|
"Module failed to load but nothing was diagnosed?");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (shouldImplicityImportSwiftOnoneSupportModule(
|
|
||||||
Invocation.getSILOptions().Optimization,
|
|
||||||
Invocation.getFrontendOptions().RequestedAction)) {
|
|
||||||
Invocation.getFrontendOptions().ImplicitImportModuleNames.push_back(
|
|
||||||
SWIFT_ONONE_SUPPORT);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user