Author: bader Date: Wed Jul 13 05:28:13 2016 New Revision: 275259 URL: http://llvm.org/viewvc/llvm-project?rev=275259&view=rev Log: [OpenCL] Fix code generation of kernel pipe parameters.
Improved test with user define structure pipe type case. Reviewers: Anastasia, pxli168 Subscribers: yaxunl, cfe-commits Differential revision: http://reviews.llvm.org/D21744 Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/test/CodeGenOpenCL/pipe_types.cl Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=275259&r1=275258&r2=275259&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Jul 13 05:28:13 2016 @@ -516,7 +516,8 @@ static void GenOpenCLArgMetadata(const F // 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 F 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); Modified: cfe/trunk/test/CodeGenOpenCL/pipe_types.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/pipe_types.cl?rev=275259&r1=275258&r2=275259&view=diff ============================================================================== --- cfe/trunk/test/CodeGenOpenCL/pipe_types.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/pipe_types.cl Wed Jul 13 05:28:13 2016 @@ -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* %{{.*}}) +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits