diff options
author | Joey Gouly <joey.gouly@arm.com> | 2013-11-14 18:26:10 +0000 |
---|---|---|
committer | Joey Gouly <joey.gouly@arm.com> | 2013-11-14 18:26:10 +0000 |
commit | 561bba2e9f3e67979b0cf6104b48067f8f7d6647 (patch) | |
tree | e739d899d95f659ca848c43e6f02dbedf68378a6 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | dba269286531073ddfc73b1b939501e7cb7cd177 (diff) | |
download | bcm5719-llvm-561bba2e9f3e67979b0cf6104b48067f8f7d6647.tar.gz bcm5719-llvm-561bba2e9f3e67979b0cf6104b48067f8f7d6647.zip |
[OpenCL] Make sure we put string literals in the constant address space.
llvm-svn: 194717
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 1f2f4bbde3c..da54de0bed8 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2625,11 +2625,16 @@ static llvm::GlobalVariable *GenerateStringLiteral(StringRef str, llvm::Constant *C = llvm::ConstantDataArray::getString(CGM.getLLVMContext(), str, false); + // OpenCL v1.1 s6.5.3: a string literal is in the constant address space. + unsigned AddrSpace = 0; + if (CGM.getLangOpts().OpenCL) + AddrSpace = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant); + // Create a global variable for this string - llvm::GlobalVariable *GV = - 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, 0, + llvm::GlobalVariable::NotThreadLocal, AddrSpace); GV->setAlignment(Alignment); GV->setUnnamedAddr(true); return GV; |