Skip to content

Commit 54a411d

Browse files
committed
Revert "SILGen: Explicitly make fragile entities public when -sil-serialize-all is on"
This commit caused link failures across several stdlib tests. This reverts commit 6723560.
1 parent 92b3e15 commit 54a411d

File tree

10 files changed

+17
-35
lines changed

10 files changed

+17
-35
lines changed

lib/SIL/SILDeclRef.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,8 @@ SILLinkage SILDeclRef::getLinkage(ForDefinition_t forDefinition) const {
324324
if (isa<ClangModuleUnit>(derivedFor->getModuleScopeContext()))
325325
return ClangLinkage;
326326
}
327-
328-
// If the module is being built with -sil-serialize-all, everything has
329-
// to have public linkage.
330-
if (moduleContext->getParentModule()->getResilienceStrategy()
331-
== ResilienceStrategy::Fragile) {
332-
return (forDefinition ? SILLinkage::Public : SILLinkage::PublicExternal);
333-
}
334-
335-
// Otherwise, linkage is determined by accessibility at the AST level.
327+
328+
// Otherwise, we have external linkage.
336329
switch (d->getEffectiveAccess()) {
337330
case Accessibility::Private:
338331
return (forDefinition ? SILLinkage::Private : SILLinkage::PrivateExternal);

lib/SILGen/SILGen.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -854,14 +854,9 @@ SILFunction *SILGenModule::emitLazyGlobalInitializer(StringRef funcName,
854854
auto initSILType = getLoweredType(initType).castTo<SILFunctionType>();
855855

856856
auto *f =
857-
M.getOrCreateFunction(makeModuleFragile
858-
? SILLinkage::Public
859-
: SILLinkage::Private,
860-
funcName, initSILType, nullptr,
857+
M.getOrCreateFunction(SILLinkage::Private, funcName, initSILType, nullptr,
861858
SILLocation(binding), IsNotBare, IsNotTransparent,
862-
makeModuleFragile
863-
? IsFragile
864-
: IsNotFragile);
859+
makeModuleFragile ? IsFragile : IsNotFragile);
865860
f->setDebugScope(
866861
new (M) SILDebugScope(RegularLocation(binding->getInit(pbdEntry)), f));
867862
f->setLocation(binding);

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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ SILGenModule::emitVTableMethod(SILDeclRef derived, SILDeclRef base) {
8888
auto *derivedDecl = cast<AbstractFunctionDecl>(derived.getDecl());
8989
SILLocation loc(derivedDecl);
9090
auto thunk =
91-
M.getOrCreateFunction(makeModuleFragile
92-
? SILLinkage::Public
93-
: SILLinkage::Private,
94-
name, overrideInfo.SILFnType,
91+
M.getOrCreateFunction(SILLinkage::Private, name, overrideInfo.SILFnType,
9592
derivedDecl->getGenericParams(), loc, IsBare,
9693
IsNotTransparent, IsNotFragile);
9794
thunk->setDebugScope(new (M) SILDebugScope(loc, thunk));

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

0 commit comments

Comments
 (0)