diff options
author | Alexey Bader <aleksey.bader@mail.ru> | 2016-10-31 10:26:31 +0000 |
---|---|---|
committer | Alexey Bader <aleksey.bader@mail.ru> | 2016-10-31 10:26:31 +0000 |
commit | abdcfc18090f93a55bb35048b435028319599180 (patch) | |
tree | 629f6e188e2ae595cf5f2d70f029e892b22bc9ce /clang/lib/CodeGen/CGDecl.cpp | |
parent | 56c85d2119078e4538d8a81704f2c45c0f5e5674 (diff) | |
download | bcm5719-llvm-abdcfc18090f93a55bb35048b435028319599180.tar.gz bcm5719-llvm-abdcfc18090f93a55bb35048b435028319599180.zip |
[OpenCL] Setting constant address space for array initializers
Summary: Setting constant address space for global constants used for memcpy-initialization of arrays.
Patch by Alexey Sotkin.
Reviewers: bader, yaxunl, Anastasia
Subscribers: cfe-commits, AlexeySotkin
Differential Revision: https://reviews.llvm.org/D25305
llvm-svn: 285557
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index d527ac47e82..5ad709d0b80 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -1225,10 +1225,16 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { // Otherwise, create a temporary global with the initializer then // memcpy from the global to the alloca. std::string Name = getStaticDeclName(CGM, D); + unsigned AS = 0; + if (getLangOpts().OpenCL) { + AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant); + BP = llvm::PointerType::getInt8PtrTy(getLLVMContext(), AS); + } llvm::GlobalVariable *GV = new llvm::GlobalVariable(CGM.getModule(), constant->getType(), true, llvm::GlobalValue::PrivateLinkage, - constant, Name); + constant, Name, nullptr, + llvm::GlobalValue::NotThreadLocal, AS); GV->setAlignment(Loc.getAlignment().getQuantity()); GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global); |