Skip to content

Commit a02fca1

Browse files
committed
[ownership] Add a frontend option -disable-ossa-opts to disable ossa based opts for benchmarking purposes.
1 parent 631305f commit a02fca1

File tree

5 files changed

+15
-0
lines changed

5 files changed

+15
-0
lines changed

include/swift/AST/SILOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ class SILOptions {
5353
/// Controls whether the SIL ARC optimizations are run.
5454
bool EnableARCOptimizations = true;
5555

56+
/// Controls whether specific OSSA optimizations are run. For benchmarking
57+
/// purposes.
58+
bool EnableOSSAOptimizations = true;
59+
5660
/// Should we run any SIL performance optimizations
5761
///
5862
/// Useful when you want to enable -O LLVM opts but not -O SIL opts.

include/swift/Option/FrontendOptions.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ def debugger_support : Flag<["-"], "debugger-support">,
254254

255255
def disable_arc_opts : Flag<["-"], "disable-arc-opts">,
256256
HelpText<"Don't run SIL ARC optimization passes.">;
257+
def disable_ossa_opts : Flag<["-"], "disable-ossa-opts">,
258+
HelpText<"Don't run SIL OSSA optimization passes.">;
257259

258260
def disable_sil_partial_apply : Flag<["-"], "disable-sil-partial-apply">,
259261
HelpText<"Disable use of partial_apply in SIL generation">;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
844844
Opts.RemoveRuntimeAsserts |= Args.hasArg(OPT_RemoveRuntimeAsserts);
845845

846846
Opts.EnableARCOptimizations |= !Args.hasArg(OPT_disable_arc_opts);
847+
Opts.EnableOSSAOptimizations &= !Args.hasArg(OPT_disable_ossa_opts);
847848
Opts.DisableSILPerfOptimizations |= Args.hasArg(OPT_disable_sil_perf_optzns);
848849
Opts.VerifyAll |= Args.hasArg(OPT_sil_verify_all);
849850
Opts.DebugSerialization |= Args.hasArg(OPT_sil_debug_serialization);

lib/SILOptimizer/Mandatory/SemanticARCOpts.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,10 @@ struct SemanticARCOpts : SILFunctionTransform {
772772
void run() override {
773773
SILFunction &f = *getFunction();
774774

775+
// Return early if we are not performing OSSA optimizations.
776+
if (!f.getModule().getOptions().EnableOSSAOptimizations)
777+
return;
778+
775779
// Make sure we are running with ownership verification enabled.
776780
assert(f.getModule().getOptions().VerifySILOwnership &&
777781
"Can not perform semantic arc optimization unless ownership "

lib/SILOptimizer/Transforms/DestroyHoisting.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,10 @@ class DestroyHoistingPass : public SILFunctionTransform {
716716
if (!F->hasOwnership())
717717
return;
718718

719+
// If we are not supposed to perform ossa optimizations, bail.
720+
if (!F->getModule().getOptions().EnableOSSAOptimizations)
721+
return;
722+
719723
LLVM_DEBUG(llvm::dbgs() << "*** DestroyHoisting on function: "
720724
<< F->getName() << " ***\n");
721725

0 commit comments

Comments
 (0)