[PATCH] D27334: [OpenCL] Ambiguous function call.

Egor Churaev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 9 02:56:23 PST 2017


echuraev added a comment.

In https://reviews.llvm.org/D27334#614826, @Anastasia wrote:

> In https://reviews.llvm.org/D27334#614389, @bader wrote:
>
> > In https://reviews.llvm.org/D27334#613504, @Anastasia wrote:
> >
> > > In https://reviews.llvm.org/D27334#612858, @bader wrote:
> > >
> > > > In https://reviews.llvm.org/D27334#611703, @Anastasia wrote:
> > > >
> > > > > This change seems to modify normal C behavior again. Is there any strong motivation for doing this and if yes could it be done generically with C?
> > > >
> > > >
> > > > Motivation:
> > > >
> > > >   // Non-portable OpenCL 1.2 code 
> > > >   __kernel void foo(global float* out) {
> > > >     out[get_global_id(0)] = sin(get_global_id(0));
> > > >   }
> > > >
> > > >
> > > > This program compiles fine on OpenCL platform w/o doubles support and fails otherwise.
> > > >  If OpenCL driver supports doubles it provides at least two versions of 'sin' built-in math function and compiler will not be able to choose the right one for 'size_t' argument.
> > > >  The goal of this warning is to let OpenCL developer know about potential issues with code portability.
> > >
> > >
> > > I would argue this improves the portability much as it can also be misleading in some situations (because it refers to a potentially hypothetical problem). For example there can be builtin functions that only have a float parameter (without a double version of it). This is for example the case with read_image functions that take a float coordinate value between 0 and 1. Unfortunately this warning won't be triggered on read_image functions because there is an overload candidate with an int type of the same parameter too. But we can't exclude this situations to appear in the future or from some vendor extensions or even custom OpenCL code.
> >
> >
> > As much as any other warning it's not always means that there is an error in the code. It just means that developer should inspect the construction triggering a warning.
> >  Passing integer value to a function with floating point parameters is not always an error, but some times it might be so.
> >  Do you suggest dropping the diagnostics at all or changing the diagnostics message?
>
>
> I agree warnings don't always signal a definite issue (even thought it's good to make them as precise as we can). We could try to reword the diagnostic message. However, the biggest issue I have here is that the message can be given in the situations that are unrelated to the problem (i.e. the overload candidates that don't have anything to do with the parameter being diagnosed or don't overload with the double precision). Therefore, it feels like the diagnostic can be confusing in some cases even though they are not very probable ones.


@Anastasia, do you have any suggestions how is it better to reword the diagnostic message? Yes, this message can be given in some situations that are unrelated to the problem but in this case it will be a notification for developer that this function call can be potential ambiguous.



================
Comment at: lib/Sema/SemaChecking.cpp:2479
+        // integer values.
+        if (FDecl->hasAttr<OverloadableAttr>()) {
+          for (const auto* Arg : Args) {
----------------
Anastasia wrote:
> How does it check that this is a built-in function?
In OpenCL we can overload only built-in functions. So, I think that we can recognize that the function is built-in by checking that the language is OpenCL and the function has Overloadable attribute.


https://reviews.llvm.org/D27334





More information about the cfe-commits mailing list