Skip to content

Rename swift sections from swift4 to swift5 #16802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions include/swift/Reflection/ReflectionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ class ReflectionContext

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

bool success = FieldMd.second || AssocTyMd.second || BuiltinTyMd.second ||
CaptureMd.second || TyperefMd.second || ReflStrMd.second;
Expand Down
18 changes: 9 additions & 9 deletions lib/IRGen/GenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2751,10 +2751,10 @@ llvm::Constant *IRGenModule::emitSwiftProtocols() {
StringRef sectionName;
switch (TargetInfo.OutputObjectFormat) {
case llvm::Triple::MachO:
sectionName = "__TEXT, __swift4_protos, regular, no_dead_strip";
sectionName = "__TEXT, __swift5_protos, regular, no_dead_strip";
break;
case llvm::Triple::ELF:
sectionName = "swift4_protocols";
sectionName = "swift5_protocols";
break;
case llvm::Triple::COFF:
sectionName = ".sw5prt$B";
Expand Down Expand Up @@ -2941,10 +2941,10 @@ llvm::Constant *IRGenModule::emitProtocolConformances() {
StringRef sectionName;
switch (TargetInfo.OutputObjectFormat) {
case llvm::Triple::MachO:
sectionName = "__TEXT, __swift4_proto, regular, no_dead_strip";
sectionName = "__TEXT, __swift5_proto, regular, no_dead_strip";
break;
case llvm::Triple::ELF:
sectionName = "swift4_protocol_conformances";
sectionName = "swift5_protocol_conformances";
break;
case llvm::Triple::COFF:
sectionName = ".sw5prtc$B";
Expand All @@ -2968,10 +2968,10 @@ llvm::Constant *IRGenModule::emitTypeMetadataRecords() {
std::string sectionName;
switch (TargetInfo.OutputObjectFormat) {
case llvm::Triple::MachO:
sectionName = "__TEXT, __swift4_types, regular, no_dead_strip";
sectionName = "__TEXT, __swift5_types, regular, no_dead_strip";
break;
case llvm::Triple::ELF:
sectionName = "swift4_type_metadata";
sectionName = "swift5_type_metadata";
break;
case llvm::Triple::COFF:
sectionName = ".sw5tymd$B";
Expand Down Expand Up @@ -3035,13 +3035,13 @@ llvm::Constant *IRGenModule::emitFieldDescriptors() {
std::string sectionName;
switch (TargetInfo.OutputObjectFormat) {
case llvm::Triple::MachO:
sectionName = "__TEXT, __swift4_fieldmd, regular, no_dead_strip";
sectionName = "__TEXT, __swift5_fieldmd, regular, no_dead_strip";
break;
case llvm::Triple::ELF:
sectionName = "swift4_fieldmd";
sectionName = "swift5_fieldmd";
break;
case llvm::Triple::COFF:
sectionName = ".swift4_fieldmd";
sectionName = ".swift5_fieldmd";
break;
default:
llvm_unreachable("Don't know how to emit field records table for "
Expand Down
6 changes: 3 additions & 3 deletions lib/IRGen/GenReflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class ReflectionMetadataBuilder {

// Others, such as capture descriptors, do not have a name.
} else {
var = B.finishAndCreateGlobal("\x01l__swift4_reflection_descriptor",
var = B.finishAndCreateGlobal("\x01l__swift5_reflection_descriptor",
Alignment(4), /*isConstant*/ true,
llvm::GlobalValue::PrivateLinkage);
}
Expand Down Expand Up @@ -766,12 +766,12 @@ static std::string getReflectionSectionName(IRGenModule &IGM,
OS << ".sw5" << FourCC << "$B";
break;
case llvm::Triple::ELF:
OS << "swift4_" << LongName;
OS << "swift5_" << LongName;
break;
case llvm::Triple::MachO:
assert(LongName.size() <= 7 &&
"Mach-O section name length must be <= 16 characters");
OS << "__TEXT,__swift4_" << LongName << ", regular, no_dead_strip";
OS << "__TEXT,__swift5_" << LongName << ", regular, no_dead_strip";
break;
case llvm::Triple::Wasm:
llvm_unreachable("web assembly object format is not supported.");
Expand Down
24 changes: 12 additions & 12 deletions stdlib/private/SwiftReflectionTest/SwiftReflectionTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ internal func getSectionInfo(_ name: String,
///
/// An image of interest must have the following sections in the __DATA
/// segment:
/// - __swift4_fieldmd
/// - __swift4_assocty
/// - __swift4_builtin
/// - __swift4_capture
/// - __swift4_typeref
/// - __swift4_reflstr (optional, may have been stripped out)
/// - __swift5_fieldmd
/// - __swift5_assocty
/// - __swift5_builtin
/// - __swift5_capture
/// - __swift5_typeref
/// - __swift5_reflstr (optional, may have been stripped out)
///
/// - Parameter i: The index of the loaded image as reported by Dyld.
/// - Returns: A `ReflectionInfo` containing the locations of all of the
Expand All @@ -123,12 +123,12 @@ internal func getReflectionInfoForImage(atIndex i: UInt32) -> ReflectionInfo? {
to: UnsafePointer<MachHeader>.self)

let imageName = _dyld_get_image_name(i)!
let fieldmd = getSectionInfo("__swift4_fieldmd", header)
let assocty = getSectionInfo("__swift4_assocty", header)
let builtin = getSectionInfo("__swift4_builtin", header)
let capture = getSectionInfo("__swift4_capture", header)
let typeref = getSectionInfo("__swift4_typeref", header)
let reflstr = getSectionInfo("__swift4_reflstr", header)
let fieldmd = getSectionInfo("__swift5_fieldmd", header)
let assocty = getSectionInfo("__swift5_assocty", header)
let builtin = getSectionInfo("__swift5_builtin", header)
let capture = getSectionInfo("__swift5_capture", header)
let typeref = getSectionInfo("__swift5_typeref", header)
let reflstr = getSectionInfo("__swift5_reflstr", header)
return ReflectionInfo(imageName: String(validatingUTF8: imageName)!,
fieldmd: fieldmd,
assocty: assocty,
Expand Down
14 changes: 7 additions & 7 deletions stdlib/public/runtime/ImageInspectionCOFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void swift::initializeProtocolLookup() {
const swift::MetadataSections *sections = registered;
while (true) {
const swift::MetadataSections::Range &protocols =
sections->swift4_protocols;
sections->swift5_protocols;
if (protocols.length)
addImageProtocolsBlockCallback(reinterpret_cast<void *>(protocols.start),
protocols.length);
Expand All @@ -56,7 +56,7 @@ void swift::initializeProtocolConformanceLookup() {
const swift::MetadataSections *sections = registered;
while (true) {
const swift::MetadataSections::Range &conformances =
sections->swift4_protocol_conformances;
sections->swift5_protocol_conformances;
if (conformances.length)
addImageProtocolConformanceBlockCallback(reinterpret_cast<void *>(conformances.start),
conformances.length);
Expand All @@ -71,7 +71,7 @@ void swift::initializeTypeMetadataRecordLookup() {
const swift::MetadataSections *sections = registered;
while (true) {
const swift::MetadataSections::Range &type_metadata =
sections->swift4_type_metadata;
sections->swift5_type_metadata;
if (type_metadata.length)
addImageTypeMetadataRecordBlockCallback(reinterpret_cast<void *>(type_metadata.start),
type_metadata.length);
Expand All @@ -85,7 +85,7 @@ void swift::initializeTypeMetadataRecordLookup() {
void swift::initializeTypeFieldLookup() {
const swift::MetadataSections *sections = registered;
while (true) {
const swift::MetadataSections::Range &fields = sections->swift4_fieldmd;
const swift::MetadataSections::Range &fields = sections->swift5_fieldmd;
if (fields.length)
addImageTypeFieldDescriptorBlockCallback(
reinterpret_cast<void *>(fields.start), fields.length);
Expand All @@ -103,20 +103,20 @@ void swift_addNewDSOImage(const void *addr) {

record(sections);

const auto &protocols_section = sections->swift4_protocols;
const auto &protocols_section = sections->swift5_protocols;
const void *protocols =
reinterpret_cast<void *>(protocols_section.start);
if (protocols_section.length)
addImageProtocolsBlockCallback(protocols, protocols_section.length);

const auto &protocol_conformances = sections->swift4_protocol_conformances;
const auto &protocol_conformances = sections->swift5_protocol_conformances;
const void *conformances =
reinterpret_cast<void *>(protocol_conformances.start);
if (protocol_conformances.length)
addImageProtocolConformanceBlockCallback(conformances,
protocol_conformances.length);

const auto &type_metadata = sections->swift4_type_metadata;
const auto &type_metadata = sections->swift5_type_metadata;
const void *metadata = reinterpret_cast<void *>(type_metadata.start);
if (type_metadata.length)
addImageTypeMetadataRecordBlockCallback(metadata, type_metadata.length);
Expand Down
14 changes: 7 additions & 7 deletions stdlib/public/runtime/ImageInspectionCOFF.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ struct MetadataSections {
size_t length;
};

Range swift4_protocols;
Range swift4_protocol_conformances;
Range swift4_type_metadata;
Range swift4_typeref;
Range swift4_reflstr;
Range swift4_fieldmd;
Range swift4_assocty;
Range swift5_protocols;
Range swift5_protocol_conformances;
Range swift5_type_metadata;
Range swift5_typeref;
Range swift5_reflstr;
Range swift5_fieldmd;
Range swift5_assocty;
};
} // namespace swift

Expand Down
14 changes: 7 additions & 7 deletions stdlib/public/runtime/ImageInspectionELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void swift::initializeProtocolLookup() {
const swift::MetadataSections *sections = registered;
while (true) {
const swift::MetadataSections::Range &protocols =
sections->swift4_protocols;
sections->swift5_protocols;
if (protocols.length)
addImageProtocolsBlockCallback(reinterpret_cast<void *>(protocols.start),
protocols.length);
Expand All @@ -60,7 +60,7 @@ void swift::initializeProtocolConformanceLookup() {
const swift::MetadataSections *sections = registered;
while (true) {
const swift::MetadataSections::Range &conformances =
sections->swift4_protocol_conformances;
sections->swift5_protocol_conformances;
if (conformances.length)
addImageProtocolConformanceBlockCallback(reinterpret_cast<void *>(conformances.start),
conformances.length);
Expand All @@ -75,7 +75,7 @@ void swift::initializeTypeMetadataRecordLookup() {
const swift::MetadataSections *sections = registered;
while (true) {
const swift::MetadataSections::Range &type_metadata =
sections->swift4_type_metadata;
sections->swift5_type_metadata;
if (type_metadata.length)
addImageTypeMetadataRecordBlockCallback(reinterpret_cast<void *>(type_metadata.start),
type_metadata.length);
Expand All @@ -89,7 +89,7 @@ void swift::initializeTypeMetadataRecordLookup() {
void swift::initializeTypeFieldLookup() {
const swift::MetadataSections *sections = registered;
while (true) {
const swift::MetadataSections::Range &fields = sections->swift4_fieldmd;
const swift::MetadataSections::Range &fields = sections->swift5_fieldmd;
if (fields.length)
addImageTypeFieldDescriptorBlockCallback(
reinterpret_cast<void *>(fields.start), fields.length);
Expand All @@ -111,20 +111,20 @@ void swift_addNewDSOImage(const void *addr) {

record(sections);

const auto &protocols_section = sections->swift4_protocols;
const auto &protocols_section = sections->swift5_protocols;
const void *protocols =
reinterpret_cast<void *>(protocols_section.start);
if (protocols_section.length)
addImageProtocolsBlockCallback(protocols, protocols_section.length);

const auto &protocol_conformances = sections->swift4_protocol_conformances;
const auto &protocol_conformances = sections->swift5_protocol_conformances;
const void *conformances =
reinterpret_cast<void *>(protocol_conformances.start);
if (protocol_conformances.length)
addImageProtocolConformanceBlockCallback(conformances,
protocol_conformances.length);

const auto &type_metadata = sections->swift4_type_metadata;
const auto &type_metadata = sections->swift5_type_metadata;
const void *metadata = reinterpret_cast<void *>(type_metadata.start);
if (type_metadata.length)
addImageTypeMetadataRecordBlockCallback(metadata, type_metadata.length);
Expand Down
14 changes: 7 additions & 7 deletions stdlib/public/runtime/ImageInspectionELF.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ struct MetadataSections {
size_t length;
};

Range swift4_protocols;
Range swift4_protocol_conformances;
Range swift4_type_metadata;
Range swift4_typeref;
Range swift4_reflstr;
Range swift4_fieldmd;
Range swift4_assocty;
Range swift5_protocols;
Range swift5_protocol_conformances;
Range swift5_type_metadata;
Range swift5_typeref;
Range swift5_reflstr;
Range swift5_fieldmd;
Range swift5_assocty;
};
} // namespace swift

Expand Down
10 changes: 5 additions & 5 deletions stdlib/public/runtime/ImageInspectionMachO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ using namespace swift;
namespace {
/// The Mach-O section name for the section containing protocol descriptor
/// references. This lives within SEG_TEXT.
constexpr const char ProtocolsSection[] = "__swift4_protos";
constexpr const char ProtocolsSection[] = "__swift5_protos";
/// The Mach-O section name for the section containing protocol conformances.
/// This lives within SEG_TEXT.
constexpr const char ProtocolConformancesSection[] = "__swift4_proto";
constexpr const char ProtocolConformancesSection[] = "__swift5_proto";
/// The Mach-O section name for the section containing type references.
/// This lives within SEG_TEXT.
constexpr const char TypeMetadataRecordSection[] = "__swift4_types";
constexpr const char TypeMetadataRecordSection[] = "__swift5_types";
/// The Mach-O section name for the section containing type field references.
/// This lives within SEG_TEXT.
constexpr const char TypeFieldRecordSection[] = "__swift4_fieldmd";
constexpr const char TypeFieldRecordSection[] = "__swift5_fieldmd";

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

// Look for a __swift4_proto section.
// Look for a __swift5_proto section.
unsigned long size;
const uint8_t *section =
getsectiondata(reinterpret_cast<const mach_header_platform *>(mh),
Expand Down
30 changes: 15 additions & 15 deletions stdlib/public/runtime/SwiftRT-ELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
__attribute__((__visibility__("hidden"))) extern const char __stop_##name;

extern "C" {
DECLARE_SWIFT_SECTION(swift4_protocols)
DECLARE_SWIFT_SECTION(swift4_protocol_conformances)
DECLARE_SWIFT_SECTION(swift4_type_metadata)

DECLARE_SWIFT_SECTION(swift4_typeref)
DECLARE_SWIFT_SECTION(swift4_reflstr)
DECLARE_SWIFT_SECTION(swift4_fieldmd)
DECLARE_SWIFT_SECTION(swift4_assocty)
DECLARE_SWIFT_SECTION(swift5_protocols)
DECLARE_SWIFT_SECTION(swift5_protocol_conformances)
DECLARE_SWIFT_SECTION(swift5_type_metadata)

DECLARE_SWIFT_SECTION(swift5_typeref)
DECLARE_SWIFT_SECTION(swift5_reflstr)
DECLARE_SWIFT_SECTION(swift5_fieldmd)
DECLARE_SWIFT_SECTION(swift5_assocty)
}

#undef DECLARE_SWIFT_SECTION
Expand All @@ -53,14 +53,14 @@ static void swift_image_constructor() {
nullptr,
nullptr,

SWIFT_SECTION_RANGE(swift4_protocols),
SWIFT_SECTION_RANGE(swift4_protocol_conformances),
SWIFT_SECTION_RANGE(swift4_type_metadata),
SWIFT_SECTION_RANGE(swift5_protocols),
SWIFT_SECTION_RANGE(swift5_protocol_conformances),
SWIFT_SECTION_RANGE(swift5_type_metadata),

SWIFT_SECTION_RANGE(swift4_typeref),
SWIFT_SECTION_RANGE(swift4_reflstr),
SWIFT_SECTION_RANGE(swift4_fieldmd),
SWIFT_SECTION_RANGE(swift4_assocty),
SWIFT_SECTION_RANGE(swift5_typeref),
SWIFT_SECTION_RANGE(swift5_reflstr),
SWIFT_SECTION_RANGE(swift5_fieldmd),
SWIFT_SECTION_RANGE(swift5_assocty),
};

#undef SWIFT_SECTION_RANGE
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/closure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// -- partial_apply context metadata

// 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*) }
// 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*) }

func a(i i: Int) -> (Int) -> Int {
return { x in i }
Expand Down
Loading