]> granicus.if.org Git - clang/commitdiff
[OpenCL] Fix code generation of kernel pipe parameters.
authorAlexey Bader <aleksey.bader@mail.ru>
Wed, 13 Jul 2016 10:28:13 +0000 (10:28 +0000)
committerAlexey Bader <aleksey.bader@mail.ru>
Wed, 13 Jul 2016 10:28:13 +0000 (10:28 +0000)
Improved test with user define structure pipe type case.

Reviewers: Anastasia, pxli168
Subscribers: yaxunl, cfe-commits

Differential revision: http://reviews.llvm.org/D21744

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275259 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenFunction.cpp
test/CodeGenOpenCL/pipe_types.cl

index a0158d8b4b23685b43e942bf052c0e23ada9431a..755881fb1480f67a9b1695e2f231250a31551a44 100644 (file)
@@ -516,7 +516,8 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn,
       // Get argument type name.
       std::string typeName;
       if (isPipe)
-        typeName = cast<PipeType>(ty)->getElementType().getAsString(Policy);
+        typeName = ty.getCanonicalType()->getAs<PipeType>()->getElementType()
+                     .getAsString(Policy);
       else
         typeName = ty.getUnqualifiedType().getAsString(Policy);
 
@@ -529,8 +530,9 @@ static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn,
 
       std::string baseTypeName;
       if (isPipe)
-        baseTypeName =
-          cast<PipeType>(ty)->getElementType().getCanonicalType().getAsString(Policy);
+        baseTypeName = ty.getCanonicalType()->getAs<PipeType>()
+                          ->getElementType().getCanonicalType()
+                          .getAsString(Policy);
       else
         baseTypeName =
           ty.getUnqualifiedType().getCanonicalType().getAsString(Policy);
index 9d8d5274a3ba5d2e9c0242bc8223229bfe5eb155..b9c411b5fcb6ac63c25840019c0574f7a38bdddf 100644 (file)
@@ -25,3 +25,23 @@ void test4(read_only pipe uchar3 p) {
 void test5(read_only pipe int4 p) {
 // CHECK: define void @test5(%opencl.pipe_t* %p)
 }
+
+typedef read_only pipe int MyPipe;
+kernel void test6(MyPipe p) {
+// CHECK: define void @test6(%opencl.pipe_t* %p)
+}
+
+struct Person {
+  const char *Name;
+  bool isFemale;
+  int ID;
+};
+
+void test_reserved_read_pipe(global struct Person *SDst,
+                             read_only pipe struct Person SPipe) {
+// CHECK: define void @test_reserved_read_pipe
+  read_pipe (SPipe, SDst);
+  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}})
+  read_pipe (SPipe, SDst);
+  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}})
+}