[PATCH] D16870: [CUDA] Tweak attribute-based overload resolution to match nvcc behavior.

Artem Belevich via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 3 16:25:13 PST 2016


tra created this revision.
tra added reviewers: jlebar, jingyue, jpienaar, eliben.
tra added a subscriber: cfe-commits.

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
discard functions that would not be present during current compilation
phase before we apply normal overload resolution rules.

Changes:
* introduce another level of call preference to better describe
  possible call combinations.
* added early check for calls matching scenario above
  in isBetterOverloadCandidate().
* disabled H->D and 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.


http://reviews.llvm.org/D16870

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16870.46849.patch
Type: text/x-patch
Size: 10956 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160204/ad6bddfc/attachment.bin>


More information about the cfe-commits mailing list