[CUDA][HIP] Fix implicit HD function resolution
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>
Thu, 4 Jun 2020 20:54:52 +0000 (16:54 -0400)
commit263390d4f5f23967a31af09eb6e0c12e633d6104
treebb4b35e278f7ab8bc12f19afeff0224fca40b5bd
parent54a8a8d5095fad1993ac3afaf04eb23f3ae06dcb
[CUDA][HIP] Fix implicit HD function resolution

recommit e03394c6a6ff with fix

When implicit HD function calls a function in device compilation,
if one candidate is an implicit HD function, current resolution rule is:

D wins over HD and H
HD and H are equal

this caused regression when there is an otherwise worse D candidate

This patch changes that to

D, HD and H are all equal

The rationale is that we already know for host compilation there is already
a valid candidate in HD and H candidates that will not cause error. Allowing
HD and H gives us a fall back candidate that will not cause error. If D wins,
that means D has to be a better match otherwise, therefore D should also
be a valid candidate that will not cause error. In this way, we can guarantee
no regression.

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