This is an archive of the discontinued LLVM Phabricator instance.

[ARM][RegisterScavenging] Don't consider LR liveout if it is not reloaded
ClosedPublic

Authored by tmatheson on Jan 25 2021, 7:07 AM.

Details

Summary

https://bugs.llvm.org/show_bug.cgi?id=48232

When PrologEpilogInserter writes callee-saved registers to the stack, LR is not reloaded but is instead loaded directly into PC.
This was not taken into account when determining if each callee-saved register was liveout for the block.
When frame elimination inserts virtual registers, and the register scavenger tries to scavenge LR, it considers it liveout and tries to spill again.
However there is no emergency spill slot to use, and it fails with an error:

fatal error: error in backend: Error while trying to spill LR from class GPR: Cannot scavenge register without an emergency spill slot!

This patch pervents any callee-saved registers which are not reloaded (including LR) from being marked liveout.
They are therefore available to scavenge without requiring an extra spill.

Diff Detail

Event Timeline

tmatheson created this revision.Jan 25 2021, 7:07 AM
tmatheson requested review of this revision.Jan 25 2021, 7:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2021, 7:07 AM
This revision is now accepted and ready to land.Jan 27 2021, 6:44 AM
pirama added a subscriber: pirama.Jan 27 2021, 10:05 AM