Skip to content

Commit 9eb9a2e

Browse files
authored
Merge pull request #71676 from eeckstein/embedded-ossa-modules
embedded: enable OSSA modules in embedded swift
2 parents 8b79101 + 06ce47f commit 9eb9a2e

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3272,6 +3272,8 @@ bool CompilerInvocation::parseArgs(
32723272
SILOpts.SkipFunctionBodies = FunctionBodySkipping::None;
32733273
SILOpts.CMOMode = CrossModuleOptimizationMode::Everything;
32743274
SILOpts.EmbeddedSwift = true;
3275+
// OSSA modules are required for deinit de-virtualization.
3276+
SILOpts.EnableOSSAModules = true;
32753277
} else {
32763278
if (SILOpts.NoAllocations) {
32773279
Diags.diagnose(SourceLoc(), diag::no_allocations_without_embedded);
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %{python} %utils/split_file.py -o %t %s
3+
4+
// RUN: %target-swift-frontend -emit-module -o %t/MyModule.swiftmodule %t/MyModule.swift -enable-experimental-feature Embedded -Osize -wmo -parse-as-library
5+
// RUN: %target-swift-frontend -emit-sil -I %t %t/Main.swift -enable-experimental-feature Embedded -parse-as-library | %FileCheck %s
6+
7+
// REQUIRES: swift_in_compiler
8+
// REQUIRES: OS=macosx || OS=linux-gnu
9+
10+
// BEGIN MyModule.swift
11+
12+
public func createFoo(x: some FixedWidthInteger) {
13+
let _ = Foo<UInt>(i: 0)
14+
}
15+
16+
public struct Foo<Element> : ~Copyable {
17+
public let i: Int
18+
19+
public init(i: Int) {
20+
self.i = i
21+
}
22+
23+
deinit { }
24+
}
25+
26+
// BEGIN Main.swift
27+
28+
import MyModule
29+
30+
func test() {
31+
createFoo(x: 1)
32+
}
33+
34+
// CHECK-LABEL: sil @$s8MyModule9createFoo1xyx_ts17FixedWidthIntegerRzlFSi_Tg5 :
35+
// CHECK-NOT: release
36+
// CHECK: } // end sil function '$s8MyModule9createFoo1xyx_ts17FixedWidthIntegerRzlFSi_Tg5'

0 commit comments

Comments
 (0)