aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-14 05:55:45 +0000
committerChris Lattner <sabre@nondot.org>2009-10-14 05:55:45 +0000
commit278b9f06933c385ffbccc15f8491787470cb4a1b (patch)
treeb0238580058d6e83a7f463f57ad730b49c5a2144 /lib/CodeGen/CodeGenModule.cpp
parent00549fcec0490b2daf27543e532f94adbb186063 (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84077 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--lib/CodeGen/CodeGenModule.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 4c8ef58367..a7658e5e14 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -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;
+ // Note: -fwritable-strings doesn't make unicode CFStrings writable, but
+ // does make plain ascii ones writable.
+ isConstant = true;
} else {
- Prefix = ".str";
- Sect = getContext().Target.getCFStringDataSection();
Linkage = llvm::GlobalValue::PrivateLinkage;
- // FIXME: -fwritable-strings should probably affect this, but we
- // are following gcc here.
- isConstant = true;
+ 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) {