Skip to content

Commit c0af215

Browse files
Merge pull request #16802 from aschwaighofer/swift5_sections
Rename swift sections from swift4 to swift5
2 parents d501b58 + cc7f207 commit c0af215

File tree

16 files changed

+134
-134
lines changed

16 files changed

+134
-134
lines changed

include/swift/Reflection/ReflectionContext.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,14 @@ class ReflectionContext
148148

149149
// The docs say "not all sections may be present." We'll succeed if ANY of
150150
// them are present. Not sure if that's the right thing to do.
151-
auto FieldMd = findSection<FieldSection>(Header, "__swift4_fieldmd");
151+
auto FieldMd = findSection<FieldSection>(Header, "__swift5_fieldmd");
152152
auto AssocTyMd =
153-
findSection<AssociatedTypeSection>(Header, "__swift4_assocty");
153+
findSection<AssociatedTypeSection>(Header, "__swift5_assocty");
154154
auto BuiltinTyMd =
155-
findSection<BuiltinTypeSection>(Header, "__swift4_builtin");
156-
auto CaptureMd = findSection<CaptureSection>(Header, "__swift4_capture");
157-
auto TyperefMd = findSection<GenericSection>(Header, "__swift4_typeref");
158-
auto ReflStrMd = findSection<GenericSection>(Header, "__swift4_reflstr");
155+
findSection<BuiltinTypeSection>(Header, "__swift5_builtin");
156+
auto CaptureMd = findSection<CaptureSection>(Header, "__swift5_capture");
157+
auto TyperefMd = findSection<GenericSection>(Header, "__swift5_typeref");
158+
auto ReflStrMd = findSection<GenericSection>(Header, "__swift5_reflstr");
159159

160160
bool success = FieldMd.second || AssocTyMd.second || BuiltinTyMd.second ||
161161
CaptureMd.second || TyperefMd.second || ReflStrMd.second;

