This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU: Avoid endpgm in middle of block for fallback trap lowering.
ClosedPublic

Authored by arsenm on Jun 7 2023, 4:20 PM.

Details

Reviewers
JonChesterfield
kzhuravl
Pierre-vh
rampitec
ruiling
critson
Group Reviewers
Restricted Project
Summary

This was inserting an s_endpgm in the middle of the block when it has
to be a terminator. Split the block and insert a branch to a new block
with the trap if it's not in a terminator position.

Fixes verifier error on LDS in function with no trap support (and
other trap sources).

Diff Detail

Event Timeline

arsenm created this revision.Jun 7 2023, 4:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2023, 4:20 PM
arsenm requested review of this revision.Jun 7 2023, 4:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2023, 4:20 PM
Herald added a subscriber: wdng. · View Herald Transcript
ruiling accepted this revision.Jun 7 2023, 6:37 PM

I think we definitely should do this! just one inline comment.

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
5669

I am not sure whether BB might have a fall-through successor here, an assertion saying that won't happen might be helpful. We not only want s_endpgm be terminator, but also the end of function.

This revision is now accepted and ready to land.Jun 7 2023, 6:37 PM
arsenm updated this revision to Diff 529576.Jun 8 2023, 6:30 AM
arsenm marked an inline comment as done.

Check for fallthrough