This is an archive of the discontinued LLVM Phabricator instance.

[HIP] add __builtin_get_device_side_mangled_name
ClosedPublic

Authored by yaxunl on Mar 24 2021, 2:38 PM.

Details

Summary

Add builtin function __builtin_get_device_side_mangled_name
to get device side manged name for functions and global
variables, which can be used to get symbol address of kernels
or variables by mangled name in dynamically loaded
bundled code objects at run time.

Diff Detail

Event Timeline

yaxunl requested review of this revision.Mar 24 2021, 2:38 PM
yaxunl created this revision.
tra accepted this revision.Mar 24 2021, 3:24 PM

LGTM with a couple of nits.

clang/include/clang/Basic/Builtins.h
39

The issue is common for both CUDA and HIP.

clang/include/clang/Basic/DiagnosticSemaKinds.td
8310

Nit. I'd rephrase it in terms of what makes the argument invalid. E.g. symbol must be a device-side function or global variable.

clang/lib/Basic/Builtins.cpp
78

Please enable it for CUDA, too.

78–84

Wow! The density of negations in this function is impressive.

clang/lib/Sema/SemaChecking.cpp
1980–1983
return D->hasAttr<CUDAGlobalAttr>() || D->hasAttr<CUDADeviceAttr>() ||
        D->hasAttr<CUDAConstantAttr>() || D->hasAttr<HIPManagedAttr>();
This revision is now accepted and ready to land.Mar 24 2021, 3:24 PM
yaxunl updated this revision to Diff 333296.Mar 25 2021, 7:08 AM
yaxunl marked 5 inline comments as done.

Revised by Artem's comments.

yaxunl added inline comments.Mar 25 2021, 7:26 AM
clang/include/clang/Basic/Builtins.h
39

will rename it to CUDA_LANG

clang/include/clang/Basic/DiagnosticSemaKinds.td
8310

will do

clang/lib/Basic/Builtins.cpp
78

will do

clang/lib/Sema/SemaChecking.cpp
1980–1983

will do

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2021, 12:26 PM