[all-commits] [llvm/llvm-project] d37a39: [CUDA][HIP] fix virtual dtor host/device attr (#12...

Yaxun (Sam) Liu via All-commits all-commits at lists.llvm.org
Mon Mar 3 07:23:56 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d37a39207bc15507e602e41b7655f615c10c9a1d
      https://github.com/llvm/llvm-project/commit/d37a39207bc15507e602e41b7655f615c10c9a1d
  Author: Yaxun (Sam) Liu <yaxun.liu at amd.com>
  Date:   2025-03-03 (Mon, 03 Mar 2025)

  Changed paths:
    M clang/docs/HIPSupport.rst
    M clang/lib/Sema/SemaCUDA.cpp
    M clang/test/SemaCUDA/dtor.cu

  Log Message:
  -----------
  [CUDA][HIP] fix virtual dtor host/device attr (#128926)

Currently if CUDA/HIP users use template class with virtual dtor
and std::string data member with C++20 and MSVC. When the template
class is explicitly instantiated, there is error about host
function called by host device function (used to be undefined
symbols in linking stage before member destructors were checked
by deferred diagnostics).

It was caused by clang inferring host/device attributes for
default dtors. Since all dtors of member and parent classes
have implicit host device attrs, clang infers the virtual dtor have
implicit host and device attrs. Since virtual dtor of
explicitly instantiated template class must be emitted,
this causes constexpr dtor of std::string emitted, which
calls a host function which was not emitted on device side.

This is a serious issue since it prevents users from
using std::string with C++20 on Windows.

When inferring host device attr of virtual dtor of explicit
template class instantiation, clang should be conservative
since it is sure to be emitted. Since an implicit host device
function may call a host function, clang cannot assume it is
always available on device. This guarantees dtors that
may call host functions not to have implicit device attr,
therefore will not be emitted on device side.

Fixes: https://github.com/llvm/llvm-project/issues/108548

Fixes: SWDEV-517435



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list