[all-commits] [llvm/llvm-project] 3a203a: [CUDA][HIP] Defer device diagnostics in implicit H...
Yaxun (Sam) Liu via All-commits
all-commits at lists.llvm.org
Wed May 27 11:13:18 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 3a203a506691df098ae1020dfb14e411d25bec35
https://github.com/llvm/llvm-project/commit/3a203a506691df098ae1020dfb14e411d25bec35
Author: Yaxun (Sam) Liu <yaxun.liu at amd.com>
Date: 2026-05-27 (Wed, 27 May 2026)
Changed paths:
M clang/include/clang/AST/ASTContext.h
M clang/include/clang/AST/Decl.h
M clang/include/clang/Sema/SemaCUDA.h
M clang/lib/AST/Decl.cpp
M clang/lib/CodeGen/CGCXX.cpp
M clang/lib/CodeGen/CGVTables.cpp
M clang/lib/CodeGen/CodeGenModule.cpp
M clang/lib/CodeGen/CodeGenModule.h
M clang/lib/Sema/Sema.cpp
M clang/lib/Sema/SemaBase.cpp
M clang/lib/Sema/SemaCUDA.cpp
M clang/lib/Sema/SemaDecl.cpp
M clang/test/CodeGenCUDA/device-vtable.cu
A clang/test/CodeGenCUDA/implicit-hd-dtor-trap-stub-hip.hip
A clang/test/CodeGenCUDA/implicit-hd-explicit-inst-hip.hip
A clang/test/CodeGenCUDA/implicit-hd-overload-ambig-hip.hip
M clang/test/SemaCUDA/dtor.cu
A clang/test/SemaCUDA/implicit-hd-dtor-explicit-instantiation.cu
A clang/test/SemaCUDA/implicit-hd-explicit-inst-organic-caller.cu
A clang/test/SemaCUDA/implicit-hd-overload-ambig-organic-caller.cu
Log Message:
-----------
[CUDA][HIP] Defer device diagnostics in implicit H+D explicit instantiations (#197214)
When clang explicitly instantiates a class template, it must emit
device-side
bodies for the implicit `__host__ __device__` members so the vtable and
instantiation symbols resolve. Some of those members chain into
host-only
calls (for example libstdc++ destructors that eventually call ::operator
delete). If no device code actually uses the class, the user still sees
errors about calling a `__host__` function from device code, even though
they
wrote no device code that touches it. Overload ambiguity in the same
context
behaves the same way.
This patch defers device-side errors in implicit `__host__ __device__`
functions reached only via an explicit template instantiation. At the
end of
the translation unit, clang checks whether a real device caller exists.
If
one does, the deferred errors are surfaced with the usual call-stack
notes.
If not, the diagnostics are dropped and the function gets a trap body,
so the
vtable and instantiation symbols stay well-formed and the failure only
fires
if device code ever calls the function. This works without
-fgpu-defer-diag.
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