Skip to content

Commit 6b92d95

Browse files
committed
Revert "SILGen: Explicitly make fragile entities public when -sil-serialize-all is on"
This reverts commit 9a7a517. See the discussion here for details: <6723560>
1 parent 8f17c43 commit 6b92d95

File tree

10 files changed

+16
-30
lines changed

10 files changed

+16
-30
lines changed

lib/SIL/SILDeclRef.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,8 @@ SILLinkage SILDeclRef::getLinkage(ForDefinition_t forDefinition) const {
332332
if (isa<ClangModuleUnit>(derivedFor->getModuleScopeContext()))
333333
return ClangLinkage;
334334
}
335-
336-
// If the module is being built with -sil-serialize-all, everything has
337-
// to have public linkage.
338-
if (moduleContext->getParentModule()->getResilienceStrategy()
339-
== ResilienceStrategy::Fragile) {
340-
return (forDefinition ? SILLinkage::Public : SILLinkage::PublicExternal);
341-
}
342-
343-
// Otherwise, linkage is determined by accessibility at the AST level.
335+
336+
// Otherwise, we have external linkage.
344337
switch (d->getEffectiveAccess()) {
345338
case Accessibility::Private:
346339
return (forDefinition ? SILLinkage::Private : SILLinkage::PrivateExternal);

lib/SILGen/SILGen.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -875,9 +875,7 @@ SILFunction *SILGenModule::emitLazyGlobalInitializer(StringRef funcName,
875875
auto initSILType = getLoweredType(initType).castTo<SILFunctionType>();
876876

877877
auto *f =
878-
M.createFunction(makeModuleFragile
879-
? SILLinkage::Public
880-
: SILLinkage::Private,
878+
M.createFunction(SILLinkage::Private,
881879
funcName, initSILType, nullptr,
882880
SILLocation(binding), IsNotBare, IsNotTransparent,
883881
makeModuleFragile

lib/SILGen/SILGenGlobalVariable.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,7 @@ void SILGenModule::emitGlobalInitialization(PatternBindingDecl *pd,
224224

225225
// TODO: include the module in the onceToken's name mangling.
226226
// Then we can make it fragile.
227-
auto onceToken = SILGlobalVariable::create(M,
228-
makeModuleFragile
229-
? SILLinkage::Public
230-
: SILLinkage::Private,
227+
auto onceToken = SILGlobalVariable::create(M, SILLinkage::Private,
231228
makeModuleFragile,
232229
onceTokenBuffer, onceSILTy);
233230
onceToken->setDeclaration(false);

lib/SILGen/SILGenType.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ SILGenModule::emitVTableMethod(SILDeclRef derived, SILDeclRef base) {
9191
auto *derivedDecl = cast<AbstractFunctionDecl>(derived.getDecl());
9292
SILLocation loc(derivedDecl);
9393
auto thunk =
94-
M.createFunction(makeModuleFragile
95-
? SILLinkage::Public
96-
: SILLinkage::Private,
94+
M.createFunction(SILLinkage::Private,
9795
name, overrideInfo.SILFnType,
9896
derivedDecl->getGenericParams(), loc, IsBare,
9997
IsNotTransparent, IsNotFragile);

test/SILGen/fragile_globals.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ var mygg = 29
1111

1212
// Check if we have three tokens: 2 from the imported modules, one from mygg.
1313

14-
// CHECK: sil_global private @globalinit_[[T1:.*]]_token0
15-
// CHECK: sil_global [fragile] @globalinit_[[T2:.*]]_token0
16-
// CHECK: sil_global [fragile] @globalinit_[[T3:.*]]_token0
14+
// CHECK: sil_global private{{.*}} @globalinit_[[T1:.*]]_token0
15+
// CHECK: sil_global private{{.*}} @globalinit_[[T2:.*]]_token0
16+
// CHECK: sil_global private{{.*}} @globalinit_[[T3:.*]]_token0
1717

1818
public func sum() -> Int {
1919
return mygg + get_gg_a() + get_gg_b()

test/SILOptimizer/dead_inlined_func.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-swift-frontend -O -g %s -emit-sil | FileCheck %s -check-prefix=CHECK-SIL
2-
// RUN: %target-swift-frontend -O -g %s -emit-ir | FileCheck %s -check-prefix=CHECK-IR
2+
// RUN: %target-swift-frontend -O -g %s -sil-serialize-all -emit-ir | FileCheck %s -check-prefix=CHECK-IR
33

44
// The dead inlined function should not be in the SIL
55
// CHECK-SIL-NOT: sil {{.*}}to_be_inlined

test/Serialization/global_init.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ var MyVar = 3
1919
// CHECK: let MyConst: Int
2020
// CHECK: var MyVar: Int
2121

22-
// CHECK-DAG: sil [fragile] [global_init] @_TF11global_initau7MyConstSi : $@convention(thin) () -> Builtin.RawPointer
23-
// CHECK-DAG: sil [fragile] [global_init] @_TF11global_initau5MyVarSi : $@convention(thin) () -> Builtin.RawPointer
22+
// CHECK-DAG: sil hidden [fragile] [global_init] @_TF11global_initau7MyConstSi : $@convention(thin) () -> Builtin.RawPointer
23+
// CHECK-DAG: sil hidden [fragile] [global_init] @_TF11global_initau5MyVarSi : $@convention(thin) () -> Builtin.RawPointer
2424

2525
func getGlobals() -> Int {
2626
return MyVar + MyConst

test/Serialization/serialize_attr.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ class CC<T : PP> {
5252
}
5353
}
5454

55-
// CHECK-DAG: sil [fragile] [_specialize <Int, Float>] @_TF14serialize_attr14specializeThisu0_rFTx1uq__T_ : $@convention(thin) <T, U> (@in T, @in U) -> () {
55+
// CHECK-DAG: sil hidden [fragile] [_specialize <Int, Float>] @_TF14serialize_attr14specializeThisu0_rFTx1uq__T_ : $@convention(thin) <T, U> (@in T, @in U) -> () {
5656

57-
// CHECK-DAG: sil [fragile] [noinline] [_specialize <RR, Float, SS, Int>] @_TFC14serialize_attr2CC3foouRd__S_2QQrfTqd__1gGVS_2GGx__Tqd__GS2_x__ : $@convention(method) <T where T : PP><U where U : QQ> (@in U, GG<T>, @guaranteed CC<T>) -> (@out U, GG<T>) {
57+
// CHECK-DAG: sil hidden [fragile] [noinline] [_specialize <RR, Float, SS, Int>] @_TFC14serialize_attr2CC3foouRd__S_2QQrfTqd__1gGVS_2GGx__Tqd__GS2_x__ : $@convention(method) <T where T : PP><U where U : QQ> (@in U, GG<T>, @guaranteed CC<T>) -> (@out U, GG<T>) {

test/sil-extract/load-serialized-sil.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222

23-
// CHECK-LABEL: sil [fragile] @_TFVs1X4testfT_T_ : $@convention(method) (X) -> ()
23+
// CHECK-LABEL: sil hidden [fragile] @_TFVs1X4testfT_T_ : $@convention(method) (X) -> ()
2424
// CHECK: bb0
2525
// CHECK-NEXT: function_ref
2626
// CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> ()

test/sil-opt/sil-opt.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// CHECK: func unknown()
1919
// SIB-CHECK: func unknown()
2020

21-
// CHECK-LABEL: sil [fragile] @_TFVs1X4testfT_T_ : $@convention(method) (X) -> ()
21+
// CHECK-LABEL: sil hidden [fragile] @_TFVs1X4testfT_T_ : $@convention(method) (X) -> ()
2222
// CHECK: bb0
2323
// CHECK-NEXT: function_ref
2424
// CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> ()
@@ -36,7 +36,7 @@
3636
// CHECK: sil @unknown : $@convention(thin) () -> ()
3737
// SIB-CHECK: sil @unknown : $@convention(thin) () -> ()
3838

39-
// CHECK: sil [fragile] @_TFVs1XCfT_S_ : $@convention(method) (@thin X.Type) -> X
39+
// CHECK: sil hidden [fragile] @_TFVs1XCfT_S_ : $@convention(method) (@thin X.Type) -> X
4040
// CHECK: bb0
4141
// CHECK-NEXT: struct $X ()
4242
// CHECK-NEXT: return

0 commit comments

Comments
 (0)