From: Fraser Cormack Date: Wed, 30 Jul 2014 13:41:12 +0000 (+0000) Subject: Fix OpenCL/SPIR kernel_arg_type metadata node X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4dcbc9c128330310675ad2553eff798ea842bd8b;p=clang 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" git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214305 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 67eae450e8..6fe90fd3d4 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -384,7 +384,7 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn, // 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 FunctionDecl *FD, llvm::Function *Fn, // 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)); diff --git a/test/CodeGenOpenCL/kernel-arg-info.cl b/test/CodeGenOpenCL/kernel-arg-info.cl index 9832604b04..95a1387d09 100644 --- a/test/CodeGenOpenCL/kernel-arg-info.cl +++ b/test/CodeGenOpenCL/kernel-arg-info.cl @@ -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"}