Skip to content

Commit bb1ba7c

Browse files
committed
[embedded] Run DeadFunctionAndGlobalElimination after MandatoryPerformanceOptimizations
1 parent 36dd2c9 commit bb1ba7c

File tree

7 files changed

+55
-9
lines changed

7 files changed

+55
-9
lines changed

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ static void addMandatoryDiagnosticOptPipeline(SILPassPipelinePlan &P) {
254254
P.addMandatoryPerformanceOptimizations();
255255
P.addOnoneSimplification();
256256
P.addInitializeStaticGlobals();
257+
258+
if (P.getOptions().EmbeddedSwift) {
259+
P.addDeadFunctionAndGlobalElimination();
260+
}
261+
257262
P.addPerformanceDiagnostics();
258263
}
259264

lib/SILOptimizer/UtilityPasses/Link.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
using namespace swift;
1919

20+
static llvm::cl::opt<bool> LinkEmbeddedRuntime("link-embedded-runtime",
21+
llvm::cl::init(true));
22+
2023
//===----------------------------------------------------------------------===//
2124
// Top Level Driver
2225
//===----------------------------------------------------------------------===//
@@ -39,7 +42,7 @@ class SILLinker : public SILModuleTransform {
3942

4043
// In embedded Swift, the stdlib contains all the runtime functions needed
4144
// (swift_retain, etc.). Link them in so they can be referenced in IRGen.
42-
if (M.getOptions().EmbeddedSwift) {
45+
if (M.getOptions().EmbeddedSwift && LinkEmbeddedRuntime) {
4346
linkEmbeddedRuntimeFromStdlib();
4447
}
4548
}

stdlib/public/Platform/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ add_swift_target_library(swiftDarwin ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES}
7777
INSTALL_IN_COMPONENT sdk-overlay
7878
MACCATALYST_BUILD_FLAVOR "zippered")
7979

80-
# TODO(mracek): Disable building Darwin module as embedded pending investigations into a build failure
81-
if(FALSE)
80+
if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB)
8281
set(SWIFT_ENABLE_REFLECTION OFF)
8382

8483
add_custom_target(embedded-darwin ALL)

test/embedded/darwin-bridging-header.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
// REQUIRES: VENDOR=apple
1212
// REQUIRES: OS=macosx
1313

14-
// Temporarily disabled:
15-
// REQUIRES: rdar119283700
16-
1714
// BEGIN BridgingHeader.h
1815

1916
#include <unistd.h>

test/embedded/darwin.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
// REQUIRES: VENDOR=apple
1010
// REQUIRES: OS=macosx
1111

12-
// Temporarily disabled:
13-
// REQUIRES: rdar119283700
14-
1512
import Darwin
1613

1714
@main

test/embedded/duration.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %target-swift-emit-ir %s -enable-experimental-feature Embedded -wmo
2+
// RUN: %target-swift-emit-ir -O %s -enable-experimental-feature Embedded -wmo
3+
// RUN: %target-swift-emit-ir -Osize %s -enable-experimental-feature Embedded -wmo
4+
5+
// REQUIRES: swift_in_compiler
6+
7+
@available(SwiftStdlib 5.7, *)
8+
extension Duration {
9+
@available(SwiftStdlib 5.7, *)
10+
public init() {
11+
self = .seconds(10) + .nanoseconds(20)
12+
}
13+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %target-swift-frontend -parse-stdlib -emit-ir %s -enable-experimental-feature Embedded -Xllvm -link-embedded-runtime=0
2+
3+
// REQUIRES: swift_in_compiler
4+
// REQUIRES: VENDOR=apple
5+
// REQUIRES: OS=macosx
6+
7+
public struct UInt23 {
8+
}
9+
10+
public protocol MyBinaryInteger {
11+
}
12+
13+
extension UInt23: MyBinaryInteger {
14+
}
15+
16+
protocol MyProto {
17+
static var my_static_var: UInt23 { get }
18+
static func foo()
19+
}
20+
21+
struct MyStruct: MyProto {
22+
static let my_static_var = UInt23()
23+
}
24+
25+
extension MyProto {
26+
public static func foo() {
27+
bar(Self.my_static_var)
28+
}
29+
}
30+
31+
public func bar<T: MyBinaryInteger>(_ value: @autoclosure () -> T) {
32+
}

0 commit comments

Comments
 (0)