Page MenuHomePhabricator

[AMDGPU] Fix function calls with flat scratch
ClosedPublic

Authored by sebastian-ne on May 26 2021, 7:13 AM.

Details

Summary

When flat scratch is used, the stack pointer needs to be added when
writing arguments to the stack.
For buffer instructions, this is done in SelectMUBUFScratchOffen
and SelectMUBUFScratchOffset.

Diff Detail

Event Timeline

sebastian-ne created this revision.May 26 2021, 7:13 AM
sebastian-ne requested review of this revision.May 26 2021, 7:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2021, 7:13 AM
foad added a comment.May 26 2021, 7:39 AM

Does globalisel handle this?

Does globalisel handle this?

Similar code is needed in the AMDGPUInstructionSelector::selectScratchSAddr().

Does globalisel handle this?

Yes, it seems like globalisel handles adding the stack pointer in the AMDGPUOutgoingArgHandler. The code that adds the stack pointer in AMDGPUInstructionSelector::selectMUBUFScratchOffset is never hit, I’ll remove it.

I changed the handling in SDAG to match the one in GlobalISel. The stack pointer is now added when lowering call arguments and not when selecting instructions.

arsenm accepted this revision.May 27 2021, 5:53 PM

LGTM. This is nicer than inspecting the memory operand

This revision is now accepted and ready to land.May 27 2021, 5:53 PM
This revision was landed with ongoing or failed builds.May 28 2021, 2:33 AM
This revision was automatically updated to reflect the committed changes.