[CUDA] Tweak attribute-based overload resolution to match nvcc behavior.
authorArtem Belevich <tra@google.com>
Fri, 12 Feb 2016 18:29:18 +0000 (18:29 +0000)
committerArtem Belevich <tra@google.com>
Fri, 12 Feb 2016 18:29:18 +0000 (18:29 +0000)
commit186091094ae7c9d9afd438842057e892303686c8
treea633fb26ce11cbf36e23798d870f5710bcf24d06
parent996ad1fa0019d5ec1f5c3a9a306339a37470be0a
[CUDA] Tweak attribute-based overload resolution to match nvcc behavior.

This is an artefact of split-mode CUDA compilation that we need to
mimic. HD functions are sometimes allowed to call H or D functions. Due
to split compilation mode device-side compilation will not see host-only
function and thus they will not be considered at all. For clang both H
and D variants will become function overloads visible to
compiler. Normally target attribute is considered only if C++ rules can
not determine which function is better. However in this case we need to
ignore functions that would not be present during current compilation
phase before we apply normal overload resolution rules.

Changes:
* introduced another level of call preference to better describe
  possible call combinations.
* removed WrongSide functions from consideration if the set contains
  SameSide function.
* disabled H->D, D->H and G->H calls. These combinations are
  not allowed by CUDA and we were reluctantly allowing them to work
  around device-side calls to math functions in std namespace.
  We no longer need it after r258880.

Differential Revision: http://reviews.llvm.org/D16870

llvm-svn: 260697
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/CodeGenCUDA/function-overload.cu
clang/test/SemaCUDA/function-overload.cu