@@ -297,7 +297,7 @@ class ObjCProtocolInitializerVisitor
297297 // protocol. If so, use it.
298298 SmallString<32 > buf;
299299 auto protocolName = IGM.getAddrOfGlobalString (
300- proto->getObjCRuntimeName (buf), IRGenModule::ObjCClassNameSectionName );
300+ proto->getObjCRuntimeName (buf), CStringSectionType::ObjCClassName );
301301
302302 auto existing = Builder.CreateCall (objc_getProtocol, protocolName);
303303 auto isNull = Builder.CreateICmpEQ (existing,
@@ -4240,10 +4240,10 @@ static TypeEntityReference
42404240getObjCClassByNameReference (IRGenModule &IGM, ClassDecl *cls) {
42414241 auto kind = TypeReferenceKind::DirectObjCClassName;
42424242 SmallString<64 > objcRuntimeNameBuffer;
4243- auto ref = IGM. getAddrOfGlobalString (
4244- cls->getObjCRuntimeName (objcRuntimeNameBuffer),
4245- /* willBeRelativelyAddressed= */ true ,
4246- /* useOSLogSection =*/ false , IRGenModule::ObjCClassNameSectionName );
4243+ auto ref =
4244+ IGM. getAddrOfGlobalString ( cls->getObjCRuntimeName (objcRuntimeNameBuffer),
4245+ CStringSectionType::ObjCClassName ,
4246+ /* willBeRelativelyAddressed =*/ true );
42474247
42484248 return TypeEntityReference (kind, ref);
42494249}
@@ -4800,9 +4800,9 @@ void IRGenModule::emitAccessibleFunction(StringRef sectionName,
48004800
48014801 // -- Field: Name (record name)
48024802 {
4803- llvm::Constant *name =
4804- getAddrOfGlobalString ( func.getFunctionName (),
4805- /* willBeRelativelyAddressed=*/ true );
4803+ llvm::Constant *name = getAddrOfGlobalString (
4804+ func.getFunctionName (), CStringSectionType::Default ,
4805+ /* willBeRelativelyAddressed=*/ true );
48064806 fields.addRelativeAddress (name);
48074807 }
48084808
@@ -6016,12 +6016,6 @@ Address IRGenFunction::createAlloca(llvm::Type *type,
60166016 return Address (alloca, type, alignment);
60176017}
60186018
6019- llvm::Constant *IRGenModule::getAddrOfGlobalString (StringRef data,
6020- const char *sectionName) {
6021- return getAddrOfGlobalString (data, /* willBeRelativelyAddressed=*/ false ,
6022- /* useOSLogSection=*/ false , sectionName);
6023- }
6024-
60256019// / Get or create a global string constant.
60266020// /
60276021// / \returns an i8* with a null terminator; note that embedded nulls
@@ -6030,15 +6024,35 @@ llvm::Constant *IRGenModule::getAddrOfGlobalString(StringRef data,
60306024// / FIXME: willBeRelativelyAddressed is only needed to work around an ld64 bug
60316025// / resolving relative references to coalesceable symbols.
60326026// / It should be removed when fixed. rdar://problem/22674524
6033- llvm::Constant *IRGenModule::getAddrOfGlobalString (
6034- StringRef data, bool willBeRelativelyAddressed, bool useOSLogSection,
6035- StringRef sectionName) {
6036- useOSLogSection = useOSLogSection &&
6037- TargetInfo.OutputObjectFormat == llvm::Triple::MachO;
6027+ llvm::Constant *
6028+ IRGenModule::getAddrOfGlobalString (StringRef data, CStringSectionType type,
6029+ bool willBeRelativelyAddressed) {
6030+ if (TargetInfo.OutputObjectFormat != llvm::Triple::MachO)
6031+ type = CStringSectionType::Default;
6032+ StringRef sectionName;
6033+ switch (type) {
6034+ case CStringSectionType::Default:
6035+ sectionName = " " ;
6036+ break ;
6037+ case CStringSectionType::ObjCClassName:
6038+ sectionName = ObjCClassNameSectionName;
6039+ break ;
6040+ case CStringSectionType::ObjCMethodName:
6041+ sectionName = ObjCMethodNameSectionName;
6042+ break ;
6043+ case CStringSectionType::ObjCMethodType:
6044+ sectionName = ObjCMethodTypeSectionName;
6045+ break ;
6046+ case CStringSectionType::ObjCPropertyName:
6047+ sectionName = ObjCPropertyNameSectionName;
6048+ break ;
6049+ case CStringSectionType::OSLogString:
6050+ sectionName = OSLogStringSectionName;
6051+ break ;
6052+ }
60386053
60396054 // Check whether this string already exists.
6040- auto &entry = useOSLogSection ? GlobalOSLogStrings[data] :
6041- GlobalStrings[data];
6055+ auto &entry = GlobalStrings[type][data];
60426056
60436057 if (entry.second ) {
60446058 // FIXME: Clear unnamed_addr if the global will be relative referenced
@@ -6060,9 +6074,6 @@ llvm::Constant *IRGenModule::getAddrOfGlobalString(
60606074 (llvm::Twine (" .nul" ) + llvm::Twine (i)).toVector (name);
60616075 }
60626076
6063- sectionName =
6064- useOSLogSection ? " __TEXT,__oslogstring,cstring_literals" : sectionName;
6065-
60666077 entry = createStringConstant (data, willBeRelativelyAddressed,
60676078 sectionName, name);
60686079 return entry.second ;
@@ -6074,9 +6085,11 @@ IRGenModule::getAddrOfGlobalIdentifierString(StringRef data,
60746085 if (Lexer::identifierMustAlwaysBeEscaped (data)) {
60756086 llvm::SmallString<256 > name;
60766087 Mangle::Mangler::appendRawIdentifierForRuntime (data, name);
6077- return getAddrOfGlobalString (name, willBeRelativelyAddressed);
6088+ return getAddrOfGlobalString (name, CStringSectionType::Default,
6089+ willBeRelativelyAddressed);
60786090 }
6079- return getAddrOfGlobalString (data, willBeRelativelyAddressed);
6091+ return getAddrOfGlobalString (data, CStringSectionType::Default,
6092+ willBeRelativelyAddressed);
60806093}
60816094
60826095// / Get or create a global UTF-16 string constant.
0 commit comments