r264825 - [OpenCL] Fix pipe builtin bugs
Xiuli Pan via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 29 21:46:33 PDT 2016
Author: pxl
Date: Tue Mar 29 23:46:32 2016
New Revision: 264825
URL: http://llvm.org/viewvc/llvm-project?rev=264825&view=rev
Log:
[OpenCL] Fix pipe builtin bugs
Summary:
1. Diag should be output if types are not the same.
2. Should compare using canonical type.
3. Refine the diag to be more clear.
Reviewers: yaxunl, Anastasia
Subscribers: MatsPetersson, pekka.jaaskelainen, cfe-commits
Differential Revision: http://reviews.llvm.org/D17955
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=264825&r1=264824&r2=264825&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Mar 29 23:46:32 2016
@@ -7776,7 +7776,7 @@ def err_opencl_builtin_pipe_first_arg :
def err_opencl_builtin_pipe_arg_num : Error<
"invalid number of arguments to function: %0">;
def err_opencl_builtin_pipe_invalid_arg : Error<
- "invalid argument type to function %0 (expecting %1)">;
+ "invalid argument type to function %0 (expecting %1 having %2)">;
def err_opencl_builtin_pipe_invalid_access_modifier : Error<
"invalid pipe access modifier (expecting %0)">;
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=264825&r1=264824&r2=264825&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Mar 29 23:46:32 2016
@@ -325,10 +325,12 @@ static bool checkOpenCLPipePacketType(Se
const PointerType *ArgTy = ArgIdx->getType()->getAs<PointerType>();
// The Idx argument should be a pointer and the type of the pointer and
// the type of pipe element should also be the same.
- if (!ArgTy || S.Context.hasSameType(EltTy, ArgTy->getPointeeType())) {
+ if (!ArgTy ||
+ !S.Context.hasSameType(
+ EltTy, ArgTy->getPointeeType()->getCanonicalTypeInternal())) {
S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
<< Call->getDirectCallee() << S.Context.getPointerType(EltTy)
- << ArgIdx->getSourceRange();
+ << ArgIdx->getType() << ArgIdx->getSourceRange();
return true;
}
return false;
@@ -361,7 +363,7 @@ static bool SemaBuiltinRWPipe(Sema &S, C
if (!Call->getArg(1)->getType()->isReserveIDT()) {
S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
<< Call->getDirectCallee() << S.Context.OCLReserveIDTy
- << Call->getArg(1)->getSourceRange();
+ << Call->getArg(1)->getType() << Call->getArg(1)->getSourceRange();
return true;
}
@@ -371,7 +373,7 @@ static bool SemaBuiltinRWPipe(Sema &S, C
!Arg2->getType()->isUnsignedIntegerType()) {
S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
<< Call->getDirectCallee() << S.Context.UnsignedIntTy
- << Arg2->getSourceRange();
+ << Arg2->getType() << Arg2->getSourceRange();
return true;
}
@@ -405,7 +407,7 @@ static bool SemaBuiltinReserveRWPipe(Sem
!Call->getArg(1)->getType()->isUnsignedIntegerType()) {
S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
<< Call->getDirectCallee() << S.Context.UnsignedIntTy
- << Call->getArg(1)->getSourceRange();
+ << Call->getArg(1)->getType() << Call->getArg(1)->getSourceRange();
return true;
}
@@ -428,7 +430,7 @@ static bool SemaBuiltinCommitRWPipe(Sema
if (!Call->getArg(1)->getType()->isReserveIDT()) {
S.Diag(Call->getLocStart(), diag::err_opencl_builtin_pipe_invalid_arg)
<< Call->getDirectCallee() << S.Context.OCLReserveIDTy
- << Call->getArg(1)->getSourceRange();
+ << Call->getArg(1)->getType() << Call->getArg(1)->getSourceRange();
return true;
}
Modified: cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl?rev=264825&r1=264824&r2=264825&view=diff
==============================================================================
--- cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl Tue Mar 29 23:46:32 2016
@@ -5,22 +5,27 @@ void test1(read_only pipe int p, global
reserve_id_t rid;
// read/write_pipe
+ read_pipe(p, &tmp);
+ read_pipe(p, ptr);
read_pipe(tmp, p); // expected-error {{first argument to 'read_pipe' must be a pipe type}}
read_pipe(p); // expected-error {{invalid number of arguments to function: 'read_pipe'}}
- read_pipe(p, tmp, tmp, ptr); // expected-error {{invalid argument type to function 'read_pipe' (expecting 'reserve_id_t')}}
- read_pipe(p, rid, rid, ptr); // expected-error {{invalid argument type to function 'read_pipe' (expecting 'unsigned int')}}
- read_pipe(p, tmp); // expected-error {{invalid argument type to function 'read_pipe' (expecting 'int *')}}
+ read_pipe(p, rid, tmp, ptr);
+ read_pipe(p, tmp, tmp, ptr); // expected-error {{invalid argument type to function 'read_pipe' (expecting 'reserve_id_t' having 'int')}}
+ read_pipe(p, rid, rid, ptr); // expected-error {{invalid argument type to function 'read_pipe' (expecting 'unsigned int' having 'reserve_id_t')}}
+ read_pipe(p, tmp); // expected-error {{invalid argument type to function 'read_pipe' (expecting 'int *' having 'int')}}
write_pipe(p, ptr); // expected-error {{invalid pipe access modifier (expecting write_only)}}
write_pipe(p, rid, tmp, ptr); // expected-error {{invalid pipe access modifier (expecting write_only)}}
// reserve_read/write_pipe
- reserve_read_pipe(p, ptr); // expected-error{{invalid argument type to function 'reserve_read_pipe' (expecting 'unsigned int')}}
+ reserve_read_pipe(p, tmp);
+ reserve_read_pipe(p, ptr); // expected-error{{invalid argument type to function 'reserve_read_pipe' (expecting 'unsigned int' having '__global int *')}}
work_group_reserve_read_pipe(tmp, tmp); // expected-error{{first argument to 'work_group_reserve_read_pipe' must be a pipe type}}
sub_group_reserve_write_pipe(p, tmp); // expected-error{{invalid pipe access modifier (expecting write_only)}}
// commit_read/write_pipe
+ commit_read_pipe(p, rid);
commit_read_pipe(tmp, rid); // expected-error{{first argument to 'commit_read_pipe' must be a pipe type}}
- work_group_commit_read_pipe(p, tmp); // expected-error{{invalid argument type to function 'work_group_commit_read_pipe' (expecting 'reserve_id_t')}}
+ work_group_commit_read_pipe(p, tmp); // expected-error{{invalid argument type to function 'work_group_commit_read_pipe' (expecting 'reserve_id_t' having 'int')}}
sub_group_commit_write_pipe(p, tmp); // expected-error{{invalid pipe access modifier (expecting write_only)}}
}
@@ -29,22 +34,27 @@ void test2(write_only pipe int p, global
reserve_id_t rid;
// read/write_pipe
+ write_pipe(p, &tmp);
+ write_pipe(p, ptr);
write_pipe(tmp, p); // expected-error {{first argument to 'write_pipe' must be a pipe type}}
write_pipe(p); // expected-error {{invalid number of arguments to function: 'write_pipe'}}
- write_pipe(p, tmp, tmp, ptr); // expected-error {{invalid argument type to function 'write_pipe' (expecting 'reserve_id_t')}}
- write_pipe(p, rid, rid, ptr); // expected-error {{invalid argument type to function 'write_pipe' (expecting 'unsigned int')}}
- write_pipe(p, tmp); // expected-error {{invalid argument type to function 'write_pipe' (expecting 'int *')}}
+ write_pipe(p, rid, tmp, ptr);
+ write_pipe(p, tmp, tmp, ptr); // expected-error {{invalid argument type to function 'write_pipe' (expecting 'reserve_id_t' having 'int')}}
+ write_pipe(p, rid, rid, ptr); // expected-error {{invalid argument type to function 'write_pipe' (expecting 'unsigned int' having 'reserve_id_t')}}
+ write_pipe(p, tmp); // expected-error {{invalid argument type to function 'write_pipe' (expecting 'int *' having 'int')}}
read_pipe(p, ptr); // expected-error {{invalid pipe access modifier (expecting read_only)}}
read_pipe(p, rid, tmp, ptr); // expected-error {{invalid pipe access modifier (expecting read_only)}}
// reserve_read/write_pipe
- reserve_write_pipe(p, ptr); // expected-error{{invalid argument type to function 'reserve_write_pipe' (expecting 'unsigned int')}}
+ reserve_write_pipe(p, tmp);
+ reserve_write_pipe(p, ptr); // expected-error{{invalid argument type to function 'reserve_write_pipe' (expecting 'unsigned int' having '__global int *')}}
work_group_reserve_write_pipe(tmp, tmp); // expected-error{{first argument to 'work_group_reserve_write_pipe' must be a pipe type}}
sub_group_reserve_read_pipe(p, tmp); // expected-error{{invalid pipe access modifier (expecting read_only)}}
// commit_read/write_pipe
+ commit_write_pipe(p, rid);
commit_write_pipe(tmp, rid); // expected-error{{first argument to 'commit_write_pipe' must be a pipe type}}
- work_group_commit_write_pipe(p, tmp); // expected-error{{invalid argument type to function 'work_group_commit_write_pipe' (expecting 'reserve_id_t')}}
+ work_group_commit_write_pipe(p, tmp); // expected-error{{invalid argument type to function 'work_group_commit_write_pipe' (expecting 'reserve_id_t' having 'int')}}
sub_group_commit_read_pipe(p, tmp); // expected-error{{invalid pipe access modifier (expecting read_only)}}
}
More information about the cfe-commits
mailing list