Skip to content

Commit 9253273

Browse files
authored
Merge pull request #68862 from kubamracek/embedded-shared-linkage
[embedded] Allow serialization of SILLinkage::shared functions without promoting them to public
2 parents 2a604e2 + f34bef8 commit 9253273

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

lib/SIL/IR/SILFunctionBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ SILFunction *SILFunctionBuilder::getOrCreateFunction(
3232
if (auto fn = mod.lookUpFunction(name)) {
3333
assert(fn->getLoweredFunctionType() == type);
3434
assert(stripExternalFromLinkage(fn->getLinkage()) ==
35-
stripExternalFromLinkage(linkage));
35+
stripExternalFromLinkage(linkage) || mod.getOptions().EmbeddedSwift);
3636
return fn;
3737
}
3838

test/embedded/shared-linkage.swift

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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/Module.swiftmodule %t/Module.swift -enable-experimental-feature Embedded
5+
// RUN: %target-swift-frontend -emit-ir %t/Main.swift -I%t -enable-experimental-feature Embedded
6+
7+
// RUN: %target-swift-frontend -O -emit-module -o %t/Module.swiftmodule %t/Module.swift -enable-experimental-feature Embedded
8+
// RUN: %target-swift-frontend -O -emit-ir %t/Main.swift -I%t -enable-experimental-feature Embedded
9+
10+
// RUN: %target-swift-frontend -Osize -emit-module -o %t/Module.swiftmodule %t/Module.swift -enable-experimental-feature Embedded
11+
// RUN: %target-swift-frontend -Osize -emit-ir %t/Main.swift -I%t -enable-experimental-feature Embedded
12+
13+
// REQUIRES: swift_in_compiler
14+
// REQUIRES: VENDOR=apple
15+
// REQUIRES: OS=macosx
16+
17+
// BEGIN Module.swift
18+
19+
public func bar<R>(count: Int, _ body: (UnsafeMutableBufferPointer<Int>) -> R) -> R {
20+
let pointer = UnsafeMutablePointer<Int>(bitPattern: 42)!
21+
let inoutBufferPointer = UnsafeMutableBufferPointer(start: pointer, count: count)
22+
return body(inoutBufferPointer)
23+
}
24+
25+
public func foo<R>(_ body: () -> R) -> R {
26+
bar(count: 10) { p in
27+
body()
28+
}
29+
}
30+
31+
public func module_func() {
32+
foo {
33+
return 0
34+
}
35+
}
36+
37+
// BEGIN Main.swift
38+
39+
import Module
40+
41+
public func test() {
42+
module_func()
43+
}
44+
45+
public func client_func() {
46+
foo {
47+
return 0
48+
}
49+
}

0 commit comments

Comments
 (0)