[CUDA][HIP] Workaround for resolving host device function against wrong-sided function
authorYaxun (Sam) Liu <yaxun.liu@amd.com>
Fri, 24 Apr 2020 20:41:24 +0000 (16:41 -0400)
committerYaxun (Sam) Liu <yaxun.liu@amd.com>
Tue, 12 May 2020 12:27:50 +0000 (08:27 -0400)
commite03394c6a6ff5832aa43259d4b8345f40ca6a22c
tree3b327b64ef9abddc3fc6a43fd9a1e298ef1eae9c
parentf1f8cffce49fe56817e25f648b29e1a8cfcfac8a
[CUDA][HIP] Workaround for resolving host device function against wrong-sided function

recommit c77a4078e01033aa2206c31a579d217c8a07569b with fix

https://reviews.llvm.org/D77954 caused regressions due to diagnostics in implicit
host device functions.

For now, it seems the most feasible workaround is to treat implicit host device function and explicit host
device function differently. Basically in device compilation for implicit host device functions, keep the
old behavior, i.e. give host device candidates and wrong-sided candidates equal preference. For explicit
host device functions, favor host device candidates against wrong-sided candidates.

The rationale is that explicit host device functions are blessed by the user to be valid host device functions,
that is, they should not cause diagnostics in both host and device compilation. If diagnostics occur, user is
able to fix them. However, there is no guarantee that implicit host device function can be compiled in
device compilation, therefore we need to preserve its overloading resolution in device compilation.

Differential Revision: https://reviews.llvm.org/D79526
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCUDA/function-overload.cu