Skip to content

Commit fe4c85d

Browse files
committed
NFC: static branch prediction SIL flag
1 parent 346bd23 commit fe4c85d

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

include/swift/AST/SILOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ class SILOptions {
118118
/// Controls whether to run async demotion pass.
119119
bool EnableAsyncDemotion = false;
120120

121+
/// Controls whether to enable static branch prediction heuristics.
122+
bool EnableStaticBranchPrediction = false;
123+
121124
/// Should we run any SIL performance optimizations
122125
///
123126
/// Useful when you want to enable -O LLVM opts but not -O SIL opts.

include/swift/Option/FrontendOptions.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ def enable_spec_devirt : Flag<["-"], "enable-spec-devirt">,
540540
def enable_async_demotion : Flag<["-"], "enable-experimental-async-demotion">,
541541
HelpText<"Enables an optimization pass to demote async functions.">;
542542

543+
def enable_static_branch_prediction : Flag<["-"], "enable-experimental-static-branch-prediction">,
544+
HelpText<"Enables heuristics that predict the likelihood of a branch being taken.">;
545+
543546
def disable_access_control : Flag<["-"], "disable-access-control">,
544547
HelpText<"Don't respect access control restrictions">;
545548
def enable_access_control : Flag<["-"], "enable-access-control">,

lib/DriverTool/sil_opt_main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ struct SILOptOptions {
289289
EnableAsyncDemotion = llvm::cl::opt<bool>("enable-async-demotion",
290290
llvm::cl::desc("Enables an optimization pass to demote async functions."));
291291

292+
llvm::cl::opt<bool>
293+
EnableStaticBranchPrediction = llvm::cl::opt<bool>("enable-static-branch-prediction",
294+
llvm::cl::desc("Enables heuristics that predict the likelihood of a branch being taken."));
295+
292296
llvm::cl::opt<bool>
293297
EnableMoveInoutStackProtection = llvm::cl::opt<bool>("enable-move-inout-stack-protector",
294298
llvm::cl::desc("Enable the stack protector by moving values to temporaries."));
@@ -847,6 +851,7 @@ int sil_opt_main(ArrayRef<const char *> argv, void *MainAddr) {
847851

848852
SILOpts.EnableSpeculativeDevirtualization = options.EnableSpeculativeDevirtualization;
849853
SILOpts.EnableAsyncDemotion = options.EnableAsyncDemotion;
854+
SILOpts.EnableStaticBranchPrediction = options.EnableStaticBranchPrediction;
850855
SILOpts.IgnoreAlwaysInline = options.IgnoreAlwaysInline;
851856
SILOpts.EnableOSSAModules = options.EnableOSSAModules;
852857
SILOpts.EnableSILOpaqueValues = options.EnableSILOpaqueValues;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2597,6 +2597,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
25972597
OPT_enable_sil_opaque_values, OPT_disable_sil_opaque_values, false);
25982598
Opts.EnableSpeculativeDevirtualization |= Args.hasArg(OPT_enable_spec_devirt);
25992599
Opts.EnableAsyncDemotion |= Args.hasArg(OPT_enable_async_demotion);
2600+
Opts.EnableStaticBranchPrediction |= Args.hasArg(OPT_enable_static_branch_prediction);
26002601
Opts.EnableActorDataRaceChecks |= Args.hasFlag(
26012602
OPT_enable_actor_data_race_checks,
26022603
OPT_disable_actor_data_race_checks, /*default=*/false);

0 commit comments

Comments
 (0)