Skip to content

Commit 38df7b1

Browse files
authored
Stop using 'no_dead_strip' Mach-O section attribute on __swift5_protos, __swift5_proto, __swift5_types sections (#39312)
This is needed to for a future change, <#39313>, which will start to allow under certain conditions to dead-strip unused types, protocols and conformances.
1 parent 1142f61 commit 38df7b1

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3682,7 +3682,7 @@ llvm::Constant *IRGenModule::emitSwiftProtocols() {
36823682
llvm_unreachable("Don't know how to emit protocols for "
36833683
"the selected object format.");
36843684
case llvm::Triple::MachO:
3685-
sectionName = "__TEXT, __swift5_protos, regular, no_dead_strip";
3685+
sectionName = "__TEXT, __swift5_protos, regular";
36863686
break;
36873687
case llvm::Triple::ELF:
36883688
case llvm::Triple::Wasm:
@@ -3743,7 +3743,7 @@ llvm::Constant *IRGenModule::emitProtocolConformances() {
37433743
llvm_unreachable("Don't know how to emit protocol conformances for "
37443744
"the selected object format.");
37453745
case llvm::Triple::MachO:
3746-
sectionName = "__TEXT, __swift5_proto, regular, no_dead_strip";
3746+
sectionName = "__TEXT, __swift5_proto, regular";
37473747
break;
37483748
case llvm::Triple::ELF:
37493749
case llvm::Triple::Wasm:
@@ -3769,7 +3769,7 @@ llvm::Constant *IRGenModule::emitTypeMetadataRecords() {
37693769
std::string sectionName;
37703770
switch (TargetInfo.OutputObjectFormat) {
37713771
case llvm::Triple::MachO:
3772-
sectionName = "__TEXT, __swift5_types, regular, no_dead_strip";
3772+
sectionName = "__TEXT, __swift5_types, regular";
37733773
break;
37743774
case llvm::Triple::ELF:
37753775
case llvm::Triple::Wasm:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %swift -target arm64-apple-macos11.0 -parse-stdlib %s -module-name Swift -emit-ir -o - | %FileCheck %s
2+
3+
public protocol Simple {}
4+
5+
public struct Other : Simple {}
6+
7+
// CHECK: @"\01l_protocols" = private constant
8+
// CHECK-SAME: @"$ss6SimpleMp"
9+
// CHECK-SAME: , section "__TEXT, __swift5_protos, regular"
10+
11+
// CHECK: @"\01l_protocol_conformances" = private constant
12+
// CHECK-SAME: @"$ss5OtherVs6SimplesMc"
13+
// CHECK-SAME: , section "__TEXT, __swift5_proto, regular"
14+
15+
// CHECK: @"\01l_type_metadata_table" = private constant
16+
// CHECK-SAME: @"$ss5OtherVMn"
17+
// CHECK-SAME: , section "__TEXT, __swift5_types, regular"
18+
19+
// CHECK: @llvm.used = appending global [{{.*}} x i8*] [
20+
// CHECK-SAME: @"\01l_protocols"
21+
// CHECK-SAME: @"\01l_protocol_conformances"
22+
// CHECK-SAME: @"\01l_type_metadata_table"
23+
// CHECK-SAME: ], section "llvm.metadata"

0 commit comments

Comments
 (0)