r214305 - Fix OpenCL/SPIR kernel_arg_type metadata node

Fraser Cormack fraser at codeplay.com
Wed Jul 30 06:41:12 PDT 2014


Author: fcormack
Date: Wed Jul 30 08:41:12 2014
New Revision: 214305

URL: http://llvm.org/viewvc/llvm-project?rev=214305&view=rev
Log:
Fix OpenCL/SPIR kernel_arg_type metadata node

This fixes a bug where kernel_arg_type was always changing 'unsigned ' to 'u'
for any parameter type, including non-canonical types.

Example:
  typedef unsigned int myunsignedint;
would report:
  "myunt"

Modified:
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=214305&r1=214304&r2=214305&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Jul 30 08:41:12 2014
@@ -384,7 +384,7 @@ static void GenOpenCLArgMetadata(const F
 
       // Turn "unsigned type" to "utype"
       std::string::size_type pos = typeName.find("unsigned");
-      if (pos != std::string::npos)
+      if (pointeeTy.isCanonical() && pos != std::string::npos)
         typeName.erase(pos+1, 8);
 
       argTypeNames.push_back(llvm::MDString::get(Context, typeName));
@@ -410,7 +410,7 @@ static void GenOpenCLArgMetadata(const F
 
       // Turn "unsigned type" to "utype"
       std::string::size_type pos = typeName.find("unsigned");
-      if (pos != std::string::npos)
+      if (ty.isCanonical() && pos != std::string::npos)
         typeName.erase(pos+1, 8);
 
       argTypeNames.push_back(llvm::MDString::get(Context, typeName));

Modified: cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl?rev=214305&r1=214304&r2=214305&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl Wed Jul 30 08:41:12 2014
@@ -26,3 +26,12 @@ kernel void foo3(__global half * X) {
 // CHECK: metadata !{metadata !"kernel_arg_type", metadata !"half*"}
 // CHECK: metadata !{metadata !"kernel_arg_type_qual", metadata !""}
 // CHECK: metadata !{metadata !"kernel_arg_name", metadata !"X"}
+
+typedef unsigned int myunsignedint;
+kernel void foo4(__global unsigned int * X, __global myunsignedint * Y) {
+}
+// CHECK: metadata !{metadata !"kernel_arg_addr_space", i32 1, i32 1}
+// CHECK: metadata !{metadata !"kernel_arg_access_qual", metadata !"none", metadata !"none"}
+// CHECK: metadata !{metadata !"kernel_arg_type", metadata !"uint*", metadata !"myunsignedint*"}
+// CHECK: metadata !{metadata !"kernel_arg_type_qual", metadata !"", metadata !""}
+// CHECK: metadata !{metadata !"kernel_arg_name", metadata !"X", metadata !"Y"}





More information about the cfe-commits mailing list