Skip to content

Commit f854547

Browse files
committed
[ownership] Enable ownership verification by default.
I also removed the -verify-sil-ownership flag in favor of a disable flag -disable-sil-ownership-verifier. I used this on only two tests that still need work to get them to pass with ownership, but whose problems are well understood, small corner cases. I am going to fix them in follow on commits. I detail them below: 1. SILOptimizer/definite_init_inout_super_init.swift. This is a test case where DI is supposed to error. The only problem is that we crash before we error since the code emitting by SILGen to trigger this error does not pass ownership invariants. I have spoken with JoeG about this and he suggested that I fix this earlier in the compiler. Since we do not run the ownership verifier without asserts enabled, this should not affect compiler users. Given that it has triggered DI errors previously I think it is safe to disable ownership here. 2. PrintAsObjC/extensions.swift. In this case, the signature generated by type lowering for one of the thunks here uses an unsafe +0 return value instead of doing an autorelease return. The ownership checker rightly flags this leak. This is going to require either an AST level change or a change to TypeLowering. I think it is safe to turn this off since it is such a corner case that it was found by a test that has nothing to do with it. rdar://43398898
1 parent e14e692 commit f854547

File tree

114 files changed

+169
-171
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+169
-171
lines changed

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ function (swift_benchmark_compile_archopts)
314314

315315
set(common_options
316316
"-c"
317-
"-Xfrontend" "-verify-sil-ownership"
318317
"-target" "${target}"
319318
"-${BENCH_COMPILE_ARCHOPTS_OPT}" ${PAGE_ALIGNMENT_OPTION})
320319

@@ -344,7 +343,6 @@ function (swift_benchmark_compile_archopts)
344343

345344
set(common_options_driver
346345
"-c"
347-
"-Xfrontend" "-verify-sil-ownership"
348346
"-target" "${target}"
349347
"-${driver_opt}")
350348

cmake/modules/SwiftSource.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ function(_compile_swift_files
236236
endif()
237237

238238
if(SWIFTFILE_IS_STDLIB)
239-
list(APPEND swift_flags "-Xfrontend" "-verify-sil-ownership")
240239
list(APPEND swift_flags "-Xfrontend" "-enable-mandatory-semantic-arc-opts")
241240
endif()
242241

include/swift/AST/SILOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class SILOptions {
112112
std::string SILOutputFileNameForDebugging;
113113

114114
/// If set to true, compile with the SIL Ownership Model enabled.
115-
bool VerifySILOwnership = false;
115+
bool VerifySILOwnership = true;
116116

117117
/// Assume that code will be executed in a single-threaded environment.
118118
bool AssumeSingleThreaded = false;

include/swift/Option/FrontendOptions.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ def emit_pch : Flag<["-"], "emit-pch">,
299299
def pch_disable_validation : Flag<["-"], "pch-disable-validation">,
300300
HelpText<"Disable validating the persistent PCH">;
301301

302-
def verify_sil_ownership : Flag<["-"], "verify-sil-ownership">,
303-
HelpText<"Verify ownership invariants during SIL Verification ">;
302+
def disable_sil_ownership_verifier : Flag<["-"], "disable-sil-ownership-verifier">,
303+
HelpText<"Do not verify ownership invariants during SIL Verification ">;
304304

305305
def enable_mandatory_semantic_arc_opts : Flag<["-"], "enable-mandatory-semantic-arc-opts">,
306306
HelpText<"Enable the mandatory semantic arc optimizer">;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
767767
Opts.EmitProfileCoverageMapping |= Args.hasArg(OPT_profile_coverage_mapping);
768768
Opts.DisableSILPartialApply |=
769769
Args.hasArg(OPT_disable_sil_partial_apply);
770-
Opts.VerifySILOwnership |= Args.hasArg(OPT_verify_sil_ownership);
770+
Opts.VerifySILOwnership &= !Args.hasArg(OPT_disable_sil_ownership_verifier);
771771
Opts.EnableMandatorySemanticARCOpts |=
772772
Args.hasArg(OPT_enable_mandatory_semantic_arc_opts);
773773
Opts.EnableLargeLoadableTypes |= Args.hasArg(OPT_enable_large_loadable_types);

test/ClangImporter/optional.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(mock-sdk: %clang-importer-sdk) -module-name optional -I %S/Inputs/custom-modules -verify-sil-ownership -emit-silgen -o - %s | %FileCheck %s
2+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -module-name optional -I %S/Inputs/custom-modules -emit-silgen -o - %s | %FileCheck %s
33

44
// REQUIRES: objc_interop
55

test/IRGen/objc_dealloc.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %build-irgen-test-overlays
3-
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -verify-sil-ownership -emit-ir | %FileCheck %s
3+
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir | %FileCheck %s
44

55
// REQUIRES: CPU=x86_64
66
// REQUIRES: objc_interop

test/Interpreter/enforce_exclusive_access.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-build-swift -Xfrontend -verify-sil-ownership -swift-version 4 %s -o %t/a.out -enforce-exclusivity=checked -Onone
2+
// RUN: %target-build-swift -swift-version 4 %s -o %t/a.out -enforce-exclusivity=checked -Onone
33
//
44
// RUN: %target-codesign %t/a.out
55
// RUN: %target-run %t/a.out

test/Misc/tbi.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
// RUN: %swiftc_driver -parse-sil -Xfrontend -disable-legacy-type-info -target arm64-apple-ios8.0 -target-cpu cyclone \
66
// RUN: -O -S %s -parse-as-library -parse-stdlib -module-name Swift \
7-
// RUN: -Xfrontend -verify-sil-ownership | \
7+
// RUN: | \
88
// RUN: %FileCheck --check-prefix=TBI %s
99

1010
// RUN: %swiftc_driver -parse-sil -Xfrontend -disable-legacy-type-info -target arm64-apple-ios7.0 -target-cpu cyclone \
1111
// RUN: -O -S %s -parse-as-library -parse-stdlib -module-name Swift \
12-
// RUN: -Xfrontend -verify-sil-ownership | \
12+
// RUN: | \
1313
// RUN: %FileCheck --check-prefix=NO_TBI %s
1414

1515
// REQUIRES: CODEGENERATOR=AArch64

test/PrintAsObjC/blocks.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Please keep this file in alphabetical order!
22

33
// RUN: %empty-directory(%t)
4-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -verify-sil-ownership -emit-module -o %t %s -disable-objc-attr-requires-foundation-module
5-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -verify-sil-ownership -parse-as-library %t/blocks.swiftmodule -typecheck -emit-objc-header-path %t/blocks.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module
4+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t %s -disable-objc-attr-requires-foundation-module
5+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse-as-library %t/blocks.swiftmodule -typecheck -emit-objc-header-path %t/blocks.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module
66
// RUN: %FileCheck %s < %t/blocks.h
77
// RUN: %check-in-clang %t/blocks.h
88

0 commit comments

Comments
 (0)