@@ -296,6 +296,18 @@ static llvm::cl::opt<OptimizationMode> OptModeFlag(
296
296
" ignore debug info, reduce runtime" )),
297
297
llvm::cl::init(OptimizationMode::NotSet));
298
298
299
+ static llvm::cl::opt<IRGenDebugInfoLevel> IRGenDebugInfoLevelArg (
300
+ " irgen-debuginfo-level" , llvm::cl::desc(" IRGen debug info level" ),
301
+ llvm::cl::values(clEnumValN(IRGenDebugInfoLevel::None, " none" ,
302
+ " No debug info" ),
303
+ clEnumValN(IRGenDebugInfoLevel::LineTables, " line-tables" ,
304
+ " Line tables only" ),
305
+ clEnumValN(IRGenDebugInfoLevel::ASTTypes, " ast-types" ,
306
+ " Line tables + AST type references" ),
307
+ clEnumValN(IRGenDebugInfoLevel::DwarfTypes, " dwarf-types" ,
308
+ " Line tables + AST type refs + Dwarf types" )),
309
+ llvm::cl::init(IRGenDebugInfoLevel::ASTTypes));
310
+
299
311
static llvm::cl::opt<OptGroup> OptimizationGroup (
300
312
llvm::cl::desc (" Predefined optimization groups:" ),
301
313
llvm::cl::values(
@@ -675,8 +687,19 @@ int main(int argc, char **argv) {
675
687
SILOpts.OptMode = OptModeFlag;
676
688
}
677
689
678
- // Note: SILOpts must be set before the CompilerInstance is initializer below
679
- // based on Invocation.
690
+ auto &IRGenOpts = Invocation.getIRGenOptions ();
691
+ if (OptModeFlag == OptimizationMode::NotSet) {
692
+ if (OptimizationGroup == OptGroup::Diagnostics)
693
+ IRGenOpts.OptMode = OptimizationMode::NoOptimization;
694
+ else
695
+ IRGenOpts.OptMode = OptimizationMode::ForSpeed;
696
+ } else {
697
+ IRGenOpts.OptMode = OptModeFlag;
698
+ }
699
+ IRGenOpts.DebugInfoLevel = IRGenDebugInfoLevelArg;
700
+
701
+ // Note: SILOpts, LangOpts, and IRGenOpts must be set before the
702
+ // CompilerInstance is initializer below based on Invocation.
680
703
681
704
serialization::ExtendedValidationInfo extendedInfo;
682
705
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
@@ -774,7 +797,8 @@ int main(int argc, char **argv) {
774
797
case OptGroup::Unknown: {
775
798
auto T = irgen::createIRGenModule (
776
799
SILMod.get (), Invocation.getOutputFilenameForAtMostOnePrimary (),
777
- Invocation.getMainInputFilenameForDebugInfoForAtMostOnePrimary (), " " );
800
+ Invocation.getMainInputFilenameForDebugInfoForAtMostOnePrimary (), " " ,
801
+ IRGenOpts);
778
802
runCommandLineSelectedPasses (SILMod.get (), T.second );
779
803
irgen::deleteIRGenModule (T);
780
804
break ;
0 commit comments