This is an archive of the discontinued LLVM Phabricator instance.

[regalloc] Don't align stack slots if the stack can't be realigned
ClosedPublic

Authored by tmatheson on Jun 3 2021, 2:41 AM.

Details

Summary

Register allocation may spill virtual registers to the stack, which can
increase alignment requirements of the stack frame. If the the function
did not require stack realignment before register allocation, the
registers required to do so may not be reserved/available. This results
in a stack frame that requires realignment but can not be realigned.

Instead, only increase the alignment of the stack if we are still able
to realign.

The register SpillAlignment will be ignored if we can't realign, and the
backend will be responsible for emitting the correct unaligned loads and
stores. This seems to be the assumed behaviour already, e.g.
ARMBaseInstrInfo::storeRegToStackSlot and X86InstrInfo::storeRegToStackSlot
are both canRealignStack aware.

Diff Detail

Event Timeline

tmatheson created this revision.Jun 3 2021, 2:41 AM
tmatheson requested review of this revision.Jun 3 2021, 2:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 3 2021, 2:41 AM
tmatheson retitled this revision from [CodeGen][regalloc] Don't align stack slots if the stack can't be realigned to [regalloc] Don't align stack slots if the stack can't be realigned.Jun 3 2021, 2:41 AM
This revision is now accepted and ready to land.Jun 3 2021, 9:25 AM
tmatheson updated this revision to Diff 351448.Jun 11 2021, 7:47 AM

Rebase and update tests