aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-04-03 00:57:44 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-04-03 00:57:44 +0000
commita9668e0b4c451a1021fe650c451b54dc98c2d18d (patch)
tree6b7a763092c64a5cc677c45bb0a65dfb819f4ae5 /lib/CodeGen/CodeGenModule.cpp
parent2b63fbc9bf79e98e824cd9a6d5104242756dc6b7 (diff)
Add target hook for setting symbol prefix and section of unicode
string literals. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68363 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--lib/CodeGen/CodeGenModule.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index fa475ced6e..1132c3f721 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -1082,13 +1082,31 @@ GetAddrOfConstantCFString(const StringLiteral *Literal) {
CurField = NextField;
NextField = *Field++;
llvm::Constant *C = llvm::ConstantArray::get(str);
+
+ const char *Sect, *Prefix;
+ bool isConstant;
+ if (isUTF16) {
+ Prefix = getContext().Target.getUnicodeStringSymbolPrefix();
+ Sect = getContext().Target.getUnicodeStringSection();
+ // FIXME: Why does GCC not set constant here?
+ isConstant = false;
+ } else {
+ Prefix = getContext().Target.getStringSymbolPrefix(true);
+ Sect = getContext().Target.getCFStringDataSection();
+ // FIXME: -fwritable-strings should probably affect this, but we
+ // are following gcc here.
+ isConstant = true;
+ }
llvm::GlobalVariable *GV =
- new llvm::GlobalVariable(C->getType(), true,
+ new llvm::GlobalVariable(C->getType(), isConstant,
llvm::GlobalValue::InternalLinkage,
- C, getContext().Target.getStringSymbolPrefix(true),
- &getModule());
- if (const char *Sect = getContext().Target.getCFStringDataSection())
+ C, Prefix, &getModule());
+ if (Sect)
GV->setSection(Sect);
+ if (isUTF16) {
+ unsigned Align = getContext().getTypeAlign(getContext().ShortTy)/8;
+ GV->setAlignment(Align);
+ }
appendFieldAndPadding(*this, Fields, CurField, NextField,
llvm::ConstantExpr::getGetElementPtr(GV, Zeros, 2),
CFRD, STy);