Skip to content

Commit e2d7f77

Browse files
committed
[semantic-sil] Enable the mandatory sil ownership optimization on all stdlib overlays.
We can do this b/c all overlays pass the ownership verifier, so it is safe.
1 parent 2594cd7 commit e2d7f77

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ function(_compile_swift_files
243243

244244
if(SWIFTFILE_IS_STDLIB)
245245
list(APPEND swift_flags "-Xfrontend" "-enable-sil-ownership")
246+
list(APPEND swift_flags "-Xfrontend" "-enable-mandatory-semantic-arc-opts")
246247
endif()
247248

248249
if(NOT SWIFT_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING AND SWIFTFILE_IS_STDLIB)

include/swift/Option/FrontendOptions.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ def enable_sil_ownership : Flag<["-"], "enable-sil-ownership">,
304304
def disable_guaranteed_normal_arguments : Flag<["-"], "disable-guaranteed-normal-arguments">,
305305
HelpText<"If set to true, all normal parameters (except to inits/setters) will be passed at +1">;
306306

307-
def disable_mandatory_semantic_arc_opts : Flag<["-"], "disable-mandatory-semantic-arc-opts">,
308-
HelpText<"Disable the mandatory semantic arc optimizer">;
307+
def enable_mandatory_semantic_arc_opts : Flag<["-"], "enable-mandatory-semantic-arc-opts">,
308+
HelpText<"Enable the mandatory semantic arc optimizer">;
309309

310310
def assume_parsing_unqualified_ownership_sil : Flag<["-"], "assume-parsing-unqualified-ownership-sil">,
311311
HelpText<"Assume unqualified SIL ownership when parsing SIL">;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
743743
Opts.AssumeUnqualifiedOwnershipWhenParsing
744744
|= Args.hasArg(OPT_assume_parsing_unqualified_ownership_sil);
745745
Opts.EnableMandatorySemanticARCOpts |=
746-
!Args.hasArg(OPT_disable_mandatory_semantic_arc_opts);
746+
Args.hasArg(OPT_enable_mandatory_semantic_arc_opts);
747747
Opts.EnableLargeLoadableTypes |= Args.hasArg(OPT_enable_large_loadable_types);
748748

749749
if (const Arg *A = Args.getLastArg(OPT_save_optimization_record_path))

lib/SILOptimizer/Mandatory/SemanticARCOpts.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ namespace {
180180
struct SemanticARCOpts : SILFunctionTransform {
181181
void run() override {
182182
SILFunction &f = *getFunction();
183-
// Do not run the semantic arc opts unless we are running on the
184-
// standard library. This is because this is the only module that
185-
// passes the ownership verifier.
186-
if (!f.getModule().isStdlibModule())
187-
return;
183+
184+
// Make sure we are running with ownership verification enabled.
185+
assert(f.getModule().getOptions().EnableSILOwnership &&
186+
"Can not perform semantic arc optimization unless ownership "
187+
"verification is enabled");
188188

189189
// Iterate over all of the arguments, performing small peephole
190190
// ARC optimizations.

0 commit comments

Comments
 (0)