This is an archive of the discontinued LLVM Phabricator instance.

RegScavenger: Add function to externally reserve a scavenging index
ClosedPublic

Authored by arsenm on Dec 8 2021, 2:02 PM.

Details

Summary

AMDGPU separately tracks the frame index we use for the emergency
spill slot. In the case where we need to spill SGPRs to memory, we
manually handle the save and restore. In other cases, the scavenger
handles the spills normally.

In a future change, I will need to add a second scavenging index in
order to free a second register in case we are spilling to a large
offset and also have to avoid clobbering a condition register
(SCC). In the intersection of these two cases, we will end up
recursively calling eliminateFrameIndex. We need to report to the
scavenger that the first scavenging frame index is unavailable, and
that the register is already used to avoid double spilling to the
scavenging slot (and avoid clobbering the previously evicted register,
and getting the same register for both scavenge calls).

This is really ugly but I don't see a better way without requiring
targets to be far more aware of how the scavenger iterator is
advanced.

Diff Detail