This is an archive of the discontinued LLVM Phabricator instance.

[amdgpu][lds] Raise an explicit unimplemented error on absolute address LDS variables
ClosedPublic

Authored by JonChesterfield on Jul 12 2023, 3:36 PM.

Details

Summary

These aren't implemented. They could be at moderate implementation
complexity. Raising an error is better than silently miscompiling.

Patching now because the patch at D155125 is a step towards using this metadata
more extensively as part of the lowering path and that will interact badly with
input variables with this annotation.

Lowering user defined variables at specific addresses would drop this error,
put them at the requested position in the frame during this pass, and then
use the same codegen that will be used for the kernel specific struct shortly.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2023, 3:36 PM
JonChesterfield requested review of this revision.Jul 12 2023, 3:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2023, 3:36 PM
jmmartinez accepted this revision.Jul 13 2023, 1:02 AM

Looks good to me. If you think it's relevant to privde a better diagnostic with the souce location I'd welcome that change.

I was thinking about using LLVMContext::diagnose + DiagnosticInfoUnsupported but it seems there is no alternative for GlobalVariables (only for Functions) and adding support for it is a whole other patch.

This revision is now accepted and ready to land.Jul 13 2023, 1:02 AM
This revision was landed with ongoing or failed builds.Jul 13 2023, 3:32 AM
This revision was automatically updated to reflect the committed changes.

I was thinking about using LLVMContext::diagnose + DiagnosticInfoUnsupported but it seems there is no alternative for GlobalVariables (only for Functions) and adding support for it is a whole other patch.

Interesting. That probably is something LLVM should have available. In this case, I'm hoping we'll implement this (put the variable at the requested location in the kernels that can reach it) as opposed to improving the diagnostics, though that may be unimplementable in the context of separate compilation (which is also not yet implemented).

arsenm added inline comments.Jul 13 2023, 7:17 AM
llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
358

LLVMContext::emitError is a lazier way than going through the full diagnostic. You still need to produce some result though, so usually just replace with poison/undef

arsenm added inline comments.Jul 13 2023, 7:18 AM
llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
358

I just looked at the implementation and it is emitting a diagnostic, but assuming it's related to inlineasm for some reason