Skip to content

Commit 86d4ba1

Browse files
committed
[sil-opt] Set the opt level on the IRGenOptions used so it matches the one we set on SILOpt.
1 parent 781a90c commit 86d4ba1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tools/sil-opt/SILOpt.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,18 @@ int main(int argc, char **argv) {
675675
SILOpts.OptMode = OptModeFlag;
676676
}
677677

678-
// Note: SILOpts must be set before the CompilerInstance is initializer below
679-
// based on Invocation.
678+
auto &IRGenOpts = Invocation.getIRGenOptions();
679+
if (OptModeFlag == OptimizationMode::NotSet) {
680+
if (OptimizationGroup == OptGroup::Diagnostics)
681+
IRGenOpts.OptMode = OptimizationMode::NoOptimization;
682+
else
683+
IRGenOpts.OptMode = OptimizationMode::ForSpeed;
684+
} else {
685+
IRGenOpts.OptMode = OptModeFlag;
686+
}
687+
688+
// Note: SILOpts, LangOpts, and IRGenOpts must be set before the
689+
// CompilerInstance is initializer below based on Invocation.
680690

681691
serialization::ExtendedValidationInfo extendedInfo;
682692
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =

0 commit comments

Comments
 (0)