Skip to content

[TEST ONLY][CUDA][HIP] Defer diagnostics for unused implicit H+D functions#3066

Open
yxsamliu wants to merge 1 commit into
ROCm:amd-stagingfrom
yxsamliu:amd/dev/yaxunl/implicit-hd-defer-unused-device-diags-dev
Open

[TEST ONLY][CUDA][HIP] Defer diagnostics for unused implicit H+D functions#3066
yxsamliu wants to merge 1 commit into
ROCm:amd-stagingfrom
yxsamliu:amd/dev/yaxunl/implicit-hd-defer-unused-device-diags-dev

Conversation

@yxsamliu

@yxsamliu yxsamliu commented Jun 25, 2026

Copy link
Copy Markdown

Test-only ROCm amd-staging PR for llvm#205828.

The amd-staging base already includes the prerequisite upstream change:

This branch contains the generic follow-up:

  • [CUDA][HIP] Defer diagnostics for unused implicit H+D functions

@yxsamliu yxsamliu force-pushed the amd/dev/yaxunl/implicit-hd-defer-unused-device-diags-dev branch from cdec34a to 8da2324 Compare June 25, 2026 17:57
@yxsamliu yxsamliu changed the base branch from amd-main to amd-staging June 25, 2026 17:58
Implicit H+D attributes are usually added to host functions by speculative, optimistic heuristics. For example, constexpr functions are implicitly marked H+D assuming they only call other constexpr functions and therefore work on both host and device. In practice, a constexpr function can still call a non-constexpr host function on a runtime path, which makes that body unusable for device code.

A recent PR fixed this for implicit H+D functions forced by explicit instantiation: defer device diagnostics until end of TU, then either emit them for an organic device caller or discard them and use the trap-body fallback if CodeGen still needs a device symbol.

The same reasoning applies to any implicit H+D function. The device side is speculative until real device code reaches it, so defer these diagnostics generally. This avoids rejecting host-only uses while preserving diagnostics for real device callers.
@yxsamliu yxsamliu force-pushed the amd/dev/yaxunl/implicit-hd-defer-unused-device-diags-dev branch from 8da2324 to 2feefb5 Compare June 26, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant