[PATCH] D96161: [OpenCL] Fix printing of types with signed prefix in arg info metadata

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 5 10:34:45 PST 2021


Anastasia created this revision.
Anastasia added reviewers: svenvh, mantognini.
Herald added subscribers: ebevhan, yaxunl.
Anastasia requested review of this revision.

OpenCL spec doesn't seem to describe the behavior correctly for type printing in **GetKernelArgInfo** (https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#clGetKernelArgInfo):

> The type name returned will be the argument type name as it was declared with any whitespace removed. If argument type name is an unsigned scalar type (i.e. unsigned char, unsigned short, unsigned int, unsigned long), uchar, ushort, uint and ulong will be returned.

The example with unsigned doesn't seem to comply with the general statement in the first sentence. It is believed that it actually meant to say that the single word spelling should be used for types i.e.

  unsigned type -> utype
  signed type -> type

This patch fixed the printing of type with `signed` prefix in spelling.


https://reviews.llvm.org/D96161

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenOpenCL/kernel-arg-info.cl


Index: clang/test/CodeGenOpenCL/kernel-arg-info.cl
===================================================================
--- clang/test/CodeGenOpenCL/kernel-arg-info.cl
+++ clang/test/CodeGenOpenCL/kernel-arg-info.cl
@@ -107,6 +107,16 @@
 // CHECK-NOT: !kernel_arg_name
 // ARGINFO: !kernel_arg_name ![[PIPE_ARG_NAMES:[0-9]+]]
 
+kernel void foo9(signed int si1,  global const signed int* si2) {}
+// CHECK: define{{.*}} spir_kernel void @foo9{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[SINT_AS_QUAL:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD42]]
+// CHECK: !kernel_arg_type ![[SINT_TY:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[SINT_TY]]
+// CHECK: !kernel_arg_type_qual ![[SINT_QUAL:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[SINT_ARG_NAMES:[0-9]+]]
+
 // CHECK: ![[MD11]] = !{i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 1, i32 1, i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 0, i32 0, i32 0, i32 0}
 // CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none"}
 // CHECK: ![[MD13]] = !{!"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int", !"int", !"int", !"int"}
@@ -146,3 +156,7 @@
 // CHECK: ![[PIPE_BASE_TY]] = !{!"int", !"uchar", !"uchar __attribute__((ext_vector_type(2)))", !"uchar", !"uchar"}
 // CHECK: ![[PIPE_QUAL]] = !{!"pipe", !"pipe", !"pipe", !"pipe", !"pipe"}
 // ARGINFO: ![[PIPE_ARG_NAMES]] = !{!"p1", !"p2", !"p3", !"p4", !"p5"}
+// CHECK: ![[SINT_AS_QUAL]] = !{i32 0, i32 1}
+// CHECK: ![[SINT_TY]] = !{!"int", !"int*"}
+// CHECK: ![[SINT_QUAL]] = !{!"", !"const"}
+// ARGINFO: ![[SINT_ARG_NAMES]] = !{!"si1", !"si2"}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1501,6 +1501,8 @@
         if (Ty.isCanonical()) {
           if (typeNameRef.consume_front("unsigned "))
             return std::string("u") + typeNameRef.str();
+          if (typeNameRef.consume_front("signed "))
+            return typeNameRef.str();
         }
 
         return typeName;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96161.321821.patch
Type: text/x-patch
Size: 2380 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210205/32e73225/attachment.bin>


More information about the cfe-commits mailing list