summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2011-01-10 22:34:03 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2011-01-10 22:34:03 +0000
commitb7f60e347479f485c99c6046a42c97311f35fc62 (patch)
tree5974160771eb36042e6f529f781ea84df9d5e652 /clang/lib/CodeGen/CodeGenModule.cpp
parentd2b48119b0b22848fc0f87ddef0e773d7b1a12ec (diff)
downloadbcm5719-llvm-b7f60e347479f485c99c6046a42c97311f35fc62.tar.gz
bcm5719-llvm-b7f60e347479f485c99c6046a42c97311f35fc62.zip
Add unnamed_addr when creating artificial string globals. For example, in
static const char foo[] = "foo"; static const char *bar = "bar"; the global created to hold "bar" will have it, but foo will not. llvm-svn: 123192
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 1376164a22a..f582238456e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1749,9 +1749,12 @@ static llvm::Constant *GenerateStringLiteral(const std::string &str,
llvm::ConstantArray::get(CGM.getLLVMContext(), str, false);
// Create a global variable for this string
- return new llvm::GlobalVariable(CGM.getModule(), C->getType(), constant,
- llvm::GlobalValue::PrivateLinkage,
- C, GlobalName);
+ llvm::GlobalVariable *GV =
+ new llvm::GlobalVariable(CGM.getModule(), C->getType(), constant,
+ llvm::GlobalValue::PrivateLinkage,
+ C, GlobalName);
+ GV->setUnnamedAddr(true);
+ return GV;
}
/// GetAddrOfConstantString - Returns a pointer to a character array
OpenPOWER on IntegriCloud