The OpenCL specification states that images are allocated

from the global address space (6.5.1 of the OpenCL 1.2 specification).
This makes clang construct the image arguments in the global address 
space and generate the argument metadata with the correct address space 
descriptor. 

Patch by Pedro Ferreira!

llvm-svn: 198868
This commit is contained in:
Pekka Jaaskelainen
2014-01-09 13:37:30 +00:00
parent af4480a121
commit 3587b32e1c
3 changed files with 18 additions and 10 deletions

View File

@@ -383,7 +383,12 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn,
if (pointeeTy.isVolatileQualified())
typeQuals += typeQuals.empty() ? "volatile" : " volatile";
} else {
addressQuals.push_back(Builder.getInt32(0));
uint32_t AddrSpc = 0;
if (ty->isImageType())
AddrSpc =
CGM.getContext().getTargetAddressSpace(LangAS::opencl_global);
addressQuals.push_back(Builder.getInt32(AddrSpc));
// Get argument type name.
std::string typeName = ty.getUnqualifiedType().getAsString();