lib/IRGen/GenDecl.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,10 +2751,10 @@ llvm::Constant *IRGenModule::emitSwiftProtocols() {
27512751
StringRef sectionName;
27522752
switch (TargetInfo.OutputObjectFormat) {
27532753
case llvm::Triple::MachO:
2754-
sectionName = "__TEXT, __swift4_protos, regular, no_dead_strip";
2754+
sectionName = "__TEXT, __swift5_protos, regular, no_dead_strip";
27552755
break;
27562756
case llvm::Triple::ELF:
2757-
sectionName = "swift4_protocols";
2757+
sectionName = "swift5_protocols";
27582758
break;
27592759
case llvm::Triple::COFF:
27602760
sectionName = ".sw5prt$B";
@@ -2941,10 +2941,10 @@ llvm::Constant *IRGenModule::emitProtocolConformances() {
29412941
StringRef sectionName;
29422942
switch (TargetInfo.OutputObjectFormat) {
29432943
case llvm::Triple::MachO:
2944-
sectionName = "__TEXT, __swift4_proto, regular, no_dead_strip";
2944+
sectionName = "__TEXT, __swift5_proto, regular, no_dead_strip";
29452945
break;
29462946
case llvm::Triple::ELF:
2947-
sectionName = "swift4_protocol_conformances";
2947+
sectionName = "swift5_protocol_conformances";
29482948
break;
29492949
case llvm::Triple::COFF:
29502950
sectionName = ".sw5prtc$B";
@@ -2968,10 +2968,10 @@ llvm::Constant *IRGenModule::emitTypeMetadataRecords() {
29682968
std::string sectionName;
29692969
switch (TargetInfo.OutputObjectFormat) {
29702970
case llvm::Triple::MachO:
2971-
sectionName = "__TEXT, __swift4_types, regular, no_dead_strip";
2971+
sectionName = "__TEXT, __swift5_types, regular, no_dead_strip";
29722972
break;
29732973
case llvm::Triple::ELF:
2974-
sectionName = "swift4_type_metadata";
2974+
sectionName = "swift5_type_metadata";
29752975
break;
29762976
case llvm::Triple::COFF:
29772977
sectionName = ".sw5tymd$B";
@@ -3035,13 +3035,13 @@ llvm::Constant *IRGenModule::emitFieldDescriptors() {
30353035
std::string sectionName;
30363036
switch (TargetInfo.OutputObjectFormat) {
30373037
case llvm::Triple::MachO:
3038-
sectionName = "__TEXT, __swift4_fieldmd, regular, no_dead_strip";
3038+
sectionName = "__TEXT, __swift5_fieldmd, regular, no_dead_strip";
30393039
break;
30403040
case llvm::Triple::ELF:
3041-
sectionName = "swift4_fieldmd";
3041+
sectionName = "swift5_fieldmd";
30423042
break;
30433043
case llvm::Triple::COFF:
3044-
sectionName = ".swift4_fieldmd";
3044+
sectionName = ".swift5_fieldmd";
30453045
break;
30463046
default:
30473047
llvm_unreachable("Don't know how to emit field records table for "

lib/IRGen/GenReflection.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class ReflectionMetadataBuilder {
247247

248248
// Others, such as capture descriptors, do not have a name.
249249
} else {
250-
var = B.finishAndCreateGlobal("\x01l__swift4_reflection_descriptor",
250+
var = B.finishAndCreateGlobal("\x01l__swift5_reflection_descriptor",
251251
Alignment(4), /*isConstant*/ true,
252252
llvm::GlobalValue::PrivateLinkage);
253253
}
@@ -766,12 +766,12 @@ static std::string getReflectionSectionName(IRGenModule &IGM,
766766
OS << ".sw5" << FourCC << "$B";
767767
break;
768768
case llvm::Triple::ELF:
769-
OS << "swift4_" << LongName;
769+
OS << "swift5_" << LongName;
770770
break;
771771
case llvm::Triple::MachO:
772772
assert(LongName.size() <= 7 &&
773773
"Mach-O section name length must be <= 16 characters");
774-
OS << "__TEXT,__swift4_" << LongName << ", regular, no_dead_strip";
774+
OS << "__TEXT,__swift5_" << LongName << ", regular, no_dead_strip";
775775
break;
776776
case llvm::Triple::Wasm:
777777
llvm_unreachable("web assembly object format is not supported.");

stdlib/private/SwiftReflectionTest/SwiftReflectionTest.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ internal func getSectionInfo(_ name: String,
107107
///
108108
/// An image of interest must have the following sections in the __DATA
109109
/// segment:
110-
/// - __swift4_fieldmd
111-
/// - __swift4_assocty
112-
/// - __swift4_builtin
113-
/// - __swift4_capture
114-
/// - __swift4_typeref
115-
/// - __swift4_reflstr (optional, may have been stripped out)
110+
/// - __swift5_fieldmd
111+
/// - __swift5_assocty
112+
/// - __swift5_builtin
113+
/// - __swift5_capture
114+
/// - __swift5_typeref
115+
/// - __swift5_reflstr (optional, may have been stripped out)
116116
///
117117
/// - Parameter i: The index of the loaded image as reported by Dyld.
118118
/// - Returns: A `ReflectionInfo` containing the locations of all of the
@@ -123,12 +123,12 @@ internal func getReflectionInfoForImage(atIndex i: UInt32) -> ReflectionInfo? {
123123
to: UnsafePointer<MachHeader>.self)
124124

125125
let imageName = _dyld_get_image_name(i)!
126-
let fieldmd = getSectionInfo("__swift4_fieldmd", header)
127-
let assocty = getSectionInfo("__swift4_assocty", header)
128-
let builtin = getSectionInfo("__swift4_builtin", header)
129-
let capture = getSectionInfo("__swift4_capture", header)
130-
let typeref = getSectionInfo("__swift4_typeref", header)
131-
let reflstr = getSectionInfo("__swift4_reflstr", header)
126+
let fieldmd = getSectionInfo("__swift5_fieldmd", header)
127+
let assocty = getSectionInfo("__swift5_assocty", header)
128+
let builtin = getSectionInfo("__swift5_builtin", header)
129+
let capture = getSectionInfo("__swift5_capture", header)
130+
let typeref = getSectionInfo("__swift5_typeref", header)
131+
let reflstr = getSectionInfo("__swift5_reflstr", header)
132132
return ReflectionInfo(imageName: String(validatingUTF8: imageName)!,
133133
fieldmd: fieldmd,
134134
assocty: assocty,

stdlib/public/runtime/ImageInspectionCOFF.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void swift::initializeProtocolLookup() {
4141
const swift::MetadataSections *sections = registered;
4242
while (true) {
4343
const swift::MetadataSections::Range &protocols =
44-
sections->swift4_protocols;
44+
sections->swift5_protocols;
4545
if (protocols.length)
4646
addImageProtocolsBlockCallback(reinterpret_cast<void *>(protocols.start),
4747
protocols.length);
@@ -56,7 +56,7 @@ void swift::initializeProtocolConformanceLookup() {
5656
const swift::MetadataSections *sections = registered;
5757
while (true) {
5858
const swift::MetadataSections::Range &conformances =
59-
sections->swift4_protocol_conformances;
59+
sections->swift5_protocol_conformances;
6060
if (conformances.length)
6161
addImageProtocolConformanceBlockCallback(reinterpret_cast<void *>(conformances.start),
6262
conformances.length);
@@ -71,7 +71,7 @@ void swift::initializeTypeMetadataRecordLookup() {
7171
const swift::MetadataSections *sections = registered;
7272
while (true) {
7373
const swift::MetadataSections::Range &type_metadata =
74-
sections->swift4_type_metadata;
74+
sections->swift5_type_metadata;
7575
if (type_metadata.length)
7676
addImageTypeMetadataRecordBlockCallback(reinterpret_cast<void *>(type_metadata.start),
7777
type_metadata.length);
@@ -85,7 +85,7 @@ void swift::initializeTypeMetadataRecordLookup() {
8585
void swift::initializeTypeFieldLookup() {
8686
const swift::MetadataSections *sections = registered;
8787
while (true) {
88-
const swift::MetadataSections::Range &fields = sections->swift4_fieldmd;
88+
const swift::MetadataSections::Range &fields = sections->swift5_fieldmd;
8989
if (fields.length)
9090
addImageTypeFieldDescriptorBlockCallback(
9191
reinterpret_cast<void *>(fields.start), fields.length);
@@ -103,20 +103,20 @@ void swift_addNewDSOImage(const void *addr) {
103103

104104
record(sections);
105105

106-
const auto &protocols_section = sections->swift4_protocols;
106+
const auto &protocols_section = sections->swift5_protocols;
107107
const void *protocols =
108108
reinterpret_cast<void *>(protocols_section.start);
109109
if (protocols_section.length)
110110
addImageProtocolsBlockCallback(protocols, protocols_section.length);
111111

112-
const auto &protocol_conformances = sections->swift4_protocol_conformances;
112+
const auto &protocol_conformances = sections->swift5_protocol_conformances;
113113
const void *conformances =
114114
reinterpret_cast<void *>(protocol_conformances.start);
115115
if (protocol_conformances.length)
116116
addImageProtocolConformanceBlockCallback(conformances,
117117
protocol_conformances.length);
118118

119-
const auto &type_metadata = sections->swift4_type_metadata;
119+
const auto &type_metadata = sections->swift5_type_metadata;
120120
const void *metadata = reinterpret_cast<void *>(type_metadata.start);
121121
if (type_metadata.length)
122122
addImageTypeMetadataRecordBlockCallback(metadata, type_metadata.length);

stdlib/public/runtime/ImageInspectionCOFF.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ struct MetadataSections {
4545
size_t length;
4646
};
4747

48-
Range swift4_protocols;
49-
Range swift4_protocol_conformances;
50-
Range swift4_type_metadata;
51-
Range swift4_typeref;
52-
Range swift4_reflstr;
53-
Range swift4_fieldmd;
54-
Range swift4_assocty;
48+
Range swift5_protocols;
49+
Range swift5_protocol_conformances;
50+
Range swift5_type_metadata;
51+
Range swift5_typeref;
52+
Range swift5_reflstr;
53+
Range swift5_fieldmd;
54+
Range swift5_assocty;
5555
};
5656
} // namespace swift
5757

stdlib/public/runtime/ImageInspectionELF.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void swift::initializeProtocolLookup() {
4646
const swift::MetadataSections *sections = registered;
4747
while (true) {
4848
const swift::MetadataSections::Range &protocols =
49-
sections->swift4_protocols;
49+
sections->swift5_protocols;
5050
if (protocols.length)
5151
addImageProtocolsBlockCallback(reinterpret_cast<void *>(protocols.start),
5252
protocols.length);
@@ -60,7 +60,7 @@ void swift::initializeProtocolConformanceLookup() {
6060
const swift::MetadataSections *sections = registered;
6161
while (true) {
6262
const swift::MetadataSections::Range &conformances =
63-
sections->swift4_protocol_conformances;
63+
sections->swift5_protocol_conformances;
6464
if (conformances.length)
6565
addImageProtocolConformanceBlockCallback(reinterpret_cast<void *>(conformances.start),
6666
conformances.length);
@@ -75,7 +75,7 @@ void swift::initializeTypeMetadataRecordLookup() {
7575
const swift::MetadataSections *sections = registered;
7676
while (true) {
7777
const swift::MetadataSections::Range &type_metadata =
78-
sections->swift4_type_metadata;
78+
sections->swift5_type_metadata;
7979
if (type_metadata.length)
8080
addImageTypeMetadataRecordBlockCallback(reinterpret_cast<void *>(type_metadata.start),
8181
type_metadata.length);
@@ -89,7 +89,7 @@ void swift::initializeTypeMetadataRecordLookup() {
8989
void swift::initializeTypeFieldLookup() {
9090
const swift::MetadataSections *sections = registered;
9191
while (true) {
92-
const swift::MetadataSections::Range &fields = sections->swift4_fieldmd;
92+
const swift::MetadataSections::Range &fields = sections->swift5_fieldmd;
9393
if (fields.length)
9494
addImageTypeFieldDescriptorBlockCallback(
9595
reinterpret_cast<void *>(fields.start), fields.length);
@@ -111,20 +111,20 @@ void swift_addNewDSOImage(const void *addr) {
111111

112112
record(sections);
113113

114-
const auto &protocols_section = sections->swift4_protocols;
114+
const auto &protocols_section = sections->swift5_protocols;
115115
const void *protocols =
116116
reinterpret_cast<void *>(protocols_section.start);
117117
if (protocols_section.length)
118118
addImageProtocolsBlockCallback(protocols, protocols_section.length);
119119

120-
const auto &protocol_conformances = sections->swift4_protocol_conformances;
120+
const auto &protocol_conformances = sections->swift5_protocol_conformances;
121121
const void *conformances =
122122
reinterpret_cast<void *>(protocol_conformances.start);
123123
if (protocol_conformances.length)
124124
addImageProtocolConformanceBlockCallback(conformances,
125125
protocol_conformances.length);
126126

127-
const auto &type_metadata = sections->swift4_type_metadata;
127+
const auto &type_metadata = sections->swift5_type_metadata;
128128
const void *metadata = reinterpret_cast<void *>(type_metadata.start);
129129
if (type_metadata.length)
130130
addImageTypeMetadataRecordBlockCallback(metadata, type_metadata.length);

stdlib/public/runtime/ImageInspectionELF.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ struct MetadataSections {
4545
size_t length;
4646
};
4747

48-
Range swift4_protocols;
49-
Range swift4_protocol_conformances;
50-
Range swift4_type_metadata;
51-
Range swift4_typeref;
52-
Range swift4_reflstr;
53-
Range swift4_fieldmd;
54-
Range swift4_assocty;
48+
Range swift5_protocols;
49+
Range swift5_protocol_conformances;
50+
Range swift5_type_metadata;
51+
Range swift5_typeref;
52+
Range swift5_reflstr;
53+
Range swift5_fieldmd;
54+
Range swift5_assocty;
5555
};
5656
} // namespace swift
5757

stdlib/public/runtime/ImageInspectionMachO.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ using namespace swift;
3131
namespace {
3232
/// The Mach-O section name for the section containing protocol descriptor
3333
/// references. This lives within SEG_TEXT.
34-
constexpr const char ProtocolsSection[] = "__swift4_protos";
34+
constexpr const char ProtocolsSection[] = "__swift5_protos";
3535
/// The Mach-O section name for the section containing protocol conformances.
3636
/// This lives within SEG_TEXT.
37-
constexpr const char ProtocolConformancesSection[] = "__swift4_proto";
37+
constexpr const char ProtocolConformancesSection[] = "__swift5_proto";
3838
/// The Mach-O section name for the section containing type references.
3939
/// This lives within SEG_TEXT.
40-
constexpr const char TypeMetadataRecordSection[] = "__swift4_types";
40+
constexpr const char TypeMetadataRecordSection[] = "__swift5_types";
4141
/// The Mach-O section name for the section containing type field references.
4242
/// This lives within SEG_TEXT.
43-
constexpr const char TypeFieldRecordSection[] = "__swift4_fieldmd";
43+
constexpr const char TypeFieldRecordSection[] = "__swift5_fieldmd";
4444

4545
#if __POINTER_WIDTH__ == 64
4646
using mach_header_platform = mach_header_64;
@@ -57,7 +57,7 @@ void addImageCallback(const mach_header *mh, intptr_t vmaddr_slide) {
5757
assert(mh->magic == MH_MAGIC_64 && "loaded non-64-bit image?!");
5858
#endif
5959

60-
// Look for a __swift4_proto section.
60+
// Look for a __swift5_proto section.
6161
unsigned long size;
6262
const uint8_t *section =
6363
getsectiondata(reinterpret_cast<const mach_header_platform *>(mh),

stdlib/public/runtime/SwiftRT-ELF.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
__attribute__((__visibility__("hidden"))) extern const char __stop_##name;
2525

2626
extern "C" {
27-
DECLARE_SWIFT_SECTION(swift4_protocols)
28-
DECLARE_SWIFT_SECTION(swift4_protocol_conformances)
29-
DECLARE_SWIFT_SECTION(swift4_type_metadata)
30-
31-
DECLARE_SWIFT_SECTION(swift4_typeref)
32-
DECLARE_SWIFT_SECTION(swift4_reflstr)
33-
DECLARE_SWIFT_SECTION(swift4_fieldmd)
34-
DECLARE_SWIFT_SECTION(swift4_assocty)
27+
DECLARE_SWIFT_SECTION(swift5_protocols)
28+
DECLARE_SWIFT_SECTION(swift5_protocol_conformances)
29+
DECLARE_SWIFT_SECTION(swift5_type_metadata)
30+
31+
DECLARE_SWIFT_SECTION(swift5_typeref)
32+
DECLARE_SWIFT_SECTION(swift5_reflstr)
33+
DECLARE_SWIFT_SECTION(swift5_fieldmd)
34+
DECLARE_SWIFT_SECTION(swift5_assocty)
3535
}
3636

3737
#undef DECLARE_SWIFT_SECTION
@@ -53,14 +53,14 @@ static void swift_image_constructor() {
5353
nullptr,
5454
nullptr,
5555

56-
SWIFT_SECTION_RANGE(swift4_protocols),
57-
SWIFT_SECTION_RANGE(swift4_protocol_conformances),
58-
SWIFT_SECTION_RANGE(swift4_type_metadata),
56+
SWIFT_SECTION_RANGE(swift5_protocols),
57+
SWIFT_SECTION_RANGE(swift5_protocol_conformances),
58+
SWIFT_SECTION_RANGE(swift5_type_metadata),
5959

60-
SWIFT_SECTION_RANGE(swift4_typeref),
61-
SWIFT_SECTION_RANGE(swift4_reflstr),
62-
SWIFT_SECTION_RANGE(swift4_fieldmd),
63-
SWIFT_SECTION_RANGE(swift4_assocty),
60+
SWIFT_SECTION_RANGE(swift5_typeref),
61+
SWIFT_SECTION_RANGE(swift5_reflstr),
62+
SWIFT_SECTION_RANGE(swift5_fieldmd),
63+
SWIFT_SECTION_RANGE(swift5_assocty),
6464
};
6565

6666
#undef SWIFT_SECTION_RANGE

test/IRGen/closure.swift

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

55
// -- partial_apply context metadata
66

7-
// CHECK: [[METADATA:@.*]] = private constant %swift.full_boxmetadata { void (%swift.refcounted*)* @objectdestroy, i8** null, %swift.type { i64 64 }, i32 16, i8* bitcast ({ i32, i32, i32, i32 }* @"\01l__swift4_reflection_descriptor" to i8*) }
7+
// CHECK: [[METADATA:@.*]] = private constant %swift.full_boxmetadata { void (%swift.refcounted*)* @objectdestroy, i8** null, %swift.type { i64 64 }, i32 16, i8* bitcast ({ i32, i32, i32, i32 }* @"\01l__swift5_reflection_descriptor" to i8*) }
88

99
func a(i i: Int) -> (Int) -> Int {
1010
return { x in i }

0 commit comments

Comments
 (0)