[PATCH] D21744: [OpenCL] Fix code generation of kernel pipe parameters.
Alexey Bader via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 27 00:16:52 PDT 2016
bader created this revision.
bader added reviewers: Anastasia, pxli168.
bader added subscribers: cfe-commits, yaxunl.
Improved test with user define structure pipe type case.
http://reviews.llvm.org/D21744
Files:
lib/CodeGen/CodeGenFunction.cpp
test/CodeGenOpenCL/pipe_types.cl
Index: test/CodeGenOpenCL/pipe_types.cl
===================================================================
--- test/CodeGenOpenCL/pipe_types.cl
+++ test/CodeGenOpenCL/pipe_types.cl
@@ -25,3 +25,23 @@
void test5(read_only pipe int4 p) {
// CHECK: define void @test5(%opencl.pipe_t* %p)
}
+
+typedef pipe int MyPipe;
+kernel void test6(read_only 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* %{{.*}})
+}
Index: lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -516,7 +516,10 @@
// 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 +532,11 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21744.61934.patch
Type: text/x-patch
Size: 2022 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160627/653f89a9/attachment.bin>
More information about the cfe-commits
mailing list