Skip to content

Commit 57654da

Browse files
committed
[ownership] On non-Darwin platforms start serializing the stdlib in OSSA as well.
I had to fix a memory corruption bug (see previous commit) to land this. But now that it is fixed, we are ready!
1 parent 891bd00 commit 57654da

File tree

10 files changed

+14
-244
lines changed

10 files changed

+14
-244
lines changed

include/swift/AST/SILOptions.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,8 @@ class SILOptions {
154154
bool VerifyExclusivity = false;
155155

156156
/// When building the stdlib with opts should we lower ownership after
157-
/// serialization? Otherwise we do before. Only set to true on Darwin for now.
158-
///
159-
bool SerializeStdlibWithOwnershipWithOpts = false;
157+
/// serialization? Otherwise we do before.
158+
bool SerializeStdlibWithOwnershipWithOpts = true;
160159

161160
/// Calls to the replaced method inside of the replacement method will call
162161
/// the previous implementation.

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,11 +1204,6 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
12041204
Args.hasArg(OPT_sil_stop_optzns_before_lowering_ownership);
12051205
if (const Arg *A = Args.getLastArg(OPT_external_pass_pipeline_filename))
12061206
Opts.ExternalPassPipelineFilename = A->getValue();
1207-
// If our triple is a darwin triple, lower ownership on the stdlib after we
1208-
// serialize.
1209-
if (Triple.isOSDarwin()) {
1210-
Opts.SerializeStdlibWithOwnershipWithOpts = true;
1211-
}
12121207

12131208
Opts.GenerateProfile |= Args.hasArg(OPT_profile_generate);
12141209
const Arg *ProfileUse = Args.getLastArg(OPT_profile_use);

test/SIL/Serialization/shared_function_serialization.sil

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
// RUN: %target-sil-opt -enable-sil-verify-all -I %t -performance-linker -inline %s -o - | %FileCheck %s
44

55
// CHECK: sil private @top_level_code
6-
// CHECK: sil public_external [serialized] @$ss1XVABycfC{{.*}}
7-
// CHECK: sil public_external [serialized] @$ss17the_thing_it_does1xys1XV_tF{{.*}}
8-
// CHECK: sil shared_external [serializable] [noinline] @$ss9the_thing1tyx_tlFs1XV_Tgq5{{.*}}
9-
10-
// See shared_function_serialization_darwin.sil
11-
// UNSUPPORTED: OS=macosx || OS=tvos || OS=watchos || OS=ios
6+
// CHECK: sil public_external [serialized] [ossa] @$ss1XVABycfC{{.*}}
7+
// CHECK: sil public_external [serialized] [ossa] @$ss17the_thing_it_does1xys1XV_tF{{.*}}
8+
// CHECK: sil shared_external [serializable] [noinline] [ossa] @$ss9the_thing1tyx_tlFs1XV_Tgq5{{.*}}
129

1310
sil_stage canonical
1411

test/SIL/Serialization/shared_function_serialization_darwin.sil

Lines changed: 0 additions & 42 deletions
This file was deleted.

test/Serialization/early-serialization-darwin.swift

Lines changed: 0 additions & 42 deletions
This file was deleted.

test/Serialization/early-serialization.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
// - it happens before the performance inlining and thus preserves @_semantics functions
77
// - it happens after generic specialization
88

9-
// UNSUPPORTED: OS=macosx || OS=tvos || OS=watchos || OS=ios
10-
119
@frozen
1210
public struct Int {
1311
@inlinable
@@ -20,7 +18,7 @@ public struct Array<T> {
2018
public init() {}
2119

2220
// Check that the generic version of a @_semantics function is preserved.
23-
// CHECK: sil [serialized] [_semantics "array.get_capacity"] [canonical] @$sSa12_getCapacitySiyF : $@convention(method) <T> (Array<T>) -> Int
21+
// CHECK: sil [serialized] [_semantics "array.get_capacity"] [canonical] [ossa] @$sSa12_getCapacitySiyF : $@convention(method) <T> (Array<T>) -> Int
2422
@inlinable
2523
@usableFromInline
2624
@_semantics("array.get_capacity")
@@ -30,10 +28,10 @@ public struct Array<T> {
3028
}
3129

3230
// Check that a specialized version of a function is produced
33-
// CHECK: sil shared [serializable] [_semantics "array.get_capacity"] [canonical] @$sSa12_getCapacitySiyFSi_Tgq5 : $@convention(method) (Array<Int>) -> Int
31+
// CHECK: sil shared [serializable] [_semantics "array.get_capacity"] [canonical] [ossa] @$sSa12_getCapacitySiyFSi_Tgq5 : $@convention(method) (Array<Int>) -> Int
3432

3533
// Check that a call of a @_semantics function was not inlined if early-serialization is enabled.
36-
// CHECK: sil [serialized] [canonical] @$ss28userOfSemanticsAnnotatedFuncySiSaySiGF
34+
// CHECK: sil [serialized] [canonical] [ossa] @$ss28userOfSemanticsAnnotatedFuncySiSaySiGF
3735
// CHECK: function_ref
3836
// CHECK: apply
3937
@inlinable

test/sil-func-extractor/load-serialized-sil-darwin.swift

Lines changed: 0 additions & 62 deletions
This file was deleted.

test/sil-func-extractor/load-serialized-sil.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -module-link-name swiftCore -O -parse-as-library -parse-stdlib -emit-module -emit-module-path - -o /dev/null | %target-sil-func-extractor -module-name="Swift" -func='$ss1XV4testyyF' | %FileCheck %s
22
// RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -O -parse-as-library -parse-stdlib -emit-sib -o - | %target-sil-func-extractor -module-name="Swift" -func='$ss1XV4testyyF' | %FileCheck %s -check-prefix=SIB-CHECK
33

4-
// UNSUPPORTED: OS=macosx || OS=tvos || OS=watchos || OS=ios
5-
64
// CHECK: import Builtin
75
// CHECK: import Swift
86

@@ -14,7 +12,7 @@
1412
// CHECK-NEXT: init
1513
// CHECK-NEXT: }
1614

17-
// CHECK-LABEL: sil [serialized] [canonical] @$ss1XV4testyyF : $@convention(method) (X) -> ()
15+
// CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XV4testyyF : $@convention(method) (X) -> ()
1816
// CHECK: bb0
1917
// CHECK-NEXT: function_ref
2018
// CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> ()
@@ -38,7 +36,7 @@
3836
// SIB-CHECK-NEXT: init
3937
// SIB-CHECK-NEXT: }
4038

41-
// SIB-CHECK-LABEL: sil [serialized] [canonical] @$ss1XV4testyyF : $@convention(method) (X) -> ()
39+
// SIB-CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XV4testyyF : $@convention(method) (X) -> ()
4240
// SIB-CHECK: bb0
4341
// SIB-CHECK-NEXT: function_ref
4442
// SIB-CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> ()

test/sil-opt/sil-opt-darwin.swift

Lines changed: 0 additions & 69 deletions
This file was deleted.

test/sil-opt/sil-opt.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -module-link-name swiftCore -O -parse-as-library -parse-stdlib -emit-module -emit-module-path - -o /dev/null | %target-sil-opt -enable-sil-verify-all -module-name="Swift" -emit-sorted-sil | %FileCheck %s
22
// RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -O -parse-as-library -parse-stdlib -emit-sib -o - | %target-sil-opt -enable-sil-verify-all -module-name="Swift" -emit-sorted-sil | %FileCheck %s -check-prefix=SIB-CHECK
33

4-
// UNSUPPORTED: OS=macosx || OS=tvos || OS=watchos || OS=ios
5-
64
// CHECK: import Builtin
75
// CHECK: import Swift
86

@@ -13,15 +11,15 @@
1311
// CHECK-NEXT: @inlinable init
1412
// CHECK-NEXT: }
1513

16-
// CHECK-LABEL: sil [serialized] [canonical] @$ss1XV4testyyF : $@convention(method) (X) -> ()
14+
// CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XV4testyyF : $@convention(method) (X) -> ()
1715
// CHECK: bb0
1816
// CHECK-NEXT: function_ref
1917
// CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> ()
2018
// CHECK-NEXT: apply
2119
// CHECK-NEXT: tuple
2220
// CHECK-NEXT: return
2321

24-
// CHECK-LABEL: sil [serialized] [canonical] @$ss1XVABycfC : $@convention(method) (@thin X.Type) -> X
22+
// CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XVABycfC : $@convention(method) (@thin X.Type) -> X
2523
// CHECK: bb0
2624
// CHECK-NEXT: struct $X ()
2725
// CHECK-NEXT: return
@@ -39,15 +37,15 @@
3937
// SIB-CHECK-NEXT: init
4038
// SIB-CHECK-NEXT: }
4139

42-
// SIB-CHECK-LABEL: sil [serialized] [canonical] @$ss1XV4testyyF : $@convention(method) (X) -> ()
40+
// SIB-CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XV4testyyF : $@convention(method) (X) -> ()
4341
// SIB-CHECK: bb0
4442
// SIB-CHECK-NEXT: function_ref
4543
// SIB-CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> ()
4644
// SIB-CHECK-NEXT: apply
4745
// SIB-CHECK-NEXT: tuple
4846
// SIB-CHECK-NEXT: return
4947

50-
// SIB-CHECK-LABEL: sil [serialized] [canonical] @$ss1XVABycfC : $@convention(method) (@thin X.Type) -> X
48+
// SIB-CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XVABycfC : $@convention(method) (@thin X.Type) -> X
5149
// SIB-CHECK: bb0
5250
// SIB-CHECK-NEXT: struct $X ()
5351
// SIB-CHECK-NEXT: return

0 commit comments

Comments
 (0)