[Clang][CUDA] Fix deferred H+D diags after 3a203a506691 (#37564)
Fix SemaCUDA/implicit-hd-explicit-inst-organic-caller.cu and
SemaCUDA/implicit-hd-overload-ambig-organic-caller.cu, which broke after
commit 3a203a506691 ([CUDA][HIP] Defer device diagnostics in implicit
H+D
explicit instantiations, #197214).
Upstream #197214 implements the feature on a collect-then-emit deferred
diagnostics model: the traversal collects per-function diagnostics,
ClassifyImplicitHDExplicitInst() drops the errors of implicit-H+D
explicit-instantiation functions that have no organic device caller, and
a
final DDE.emitCollectedDiags() emits whatever remains exactly once.
xmain long ago replaced that model with an inline-emit one (the upstream
"Speed up deferred diagnostic emitter" change):
DeferredDiagnosticsEmitter::
checkFunc emits each function's deferred diagnostics during traversal
and
there is no emitCollectedDiags. The pulldown conflict resolution for
kept ClassifyImplicitHDExplicitInst() but dropped the (nonexistent)
emitCollectedDiags call, so the new classification ran too late: an
implicit-H+D explicit-instantiation member was emitted inline both as a
bare emitted root and via the organic caller path, producing a duplicate
error with a truncated call stack.
Adapt the feature to xmain's inline model:
- Skip the inline emission in checkFunc for implicit-H+D
explicit-instantiation
functions so their diagnostics are not surfaced during traversal.
- In ClassifyImplicitHDExplicitInst, when an organic device caller
exists,
surface the deferred diagnostics here with the usual call-stack notes;
otherwise keep dropping them and emitting a trap body as before.
Intel-specific adaptation guarded with INTEL_CUSTOMIZATION.
Fixes: CMPLRLLVM-75875
This should be reverted once
https://jira.devtools.intel.com/browse/CMPLRLLVM-74216 is done to reland
[cc4ff7fe4f71d18e666018dc270a43726bb3457a](https://github.com/intel-restricted/applications.compilers.llvm-project/commit/cc4ff7fe4f71d18e666018dc270a43726bb3457a).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>