Skip to content

Commit 62ad8a6

Browse files
committed
IRGen: Remove special handling of fragile entities in LinkEntity
Dead code now that SILGen enforces this.
1 parent 0808e16 commit 62ad8a6

File tree

3 files changed

+18
-64
lines changed

3 files changed

+18
-64
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 14 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,33 +1205,11 @@ bool LinkEntity::isAvailableExternally(IRGenModule &IGM) const {
12051205
llvm_unreachable("bad link entity kind");
12061206
}
12071207

1208-
bool LinkEntity::isFragile(IRGenModule &IGM) const {
1209-
switch (getKind()) {
1210-
case Kind::SILFunction:
1211-
return getSILFunction()->isFragile();
1212-
1213-
case Kind::SILGlobalVariable:
1214-
return getSILGlobalVariable()->isFragile();
1215-
1216-
case Kind::DirectProtocolWitnessTable: {
1217-
if (auto wt = IGM.SILMod->lookUpWitnessTable(getProtocolConformance())) {
1218-
return wt->isFragile();
1219-
} else {
1220-
return false;
1221-
}
1222-
}
1223-
1224-
default:
1225-
break;
1226-
}
1227-
return false;
1228-
}
1229-
12301208

12311209
static std::pair<llvm::GlobalValue::LinkageTypes,
12321210
llvm::GlobalValue::VisibilityTypes>
12331211
getIRLinkage(IRGenModule &IGM,
1234-
SILLinkage linkage, bool isFragile, ForDefinition_t isDefinition,
1212+
SILLinkage linkage, ForDefinition_t isDefinition,
12351213
bool isWeakImported) {
12361214

12371215
#define RESULT(LINKAGE, VISIBILITY) \
@@ -1253,39 +1231,25 @@ llvm::GlobalValue::VISIBILITY##Visibility }
12531231
break;
12541232
}
12551233

