[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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260697 91177308-0d34-0410-b5e6-96231b3b80d8
Showing
- include/clang/Sema/Sema.h 9 additions, 3 deletionsinclude/clang/Sema/Sema.h
- lib/Sema/SemaCUDA.cpp 39 additions, 40 deletionslib/Sema/SemaCUDA.cpp
- lib/Sema/SemaOverload.cpp 33 additions, 3 deletionslib/Sema/SemaOverload.cpp
- test/CodeGenCUDA/function-overload.cu 106 additions, 17 deletionstest/CodeGenCUDA/function-overload.cu
- test/SemaCUDA/function-overload.cu 20 additions, 33 deletionstest/SemaCUDA/function-overload.cu
Loading
Please register or sign in to comment