Page MenuHomePhabricator

OpenCL: Improve vector printf warnings
ClosedPublic

Authored by arsenm on Wed, Nov 28, 1:27 PM.

Details

Reviewers
Anastasia
Summary

The vector modifier is considered separate, so
don't treat it as a conversion specifier.

This is still not warning on some cases, like
using a type that isn't a valid vector element.

Diff Detail

Event Timeline

arsenm created this revision.Wed, Nov 28, 1:27 PM
Anastasia added inline comments.Thu, Nov 29, 3:22 AM
test/SemaOpenCL/format-strings-fixit.cl
14

Does this not work yet?

test/SemaOpenCL/printf-format-strings.cl
77

So there is no way to print vector of float? What will happen on architectures that don't support doubles?

I guess it's the same for printf in general with the float type?

arsenm marked 2 inline comments as done.Thu, Nov 29, 8:12 AM
arsenm added inline comments.
test/SemaOpenCL/format-strings-fixit.cl
14

It does. This was a leftover reference I was using I can remove

test/SemaOpenCL/printf-format-strings.cl
77

There is, it's converted to a vector of doubles. This case warns because the element count mismatches

arsenm marked an inline comment as done and an inline comment as not done.Thu, Nov 29, 8:14 AM
arsenm added inline comments.
test/SemaOpenCL/printf-format-strings.cl
77

The conversion is to float if doubles aren't supported

arsenm marked an inline comment as done.Thu, Nov 29, 8:19 AM
arsenm added inline comments.
test/SemaOpenCL/printf-format-strings.cl
77

The warning message is wrong though without doubles, and still says double.

Anastasia added inline comments.Thu, Nov 29, 8:52 AM
test/SemaOpenCL/printf-format-strings.cl
77

Can we add this explicitly to the test just for a record? I guess the warning message can't be changed to print the type correctly?

Also would it make sense to test other builtin types: double, char...?

arsenm marked an inline comment as done.Thu, Nov 29, 9:56 AM
arsenm added inline comments.
test/SemaOpenCL/printf-format-strings.cl
77

This should be easy to fix, but the way to test for doubles is enabled is making this unnecessarily difficult. It requires threading OpenCLOptions through all of the relevant functions to check for cl_khr_fp64. Why is this separate from LangOptions?

arsenm updated this revision to Diff 175920.Thu, Nov 29, 11:55 AM

Add tests without fp64

Anastasia accepted this revision.Fri, Nov 30, 4:17 AM

LGTM! Thanks!

test/SemaOpenCL/printf-format-strings.cl
77

I see. I think the problem is that it is set conditionally based on the targets in earlier CL versions. So it had to be a separated into target specific option. :(

This revision is now accepted and ready to land.Fri, Nov 30, 4:17 AM
arsenm marked an inline comment as done.Fri, Nov 30, 10:49 AM
arsenm added inline comments.
test/SemaOpenCL/printf-format-strings.cl
77

Would it be reasonable to add a new HasNoDouble field or something in LangOptions?

arsenm closed this revision.Sat, Dec 1, 2:19 PM

r348084