fix some cfstring related issues:
1) -fwritable-string does affect the non-utf16 version of cfstrings just not the utf16 ones. 2) utf16 strings should always be marked constant, as the __TEXT segment is readonly. 3) The name of the global doesn't matter, remove it from TargetInfo. 4) Trust the asmprinter to drop cstrings into the right section, like llvmgcc does now. This fixes rdar://7115750 llvm-svn: 84077
This commit is contained in:
@@ -1434,27 +1434,24 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
|
||||
// String pointer.
|
||||
llvm::Constant *C = llvm::ConstantArray::get(VMContext, Entry.getKey().str());
|
||||
|
||||
const char *Sect, *Prefix;
|
||||
bool isConstant;
|
||||
const char *Sect = 0;
|
||||
llvm::GlobalValue::LinkageTypes Linkage;
|
||||
bool isConstant;
|
||||
if (isUTF16) {
|
||||
Prefix = getContext().Target.getUnicodeStringSymbolPrefix();
|
||||
Sect = getContext().Target.getUnicodeStringSection();
|
||||
// FIXME: why do utf strings get "l" labels instead of "L" labels?
|
||||
// FIXME: why do utf strings get "_" labels instead of "L" labels?
|
||||
Linkage = llvm::GlobalValue::InternalLinkage;
|
||||
// FIXME: Why does GCC not set constant here?
|
||||
isConstant = false;
|
||||
} else {
|
||||
Prefix = ".str";
|
||||
Sect = getContext().Target.getCFStringDataSection();
|
||||
Linkage = llvm::GlobalValue::PrivateLinkage;
|
||||
// FIXME: -fwritable-strings should probably affect this, but we
|
||||
// are following gcc here.
|
||||
// Note: -fwritable-strings doesn't make unicode CFStrings writable, but
|
||||
// does make plain ascii ones writable.
|
||||
isConstant = true;
|
||||
} else {
|
||||
Linkage = llvm::GlobalValue::PrivateLinkage;
|
||||
isConstant = !Features.WritableStrings;
|
||||
}
|
||||
|
||||
llvm::GlobalVariable *GV =
|
||||
new llvm::GlobalVariable(getModule(), C->getType(), isConstant,
|
||||
Linkage, C, Prefix);
|
||||
new llvm::GlobalVariable(getModule(), C->getType(), isConstant, Linkage, C,
|
||||
".str");
|
||||
if (Sect)
|
||||
GV->setSection(Sect);
|
||||
if (isUTF16) {
|
||||
|
||||
Reference in New Issue
Block a user