[CUDA] Make vtable construction aware of host/device side of CUDA compilation.
authorArtem Belevich <tra@google.com>
Thu, 17 Dec 2015 18:12:36 +0000 (18:12 +0000)
committerArtem Belevich <tra@google.com>
Thu, 17 Dec 2015 18:12:36 +0000 (18:12 +0000)
commit9b9294674b879d260b61b9176bc88a02d00265ac
treea2cfad9265c4c029413047290540cb7a316add40
parent8b524597efcef4ff37f667195516e468be66da6f
[CUDA] Make vtable construction aware of host/device side of CUDA compilation.

C++ emits vtables for classes that have key function present in the
current TU. While we compile CUDA the fact that key function was found
in this TU does not mean that we are going to generate code for it. E.g.
vtable for a class with host-only methods should not (and can not) be
generated on device side, because we'll never generate code for them
during device-side compilation.

This patch adds an extra CUDA-specific check during key method computation
and filters out potential key methods that are not suitable for this side
of CUDA compilation.

When we codegen vtable, entries for unsuitable methods are set to null.

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

llvm-svn: 255911
clang/lib/AST/RecordLayoutBuilder.cpp
clang/lib/CodeGen/CGVTables.cpp
clang/test/CodeGenCUDA/device-vtable.cu [new file with mode: 0644]