Skip to content

Commit 945ee92

Browse files
authored
Merge pull request #20302 from atrick/enforce-exclusivity
Enable run-time exclusivity checking in release mode.
2 parents 66563ed + a17dbc7 commit 945ee92

14 files changed

+17
-19
lines changed

cmake/modules/SwiftSource.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ function(_compile_swift_files
245245
list(APPEND swift_flags "-Xfrontend" "-enable-sil-ownership")
246246
endif()
247247

248-
if(SWIFT_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING AND SWIFTFILE_IS_STDLIB)
249-
list(APPEND swift_flags "-Xfrontend" "-enforce-exclusivity=checked")
248+
if(NOT SWIFT_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING AND SWIFTFILE_IS_STDLIB)
249+
list(APPEND swift_flags "-Xfrontend" "-enforce-exclusivity=unchecked")
250250
endif()
251251

252252
if(SWIFT_EMIT_SORTED_SIL_OUTPUT)

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,6 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
770770
Opts.VerifyExclusivity
771771
= A->getOption().matches(OPT_enable_verify_exclusivity);
772772
}
773-
if (Opts.shouldOptimize() && !Opts.VerifyExclusivity)
774-
Opts.EnforceExclusivityDynamic = false;
775773
if (const Arg *A = Args.getLastArg(options::OPT_enforce_exclusivity_EQ)) {
776774
parseExclusivityEnforcementOptions(A, Opts, Diags);
777775
}

test/IRGen/class_field_other_module.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %empty-directory(%t)
22

33
// RUN: %target-swift-frontend -emit-module -emit-module-path=%t/other_class.swiftmodule %S/Inputs/other_class.swift
4-
// RUN: %target-swift-frontend -I %t -emit-ir -O %s | %FileCheck %s -DINT=i%target-ptrsize
4+
// RUN: %target-swift-frontend -I %t -emit-ir -O -enforce-exclusivity=unchecked %s | %FileCheck %s -DINT=i%target-ptrsize
55

66
import other_class
77

test/SILOptimizer/array_contentof_opt.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -O -sil-verify-all -emit-sil %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -O -sil-verify-all -emit-sil -enforce-exclusivity=unchecked %s | %FileCheck %s
22
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
33

44
// This is an end-to-end test of the array(contentsOf) -> array(Element) optimization

test/SILOptimizer/bridged_casts_folding.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
// RUN: %target-swift-frontend -O -emit-sil %s | %FileCheck %s
2+
// RUN: %target-swift-frontend -O -emit-sil -enforce-exclusivity=unchecked %s | %FileCheck %s
33

44
// REQUIRES: objc_interop
55

test/SILOptimizer/generic_specialization_loops_detection_with_loops.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -O -emit-sil -Xllvm -sil-print-generic-specialization-loops -Xllvm -sil-print-generic-specialization-info %s 2>&1 | %FileCheck --check-prefix=CHECK %s
1+
// RUN: %target-swift-frontend -O -emit-sil -enforce-exclusivity=unchecked -Xllvm -sil-print-generic-specialization-loops -Xllvm -sil-print-generic-specialization-info %s 2>&1 | %FileCheck --check-prefix=CHECK %s
22

33
// Check that the generic specializer does not hang a compiler by
44
// creating and infinite loop of generic specializations.

test/SILOptimizer/globalopt_global_propagation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-swift-frontend -O -emit-sil %s | %FileCheck %s
2-
// RUN: %target-swift-frontend -O -wmo -emit-sil %s | %FileCheck -check-prefix=CHECK-WMO %s
1+
// RUN: %target-swift-frontend -O -emit-sil -enforce-exclusivity=unchecked %s | %FileCheck %s
2+
// RUN: %target-swift-frontend -O -wmo -emit-sil -enforce-exclusivity=unchecked %s | %FileCheck -check-prefix=CHECK-WMO %s
33

44
// Check that values of internal and private global variables, which are provably assigned only
55
// once, are propagated into their uses and enable further optimizations like constant

test/SILOptimizer/globalopt_let_propagation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -O -emit-sil -primary-file %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -O -emit-sil -enforce-exclusivity=unchecked -primary-file %s | %FileCheck %s
22

33
// Check that values of static let and global let variables are propagated into their uses
44
// and enable further optimizations like constant propagation, simplifications, etc.

test/SILOptimizer/illegal_escaping_address.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -O -sil-verify-all -emit-sil -parse-as-library %s
1+
// RUN: %target-swift-frontend -O -sil-verify-all -emit-sil -enforce-exclusivity=unchecked -parse-as-library %s
22

33
// Check that the compiler does not crash for illegal escaping of an address
44
// of a local variable.

test/SILOptimizer/let_propagation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -primary-file %s -emit-sil -O | %FileCheck %s
1+
// RUN: %target-swift-frontend -primary-file %s -emit-sil -enforce-exclusivity=unchecked -O | %FileCheck %s
22

33
// Check that LoadStoreOpts can handle "let" variables properly.
44
// Such variables should be loaded only once and their loaded values can be reused.

test/SILOptimizer/optionset.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-swift-frontend -parse-as-library -primary-file %s -O -sil-verify-all -module-name=test -emit-sil | %FileCheck %s
2-
// RUN: %target-swift-frontend -parse-as-library -primary-file %s -Osize -sil-verify-all -module-name=test -emit-sil | %FileCheck %s
1+
// RUN: %target-swift-frontend -parse-as-library -primary-file %s -O -sil-verify-all -module-name=test -emit-sil -enforce-exclusivity=unchecked | %FileCheck %s
2+
// RUN: %target-swift-frontend -parse-as-library -primary-file %s -Osize -sil-verify-all -module-name=test -emit-sil -enforce-exclusivity=unchecked | %FileCheck %s
33
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
44

55
public struct TestOptions: OptionSet {

test/SILOptimizer/outliner.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-swift-frontend -Osize -import-objc-header %S/Inputs/Outliner.h %s -emit-sil | %FileCheck %s
2-
// RUN: %target-swift-frontend -Osize -g -import-objc-header %S/Inputs/Outliner.h %s -emit-sil | %FileCheck %s
1+
// RUN: %target-swift-frontend -Osize -import-objc-header %S/Inputs/Outliner.h %s -emit-sil -enforce-exclusivity=unchecked | %FileCheck %s
2+
// RUN: %target-swift-frontend -Osize -g -import-objc-header %S/Inputs/Outliner.h %s -emit-sil -enforce-exclusivity=unchecked | %FileCheck %s
33

44
// REQUIRES: objc_interop
55

test/SILOptimizer/sil_combine_protocol_conf.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend %s -O -wmo -emit-sil -Xllvm -sil-disable-pass=DeadFunctionElimination | %FileCheck %s
1+
// RUN: %target-swift-frontend %s -O -wmo -emit-sil -Xllvm -sil-disable-pass=DeadFunctionElimination -enforce-exclusivity=unchecked | %FileCheck %s
22

33
// case 1: class protocol -- should optimize
44
internal protocol SomeProtocol : class {

test/SILOptimizer/static_arrays.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -primary-file %s -O -sil-verify-all -Xllvm -sil-disable-pass=FunctionSignatureOpts -module-name=test -emit-sil | %FileCheck %s
1+
// RUN: %target-swift-frontend -primary-file %s -O -sil-verify-all -Xllvm -sil-disable-pass=FunctionSignatureOpts -module-name=test -emit-sil -enforce-exclusivity=unchecked | %FileCheck %s
22

33
// Also do an end-to-end test to check all components, including IRGen.
44
// RUN: %empty-directory(%t)

0 commit comments

Comments
 (0)