This is an archive of the discontinued LLVM Phabricator instance.

[CUDA][HIP] Externalize device var in anonymous namespace
ClosedPublic

Authored by yaxunl on Jun 5 2023, 7:27 AM.

Details

Summary

Device variables in an anonymous namespace may be
referenced by host code, therefore they need to
be externalized in a similar way as a static device
variables or kernels in an anonymous namespace.

Fixes: https://github.com/ROCm-Developer-Tools/HIP/issues/3246

Diff Detail

Event Timeline

yaxunl created this revision.Jun 5 2023, 7:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2023, 7:27 AM
Herald added a subscriber: mattd. · View Herald Transcript
yaxunl requested review of this revision.Jun 5 2023, 7:27 AM
yaxunl updated this revision to Diff 528447.Jun 5 2023, 8:00 AM

add a test to make sure device var in an anonymous namespace is not externalized if used by device code only.

tra accepted this revision.Jun 5 2023, 10:20 AM
tra added inline comments.
clang/test/CodeGenCUDA/anon-ns.cu
47

Nit: I'd rename the patterns to reflect the names of the source entities they track, so we don't have to dig through multiple dependent matches in order to figure out what the test does.
E.g. for tempKern : KERN3, STR3 -> TKERN, TKERNSTR.

Maybe give kernels/variables more distinct names as well. My brain keeps trying to interpret temp as temporary.
A common naming scheme would be nice. E.g. tk, tv for the template kernel and variable, a* for anonymous entities.

This revision is now accepted and ready to land.Jun 5 2023, 10:20 AM
yaxunl marked an inline comment as done.Jun 5 2023, 11:13 AM
yaxunl added inline comments.
clang/test/CodeGenCUDA/anon-ns.cu
47

will do. thanks.

This revision was landed with ongoing or failed builds.Jun 6 2023, 9:04 AM
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptJun 6 2023, 9:04 AM
clang/test/CodeGenCUDA/host-used-device-var.cu