Skip to content

Commit 9cfc0a3

Browse files
committed
use helper function
1 parent 9c86349 commit 9cfc0a3

File tree

6 files changed

+27
-28
lines changed

6 files changed

+27
-28
lines changed

lib/IRGen/GenConstant.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ llvm::Constant *irgen::emitAddrOfConstantString(IRGenModule &IGM,
7979
case StringLiteralInst::Encoding::Bytes:
8080
case StringLiteralInst::Encoding::UTF8:
8181
case StringLiteralInst::Encoding::UTF8_OSLOG:
82-
return IGM.getAddrOfGlobalString(SLI->getValue(), /*sectionName=*/"", false,
83-
useOSLogEncoding);
82+
return IGM.getAddrOfGlobalString(SLI->getValue(), false, useOSLogEncoding);
8483

8584
case StringLiteralInst::Encoding::ObjCSelector:
8685
llvm_unreachable("cannot get the address of an Objective-C selector");

lib/IRGen/GenDecl.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4240,10 +4240,10 @@ static TypeEntityReference
42404240
getObjCClassByNameReference(IRGenModule &IGM, ClassDecl *cls) {
42414241
auto kind = TypeReferenceKind::DirectObjCClassName;
42424242
SmallString<64> objcRuntimeNameBuffer;
4243-
auto ref =
4244-
IGM.getAddrOfGlobalString(cls->getObjCRuntimeName(objcRuntimeNameBuffer),
4245-
IRGenModule::ObjCClassNameSectionName,
4246-
/*willBeRelativelyAddressed=*/true);
4243+
auto ref = IGM.getAddrOfGlobalString(
4244+
cls->getObjCRuntimeName(objcRuntimeNameBuffer),
4245+
/*willBeRelativelyAddressed=*/true,
4246+
/*useOSLogSection=*/false, IRGenModule::ObjCClassNameSectionName);
42474247

42484248
return TypeEntityReference(kind, ref);
42494249
}
@@ -4801,7 +4801,7 @@ void IRGenModule::emitAccessibleFunction(StringRef sectionName,
48014801
// -- Field: Name (record name)
48024802
{
48034803
llvm::Constant *name =
4804-
getAddrOfGlobalString(func.getFunctionName(), /*sectionName=*/"",
4804+
getAddrOfGlobalString(func.getFunctionName(),
48054805
/*willBeRelativelyAddressed=*/true);
48064806
fields.addRelativeAddress(name);
48074807
}
@@ -6016,6 +6016,12 @@ 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+
60196025
/// Get or create a global string constant.
60206026
///
60216027
/// \returns an i8* with a null terminator; note that embedded nulls
@@ -6024,10 +6030,9 @@ Address IRGenFunction::createAlloca(llvm::Type *type,
60246030
/// FIXME: willBeRelativelyAddressed is only needed to work around an ld64 bug
60256031
/// resolving relative references to coalesceable symbols.
60266032
/// It should be removed when fixed. rdar://problem/22674524
6027-
llvm::Constant *
6028-
IRGenModule::getAddrOfGlobalString(StringRef data, StringRef sectionName,
6029-
bool willBeRelativelyAddressed,
6030-
bool useOSLogSection) {
6033+
llvm::Constant *IRGenModule::getAddrOfGlobalString(
6034+
StringRef data, bool willBeRelativelyAddressed, bool useOSLogSection,
6035+
StringRef sectionName) {
60316036
useOSLogSection = useOSLogSection &&
60326037
TargetInfo.OutputObjectFormat == llvm::Triple::MachO;
60336038

@@ -6069,11 +6074,9 @@ IRGenModule::getAddrOfGlobalIdentifierString(StringRef data,
60696074
if (Lexer::identifierMustAlwaysBeEscaped(data)) {
60706075
llvm::SmallString<256> name;
60716076
Mangle::Mangler::appendRawIdentifierForRuntime(data, name);
6072-
return getAddrOfGlobalString(name, /*sectionName=*/"",
6073-
willBeRelativelyAddressed);
6077+
return getAddrOfGlobalString(name, willBeRelativelyAddressed);
60746078
}
6075-
return getAddrOfGlobalString(data, /*sectionName=*/"",
6076-
willBeRelativelyAddressed);
6079+
return getAddrOfGlobalString(data, willBeRelativelyAddressed);
60776080
}
60786081

60796082
/// Get or create a global UTF-16 string constant.

lib/IRGen/GenKeyPath.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,6 @@ IRGenModule::getAddrOfKeyPathPattern(KeyPathPattern *pattern,
11431143
// null otherwise.
11441144
if (!pattern->getObjCString().empty()) {
11451145
auto objcString = getAddrOfGlobalString(pattern->getObjCString(),
1146-
/*sectionName=*/"",
11471146
/*relatively addressed*/ true);
11481147
fields.addRelativeAddress(objcString);
11491148
} else {

lib/IRGen/GenMeta.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -845,9 +845,8 @@ namespace {
845845
IRGenMangler mangler(IGM.Context);
846846
auto mangledName = mangler.mangleAnonymousDescriptorName(Name);
847847
auto mangledNameConstant =
848-
IGM.getAddrOfGlobalString(mangledName,
849-
/*sectionName=*/"",
850-
/*willBeRelativelyAddressed*/ true);
848+
IGM.getAddrOfGlobalString(mangledName,
849+
/*willBeRelativelyAddressed*/ true);
851850
B.addRelativeAddress(mangledNameConstant);
852851
}
853852

@@ -1278,7 +1277,6 @@ namespace {
12781277
llvm::Constant *global = nullptr;
12791278
if (!AssociatedTypeNames.empty()) {
12801279
global = IGM.getAddrOfGlobalString(AssociatedTypeNames,
1281-
/*sectionName=*/"",
12821280
/*willBeRelativelyAddressed=*/true);
12831281
}
12841282
B.addRelativeAddressOrNull(global);
@@ -1517,11 +1515,9 @@ namespace {
15171515
name.pop_back();
15181516
assert(name.back() == '\0');
15191517
}
1520-
1521-
auto nameStr =
1522-
IGM.getAddrOfGlobalString(name,
1523-
/*sectionName=*/"",
1524-
/*willBeRelativelyAddressed*/ true);
1518+
1519+
auto nameStr = IGM.getAddrOfGlobalString(name,
1520+
/*willBeRelativelyAddressed*/ true);
15251521
B.addRelativeAddress(nameStr);
15261522
}
15271523

lib/IRGen/GenObjC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ getObjectEncodingFromClangNode(IRGenModule &IGM, Decl *d,
13301330
auto clangDecl = d->getClangNode().castAsDecl();
13311331
auto &clangASTContext = IGM.getClangASTContext();
13321332
std::string typeStr;
1333-
std::string sectionName;
1333+
const char *sectionName;
13341334
if (auto objcMethodDecl = dyn_cast<clang::ObjCMethodDecl>(clangDecl)) {
13351335
typeStr = clangASTContext.getObjCEncodingForMethodDecl(
13361336
objcMethodDecl, useExtendedEncoding /*extended*/);

lib/IRGen/IRGenModule.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,9 +1204,11 @@ class IRGenModule {
12041204
StringRef Str, bool willBeRelativelyAddressed = false,
12051205
StringRef sectionName = "", StringRef name = "");
12061206
llvm::Constant *getAddrOfGlobalString(StringRef utf8,
1207-
StringRef sectionName = "",
12081207
bool willBeRelativelyAddressed = false,
1209-
bool useOSLogSection = false);
1208+
bool useOSLogSection = false,
1209+
StringRef sectionName = "");
1210+
llvm::Constant *getAddrOfGlobalString(StringRef utf8,
1211+
const char *sectionName);
12101212
llvm::Constant *getAddrOfGlobalUTF16String(StringRef utf8);
12111213
llvm::Constant *
12121214
getAddrOfGlobalIdentifierString(StringRef utf8,

0 commit comments

Comments
 (0)