This revision was automatically updated to reflect the committed changes. Closed by commit rL280800: [OpenCL] Fix pipe built-in functions return type. (authored by bader).
Changed prior to commit: https://reviews.llvm.org/D24136?vs=70368&id=70516#toc Repository: rL LLVM https://reviews.llvm.org/D24136 Files: cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl Index: cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl =================================================================== --- cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl +++ cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl @@ -59,3 +59,19 @@ // 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; + // CHECK: %[[N:[0-9]+]] = call i32 @__get_pipe_num_packets + // CHECK: icmp ne i32 %[[N]], 0 + if (get_pipe_num_packets(r)) *ptr = -1; + // CHECK: %[[M:[0-9]+]] = call i32 @__get_pipe_max_packets + // CHECK: icmp ne i32 %[[M]], 0 + if (get_pipe_max_packets(w)) *ptr = -1; +} Index: cfe/trunk/lib/Sema/SemaChecking.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaChecking.cpp +++ cfe/trunk/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:
Index: cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl =================================================================== --- cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl +++ cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl @@ -59,3 +59,19 @@ // 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; + // CHECK: %[[N:[0-9]+]] = call i32 @__get_pipe_num_packets + // CHECK: icmp ne i32 %[[N]], 0 + if (get_pipe_num_packets(r)) *ptr = -1; + // CHECK: %[[M:[0-9]+]] = call i32 @__get_pipe_max_packets + // CHECK: icmp ne i32 %[[M]], 0 + if (get_pipe_max_packets(w)) *ptr = -1; +} Index: cfe/trunk/lib/Sema/SemaChecking.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaChecking.cpp +++ cfe/trunk/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:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits