Add a field to SILOption to represent the current optimization level.

The value is set based on the -O command-line option. It is generally useful if SIL optimization passes can check the current optimization level.
A couple of subsequent commits are going to make use of this information.

Swift SVN r29653
This commit is contained in:
Roman Levenstein
2015-06-25 02:38:02 +00:00
parent cb85eac07e
commit 251bda4959
2 changed files with 16 additions and 0 deletions

View File

@@ -881,18 +881,22 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
if (const Arg *A = Args.getLastArg(OPT_O_Group)) {
if (A->getOption().matches(OPT_Onone)) {
IRGenOpts.Optimize = false;
Opts.Optimization = SILOptions::SILOptMode::None;
} else if (A->getOption().matches(OPT_Ounchecked)) {
// Turn on optimizations and remove all runtime checks.
IRGenOpts.Optimize = true;
Opts.Optimization = SILOptions::SILOptMode::OptimizeUnchecked;
// Removal of cond_fail (overflow on binary operations).
Opts.RemoveRuntimeAsserts = true;
Opts.AssertConfig = SILOptions::Fast;
} else if (A->getOption().matches(OPT_Oplayground)) {
// For now -Oplayground is equivalent to -Onone.
IRGenOpts.Optimize = false;
Opts.Optimization = SILOptions::SILOptMode::None;
} else {
assert(A->getOption().matches(OPT_O));
IRGenOpts.Optimize = true;
Opts.Optimization = SILOptions::SILOptMode::Optimize;
}
}