[PATCH] D24136: [OpenCL] Fix pipe built-in functions return type.
Alexey Bader via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 1 08:12:27 PDT 2016
bader created this revision.
bader added a reviewer: Anastasia.
bader added subscribers: yaxunl, cfe-commits.
By default return type of call expressions calling built-in
functions is set to bool.
Fixes https://llvm.org/bugs/show_bug.cgi?id=30219.
https://reviews.llvm.org/D24136
Files:
lib/Sema/SemaChecking.cpp
test/CodeGenOpenCL/pipe_builtin.cl
Index: test/CodeGenOpenCL/pipe_builtin.cl
===================================================================
--- test/CodeGenOpenCL/pipe_builtin.cl
+++ test/CodeGenOpenCL/pipe_builtin.cl
@@ -59,3 +59,13 @@
// CHECK: call i32 @__get_pipe_max_packets(%opencl.pipe_t* %{{.*}})
*ptr = get_pipe_max_packets(p);
}
+
+void test8(read_only pipe int r, write_only pipe int w, global int *ptr) {
+ // verify that return type is correctly casted to i1 value
+ // CHECK: %[[R:[0-9]+]] = call i32 @__read_pipe_2
+ // CHECK: icmp ne i32 %[[R]], 0
+ if (read_pipe(r, ptr)) *ptr = -1;
+ // CHECK: %[[W:[0-9]+]] = call i32 @__write_pipe_2
+ // CHECK: icmp ne i32 %[[W]], 0
+ if (write_pipe(w, ptr)) *ptr = -1;
+}
Index: lib/Sema/SemaChecking.cpp
===================================================================
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1020,6 +1020,7 @@
// check for the argument.
if (SemaBuiltinRWPipe(*this, TheCall))
return ExprError();
+ TheCall->setType(Context.IntTy);
break;
case Builtin::BIreserve_read_pipe:
case Builtin::BIreserve_write_pipe:
@@ -1047,6 +1048,7 @@
case Builtin::BIget_pipe_max_packets:
if (SemaBuiltinPipePackets(*this, TheCall))
return ExprError();
+ TheCall->setType(Context.UnsignedIntTy);
break;
case Builtin::BIto_global:
case Builtin::BIto_local:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24136.70014.patch
Type: text/x-patch
Size: 1380 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160901/fe8e7c4a/attachment.bin>
More information about the cfe-commits
mailing list