From: Joey Gouly Date: Fri, 4 Apr 2014 13:43:57 +0000 (+0000) Subject: When printing types for the OpenCL kernel metadata, use the PrintingPolicy. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=92a47442f4a362fd634353316d632a1ef87ea106;p=platform%2Fupstream%2Fllvm.git When printing types for the OpenCL kernel metadata, use the PrintingPolicy. This allows 'half' to be printed as 'half' and not as '__fp16'. Patch by Fraser Cormack! llvm-svn: 205624 --- diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 806540a..ffaba95 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -339,6 +339,8 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn, // Each MDNode is a list in the form of "key", N number of values which is // the same number of values as their are kernel arguments. + const PrintingPolicy &Policy = ASTCtx.getPrintingPolicy(); + // MDNode for the kernel argument address space qualifiers. SmallVector addressQuals; addressQuals.push_back(llvm::MDString::get(Context, "kernel_arg_addr_space")); @@ -372,7 +374,8 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn, pointeeTy.getAddressSpace()))); // Get argument type name. - std::string typeName = pointeeTy.getUnqualifiedType().getAsString() + "*"; + std::string typeName = + pointeeTy.getUnqualifiedType().getAsString(Policy) + "*"; // Turn "unsigned type" to "utype" std::string::size_type pos = typeName.find("unsigned"); @@ -398,7 +401,7 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn, addressQuals.push_back(Builder.getInt32(AddrSpc)); // Get argument type name. - std::string typeName = ty.getUnqualifiedType().getAsString(); + std::string typeName = ty.getUnqualifiedType().getAsString(Policy); // Turn "unsigned type" to "utype" std::string::size_type pos = typeName.find("unsigned"); diff --git a/clang/test/CodeGenOpenCL/kernel-arg-info.cl b/clang/test/CodeGenOpenCL/kernel-arg-info.cl index 0123f37..9832604 100644 --- a/clang/test/CodeGenOpenCL/kernel-arg-info.cl +++ b/clang/test/CodeGenOpenCL/kernel-arg-info.cl @@ -18,3 +18,11 @@ kernel void foo2(read_only image1d_t img1, image2d_t img2, write_only image2d_ar // CHECK: metadata !{metadata !"kernel_arg_type", metadata !"image1d_t", metadata !"image2d_t", metadata !"image2d_array_t"} // CHECK: metadata !{metadata !"kernel_arg_type_qual", metadata !"", metadata !"", metadata !""} // CHECK: metadata !{metadata !"kernel_arg_name", metadata !"img1", metadata !"img2", metadata !"img3"} + +kernel void foo3(__global half * X) { +} +// CHECK: metadata !{metadata !"kernel_arg_addr_space", i32 1} +// CHECK: metadata !{metadata !"kernel_arg_access_qual", metadata !"none"} +// CHECK: metadata !{metadata !"kernel_arg_type", metadata !"half*"} +// CHECK: metadata !{metadata !"kernel_arg_type_qual", metadata !""} +// CHECK: metadata !{metadata !"kernel_arg_name", metadata !"X"}