From 3587b32e1cc978d997602d4c0784cdcedda7de3f Mon Sep 17 00:00:00 2001 From: Pekka Jaaskelainen Date: Thu, 9 Jan 2014 13:37:30 +0000 Subject: 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 --- clang/lib/CodeGen/CodeGenFunction.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp') diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index c1e522d0d74a..564ea11a8f87 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -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(); -- cgit v1.2.3