summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorAnastasia Stulova <anastasia.stulova@arm.com>2016-11-29 17:01:19 +0000
committerAnastasia Stulova <anastasia.stulova@arm.com>2016-11-29 17:01:19 +0000
commite4a1c38109dd21c92e0dd6f233a047d9ac862dbe (patch)
tree51dc41488bfcc6b4d16b32d57dec65dddae68a62 /clang/lib/CodeGen/CGDecl.cpp
parentbca5fd4f812db9fc692029ebb35fce5871fe6c24 (diff)
downloadbcm5719-llvm-e4a1c38109dd21c92e0dd6f233a047d9ac862dbe.tar.gz
bcm5719-llvm-e4a1c38109dd21c92e0dd6f233a047d9ac862dbe.zip
[OpenCL] Prevent generation of globals in non-constant AS for OpenCL.
Avoid using shortcut for const qualified non-constant address space aggregate variables while generating them on the stack such that the alloca object is used instead of a global variable containing initializer. Review: https://reviews.llvm.org/D27109 llvm-svn: 288163
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 5ad709d0b80..695e92ea1d0 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -948,8 +948,12 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
// If the variable's a const type, and it's neither an NRVO
// candidate nor a __block variable and has no mutable members,
// emit it as a global instead.
- if (CGM.getCodeGenOpts().MergeAllConstants && !NRVO && !isByRef &&
- CGM.isTypeConstant(Ty, true)) {
+ // Exception is if a variable is located in non-constant address space
+ // in OpenCL.
+ if ((!getLangOpts().OpenCL ||
+ Ty.getAddressSpace() == LangAS::opencl_constant) &&
+ (CGM.getCodeGenOpts().MergeAllConstants && !NRVO && !isByRef &&
+ CGM.isTypeConstant(Ty, true))) {
EmitStaticVarDecl(D, llvm::GlobalValue::InternalLinkage);
// Signal this condition to later callbacks.
OpenPOWER on IntegriCloud