This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Don't remove VGPR to AGPR dead spills from frame info
ClosedPublic

Authored by bcahoon on Dec 18 2021, 1:24 PM.

Details

Summary

Removing dead frame indices for VGPR to AGPR spills is incorrect
when the frame index is shared by multiple objects, which may
occur due to stack slot coloring. The problem is that subsequent
code processes the other object will assert because the stack
frame index has been marked dead.

Removing dead frame indices is needed prior to stack slot
coloring, which is what happens with SGPR to VGPR spills. These
spills are lowered prior to stack slot coloring, but the VGPR
to AGPR spills are processed afterwards during the Prolog/Epilog
Inserter pass.

Diff Detail

Event Timeline

bcahoon created this revision.Dec 18 2021, 1:24 PM
bcahoon requested review of this revision.Dec 18 2021, 1:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 18 2021, 1:24 PM
bcahoon retitled this revision from [AMDGPR] Don't remove VGPR to AGPR dead spills from frame info to [AMDGPU] Don't remove VGPR to AGPR dead spills from frame info.Dec 18 2021, 1:29 PM
foad added a comment.Dec 20 2021, 5:52 AM

Typo in summary "pills".

bcahoon edited the summary of this revision. (Show Details)Dec 20 2021, 6:59 AM
arsenm accepted this revision.Dec 20 2021, 8:09 AM
arsenm added a subscriber: cdevadas.

Can we rip out this special "spill" handling since D109301 @cdevadas

This revision is now accepted and ready to land.Dec 20 2021, 8:09 AM

Can we rip out this special "spill" handling since D109301 @cdevadas

I has unsolved problem with partial tuple spill. There is no partial copy.

Will the slot remain in the final allocation?

Can we rip out this special "spill" handling since D109301 @cdevadas

I has unsolved problem with partial tuple spill. There is no partial copy.

I'm not sure how we are going to handle this partial copy differently.
The equivalent for partial-copy during regalloc would be possible only if the tryInstructionSplit inserts partial copy followed by the InlineSpiller handling the leftover tuple spills.
Currently, the former doesn't handle partial copy and the latter doesn't insert subrange tuple spills/restores.
Even if they are equipped to handle partial copy and spill, how do these independent functions communicate each other the exact tuple subrange that the other suppose to handle?

Will the slot remain in the final allocation?

Yes. At least in the example I'm seeing.

Will the slot remain in the final allocation?

Yes. At least in the example I'm seeing.

Is there any way to get rid of them? Check they are actually dead, or move code later?

Will the slot remain in the final allocation?

Yes. At least in the example I'm seeing.

Is there any way to get rid of them? Check they are actually dead, or move code later?

Let me think about this a little and see if I can come up with a way to remove them if they are actually dead.

bcahoon updated this revision to Diff 395937.Dec 22 2021, 3:08 PM

Changes so that the VGPR to AGPR spill slot can be removed if stack slot coloring has not allocated multiple objects to the same slot. Added a couple extra test cases to check for different cases when the slot can/can't be removed.

rampitec accepted this revision.Dec 22 2021, 3:12 PM

Thanks! LGTM.

This revision was landed with ongoing or failed builds.Dec 23 2021, 9:12 AM
This revision was automatically updated to reflect the committed changes.