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 be generated on
device side, because we are not going to generate any code for the
host-only methods during device-side compilation.
For classes that mix host and device virtual methods, nvcc generates vtable
with null pointers for methods that are not available on the current side.
- During key method calculation only considers methods valid for the current CUDA compilation. This prevents vtable generation for classes that have no virtual methods usable on this side of CUDA compilation.
- For vtables we emit during current CUDA compilation, entries for the methods that are not valid in this mode are set to null. This allows us to generate valid vtables for classes that have mix of host/device virtual methods.