Skip to content

Commit f5665df

Browse files
authored
Merge pull request swiftlang#28382 from eeckstein/fix_aeic
Optimizer: Don't keep alwaysEmitIntoClient-functions alive after serialization
2 parents 5a862e4 + 932d468 commit f5665df

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/SILOptimizer/UtilityPasses/SerializeSILPass.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,11 @@ class SerializeSILPass : public SILModuleTransform {
405405
updateOpaqueArchetypes(F);
406406
invalidateAnalysis(&F, SILAnalysis::InvalidationKind::Everything);
407407
}
408+
409+
// After serialization we don't need to keep @alwaysEmitIntoClient
410+
// functions alive, i.e. we don't need to treat them as public functions.
411+
if (F.getLinkage() == SILLinkage::PublicNonABI && M.isWholeModule())
412+
F.setLinkage(SILLinkage::Shared);
408413
}
409414

410415
for (auto &WT : M.getWitnessTables()) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -parse-as-library -emit-module -emit-module-path=%t/Module.swiftmodule -module-name=Module -DMODULE %s -O -emit-sil | %FileCheck %s
3+
4+
// Also link to make sure we don't eliminate any needed symbols.
5+
6+
// RUN: %target-swift-frontend -parse-as-library -emit-module -emit-module-path=%t/Module.swiftmodule -module-name=Module -DMODULE %s -O -c -o module.o
7+
// RUN: %target-build-swift -DMAIN %s -I%t -O -o %t/a.out
8+
9+
#if MODULE
10+
11+
// Check if the optimizer eliminates testit() in Module.
12+
13+
// CHECK-NOT: {{sil .*testit.*}}
14+
15+
@_alwaysEmitIntoClient
16+
@inline(never)
17+
public func testit() {
18+
print("hello")
19+
}
20+
21+
#endif
22+
23+
24+
#if MAIN
25+
26+
import Module
27+
28+
public func caller() {
29+
testit()
30+
}
31+
32+
#endif
33+

0 commit comments

Comments
 (0)