mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -42,6 +42,15 @@ public:
|
||||
LinkAll
|
||||
};
|
||||
|
||||
/// Representation of optimization modes.
|
||||
enum class SILOptMode: unsigned {
|
||||
NotSet,
|
||||
None,
|
||||
Debug,
|
||||
Optimize,
|
||||
OptimizeUnchecked
|
||||
};
|
||||
|
||||
/// Controls how perform SIL linking.
|
||||
LinkingMode LinkMode = LinkNormal;
|
||||
|
||||
@@ -57,6 +66,9 @@ public:
|
||||
/// Are we debugging sil serialization.
|
||||
bool DebugSerialization = false;
|
||||
|
||||
/// Optimization mode being used.
|
||||
SILOptMode Optimization = SILOptMode::NotSet;
|
||||
|
||||
enum AssertConfiguration: unsigned {
|
||||
// Used by standard library code to distinguish between a debug and release
|
||||
// build.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user