[PATCH] D83893: [CUDA][HIP] Always defer diagnostics for wrong-sided reference
Artem Belevich via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 15 12:27:23 PDT 2020
tra added subscribers: jlebar, rsmith.
tra added a comment.
> This is different from nvcc behavior, where it is diagnosed only if the function is really emitted:
That by itself is not a sufficient reason for relaxing the checks. Clang is stricter/more principled in diagnosing other questionalbe things nvcc lets through, even when it should not have.
NVCC only sees part of the source, so it's limited in what it can diagnose during particular compilation side. Clang can do better.
> Current clang behavior causes diagnostics for wrong-sided reference emitted twice, once in host compilation, once in device compilation, which is unnecessary and cluttering the screen.
I don't think it's a problem. Clang will abort compilation if one of sub-compilation fails. We'll only see the error once.
> More importantly, current clang behavior causes false alarms for valid use cases:
I'm not convinced that your example is valid. To me it looks like `test` should not have been a HD, given that it always uses a host function.
That said, I can see where it may be useful in case of `test` being a constexpr template function (for example somewhere in a standard library) parametrized by something else which may be host or device-only.
E.g. this may be a somewhat better example: https://godbolt.org/z/44vPv8
OK. I think it is useful, but I could also use a second opinion.
@rsmith , @jlebar do you have any thoughts on this?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83893/new/
https://reviews.llvm.org/D83893
More information about the cfe-commits
mailing list