1256-
if (isFragile) {
1257-
// Fragile functions/globals must be visible from outside, regardless of
1258-
// their accessibility. If a caller is also fragile and inlined into another
1259-
// module it must be able to access this (not-inlined) function/global.
1260-
switch (linkage) {
1261-
case SILLinkage::Hidden:
1262-
case SILLinkage::Private:
1263-
linkage = SILLinkage::Public;
1264-
break;
1265-
1266-
case SILLinkage::Public:
1267-
case SILLinkage::Shared:
1268-
case SILLinkage::HiddenExternal:
1269-
case SILLinkage::PrivateExternal:
1270-
case SILLinkage::PublicExternal:
1271-
case SILLinkage::SharedExternal:
1272-
break;
1273-
}
1274-
}
1275-
12761234
switch (linkage) {
12771235
case SILLinkage::Public:
12781236
return {llvm::GlobalValue::ExternalLinkage, PublicDefinitionVisibility};
1237+
12791238
case SILLinkage::Shared:
1280-
case SILLinkage::SharedExternal: return RESULT(LinkOnceODR, Hidden);
1281-
case SILLinkage::Hidden: return RESULT(External, Hidden);
1239+
case SILLinkage::SharedExternal:
1240+
return RESULT(LinkOnceODR, Hidden);
1241+
1242+
case SILLinkage::Hidden:
1243+
return RESULT(External, Hidden);
1244+
12821245
case SILLinkage::Private:
12831246
if (IGM.dispatcher.hasMultipleIGMs()) {
12841247
// In case of multiple llvm modules (in multi-threaded compilation) all
12851248
// private decls must be visible from other files.
12861249
return RESULT(External, Hidden);
12871250
}
12881251
return RESULT(Internal, Default);
1252+
12891253
case SILLinkage::PublicExternal:
12901254
if (isDefinition) {
12911255
return RESULT(AvailableExternally, Default);
@@ -1294,15 +1258,12 @@ llvm::GlobalValue::VISIBILITY##Visibility }
12941258
if (isWeakImported)
12951259
return RESULT(ExternalWeak, Default);
12961260
return RESULT(External, Default);
1261+
12971262
case SILLinkage::HiddenExternal:
1298-
case SILLinkage::PrivateExternal: {
1299-
auto visibility = isFragile ? llvm::GlobalValue::DefaultVisibility
1300-
: llvm::GlobalValue::HiddenVisibility;
1301-
if (isDefinition) {
1302-
return {llvm::GlobalValue::AvailableExternallyLinkage, visibility};
1303-
}
1304-
return {llvm::GlobalValue::ExternalLinkage, visibility};
1305-
}
1263+
case SILLinkage::PrivateExternal:
1264+
if (isDefinition)
1265+
return RESULT(AvailableExternally, Hidden);
1266+
return RESULT(External, Hidden);
13061267
}
13071268
llvm_unreachable("bad SIL linkage");
13081269
}
@@ -1317,7 +1278,6 @@ static void updateLinkageForDefinition(IRGenModule &IGM,
13171278
auto linkage = getIRLinkage(
13181279
IGM,
13191280
entity.getLinkage(IGM, ForDefinition),
1320-
entity.isFragile(IGM),
13211281
ForDefinition,
13221282
entity.isWeakImported(IGM.SILMod->getSwiftModule()));
13231283
global->setLinkage(linkage.first);
@@ -1343,7 +1303,6 @@ LinkInfo LinkInfo::get(IRGenModule &IGM, const LinkEntity &entity,
13431303

13441304
std::tie(result.Linkage, result.Visibility) =
13451305
getIRLinkage(IGM, entity.getLinkage(IGM, isDefinition),
1346-
entity.isFragile(IGM),
13471306
isDefinition,
13481307
entity.isWeakImported(IGM.SILMod->getSwiftModule()));
13491308

lib/IRGen/Linking.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,6 @@ class LinkEntity {
496496
///
497497
bool isAvailableExternally(IRGenModule &IGM) const;
498498

499-
/// Returns true if this function or global variable may be inlined into
500-
/// another module.
501-
///
502-
bool isFragile(IRGenModule &IGM) const;
503-
504499
ValueDecl *getDecl() const {
505500
assert(isDeclKind(getKind()));
506501
return reinterpret_cast<ValueDecl*>(Pointer);

test/IRGen/sil_linkage.sil

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
sil_stage canonical
44

55
// CHECK: define{{( protected)?}} void @public_fragile_function_test() {{.*}} {
6-
// CHECK: define{{( protected)?}} void @hidden_fragile_function_test() {{.*}} {
6+
// CHECK: define hidden void @hidden_fragile_function_test() {{.*}} {
77
// CHECK: define linkonce_odr hidden void @shared_fragile_function_test() {{.*}} {
8-
// CHECK: define{{( protected)?}} void @private_fragile_function_test() {{.*}} {
8+
// CHECK: define internal void @private_fragile_function_test() {{.*}} {
99
// CHECK: define linkonce_odr hidden void @public_external_fragile_function_def_test() {{.*}} {
10-
// CHECK: define{{( protected)?}} available_externally void @hidden_external_fragile_function_def_test() {{.*}} {
10+
// CHECK: define available_externally hidden void @hidden_external_fragile_function_def_test() {{.*}} {
1111
// CHECK: define linkonce_odr hidden void @shared_external_fragile_function_def_test() {{.*}} {
12-
// CHECK: define{{( protected)?}} available_externally void @private_external_fragile_function_def_test() {{.*}} {
12+
// CHECK: define available_externally hidden void @private_external_fragile_function_def_test() {{.*}} {
1313
// CHECK: define{{( protected)?}} void @public_resilient_function_test() {{.*}} {
1414
// CHECK: define hidden void @hidden_resilient_function_test() {{.*}} {
1515
// CHECK: define linkonce_odr hidden void @shared_resilient_function_test() {{.*}} {

0 commit comments

Comments
 (0)