This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][GlobalISel] Shaders can only call amdgpu_gfx
AbandonedPublic

Authored by rovka on Jun 13 2023, 2:58 AM.

Details

Reviewers
arsenm
sebastian-ne
nhaehnle
foad
Group Reviewers
Restricted Project
Summary

SelectionDAG does not allow calls:

  • to shaders
  • from shaders to functions with calling conventions other than amdgpu_gfx

This patch essentially copies that code into GlobalISel and enables one
of the existing SelectionDAG tests for GlobalISel as well (with a couple
of FIXMEs not tackled in this patch).

It also removes an existing test that was added in
https://reviews.llvm.org/D117479
citing llvm-reduce's penchant for replacing calls to intrinsics with
calls to undef/null (while keeping the default, C calling convention).
That sounds like an important use case, but maybe a better solution for
that problem would be to teach llvm-reduce to replace the whole call
with an undef/null. (Since intrinsics often don't get lowered to calls
at all, replacing an intrinsic with a call would increase complexity rather
than reduce it.)

Diff Detail

Event Timeline

rovka created this revision.Jun 13 2023, 2:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 2:58 AM
rovka requested review of this revision.Jun 13 2023, 2:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 2:58 AM
rovka added reviewers: Restricted Project, arsenm, sebastian-ne, nhaehnle, foad.Jun 13 2023, 3:00 AM
rovka edited the summary of this revision. (Show Details)Jun 13 2023, 3:13 AM

That sounds like an important use case, but maybe a better solution for
that problem would be to teach llvm-reduce to replace the whole call
with an undef/null.

No, because that would delete the call entirely which is a much more substantial change.

I'd lean towards just removing this artificial restriction / error altogether before regressing this. Passing undefined inputs seems fine, we could have a lint check for this instead.

llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call.ll
5295

This shouldn't be dropped

nhaehnle added inline comments.Jun 19 2023, 9:16 AM
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call.ll
5295

Do you have a better idea? We can't meaningfully support calls to C calling convention from shaders...

arsenm added inline comments.Jun 19 2023, 10:04 AM
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call.ll
5295

What this was doing and passing undef to missing inputs

nhaehnle added inline comments.Jun 20 2023, 12:00 AM
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call.ll
5295

Okay fair enough.

rovka abandoned this revision.Jun 20 2023, 12:22 AM

Ok, thanks for clarifying, I'll send a patch for that then :)