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
This commit is contained in:
Joey Gouly 2014-04-04 13:43:57 +00:00
parent 7dc3c0fb2b
commit 92a47442f4
2 changed files with 13 additions and 2 deletions

View File

@ -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<llvm::Value*, 8> 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");

View File

@ -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"}