Skip to content

Commit 74ec990

Browse files
committed
[move-only] When the move only experimental option is disabled do not run the move passes.
Just trying to prevent crashy behavior that can occur if a user tries to use move only without passing in the flag. rdar://102059799
1 parent 6df38a6 commit 74ec990

8 files changed

+21
-5
lines changed

lib/SILOptimizer/Mandatory/MoveKillsCopyableAddressesChecker.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,6 +2427,10 @@ class MoveKillsCopyableAddressesCheckerPass : public SILFunctionTransform {
24272427
auto *fn = getFunction();
24282428
auto &astContext = fn->getASTContext();
24292429

2430+
// Only run this pass if the move only language feature is enabled.
2431+
if (!astContext.LangOpts.Features.contains(Feature::MoveOnly))
2432+
return;
2433+
24302434
// Don't rerun diagnostics on deserialized functions.
24312435
if (getFunction()->wasDeserializedCanonical())
24322436
return;

lib/SILOptimizer/Mandatory/MoveKillsCopyableValuesChecker.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,12 @@ class MoveKillsCopyableValuesCheckerPass : public SILFunctionTransform {
524524
void run() override {
525525
auto *fn = getFunction();
526526

527+
// Only run this pass if the move only language feature is enabled.
528+
if (!fn->getASTContext().LangOpts.Features.contains(Feature::MoveOnly))
529+
return;
530+
527531
// Don't rerun diagnostics on deserialized functions.
528-
if (getFunction()->wasDeserializedCanonical())
532+
if (fn->wasDeserializedCanonical())
529533
return;
530534

531535
assert(fn->getModule().getStage() == SILStage::Raw &&

lib/SILOptimizer/Mandatory/MoveOnlyAddressChecker.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,10 @@ class MoveOnlyCheckerPass : public SILFunctionTransform {
17291729
void run() override {
17301730
auto *fn = getFunction();
17311731

1732+
// Only run this pass if the move only language feature is enabled.
1733+
if (!fn->getASTContext().LangOpts.Features.contains(Feature::MoveOnly))
1734+
return;
1735+
17321736
// Don't rerun diagnostics on deserialized functions.
17331737
if (getFunction()->wasDeserializedCanonical())
17341738
return;

lib/SILOptimizer/Mandatory/MoveOnlyObjectChecker.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,10 @@ class MoveOnlyCheckerPass : public SILFunctionTransform {
542542
void run() override {
543543
auto *fn = getFunction();
544544

545+
// Only run this pass if the move only language feature is enabled.
546+
if (!fn->getASTContext().LangOpts.Features.contains(Feature::MoveOnly))
547+
return;
548+
545549
// Don't rerun diagnostics on deserialized functions.
546550
if (getFunction()->wasDeserializedCanonical())
547551
return;

test/SILOptimizer/move_function_kills_addresses_dbginfo.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-sil-opt %s -sil-move-kills-copyable-addresses-checker | %FileCheck %s
1+
// RUN: %target-sil-opt %s -enable-experimental-move-only -sil-move-kills-copyable-addresses-checker | %FileCheck %s
22

33
// REQUIRES: optimized_stdlib
44

test/SILOptimizer/move_function_kills_copyable_addresses.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-sil-opt -enable-sil-verify-all -o - -sil-move-kills-copyable-addresses-checker -verify %s
1+
// RUN: %target-sil-opt -enable-experimental-move-only -enable-sil-verify-all -o - -sil-move-kills-copyable-addresses-checker -verify %s
22

33
// This file is meant for specific SIL patterns that may be hard to produce with
44
// the current swift frontend but have reproduced before and we want to make

test/SILOptimizer/move_function_kills_copyable_values.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-sil-opt -enable-sil-verify-all -o - -sil-move-kills-copyable-values-checker -verify %s
1+
// RUN: %target-sil-opt -enable-experimental-move-only -enable-sil-verify-all -o - -sil-move-kills-copyable-values-checker -verify %s
22

33
// This file is meant for specific SIL patterns that may be hard to produce with
44
// the current swift frontend but have reproduced before and we want to make

test/SILOptimizer/move_function_kills_values_dbginfo.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-sil-opt %s -sil-move-kills-copyable-values-checker | %FileCheck %s
1+
// RUN: %target-sil-opt %s -enable-experimental-move-only -sil-move-kills-copyable-values-checker | %FileCheck %s
22

33
// REQUIRES: optimized_stdlib
44

0 commit comments

Comments
 (0)