Unify the implementation of optimization mode in various option classes.

This commit is mostly refactoring.

*) Introduce a new OptimizationMode enum and use that in SILOptions and IRGenOptions
*) Allow the optimization mode also be specified for specific SILFunctions. This is not used in this commit yet and thus still a NFC.

Also, fixes a minor bug: we didn’t run mandatory IRGen passes for functions with @_semantics("optimize.sil.never")
This commit is contained in:
Erik Eckstein
2017-11-06 16:06:11 -08:00
parent d1f6107bbc
commit 90c21be191
35 changed files with 203 additions and 135 deletions

View File

@@ -513,8 +513,7 @@ SILFunction *SILModule::findFunction(StringRef Name, SILLinkage Linkage) {
// compilation, simply convert it into an external declaration,
// so that a compiled version from the shared library is used.
if (F->isDefinition() &&
F->getModule().getOptions().Optimization <
SILOptions::SILOptMode::Optimize) {
!F->getModule().getOptions().shouldOptimize()) {
F->convertToDeclaration();
}
if (F->isExternalDeclaration())
@@ -769,8 +768,7 @@ bool SILModule::isOnoneSupportModule() const {
/// Returns true if it is the optimized OnoneSupport module.
bool SILModule::isOptimizedOnoneSupportModule() const {
return getOptions().Optimization >= SILOptions::SILOptMode::Optimize &&
isOnoneSupportModule();
return getOptions().shouldOptimize() && isOnoneSupportModule();
}
void SILModule::setSerializeSILAction(SILModule::ActionCallback Action) {