This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Do not fold SP adjustments into pre-increment addr modes if it overflows the redzone.
ClosedPublic

Authored by aemerson on Jan 21 2021, 2:58 PM.

Details

Summary

Instead of outright disabling this completely with the noredzone attribute, we only avoid doing the optimization if there are memory operations between the adjustment and the load/store that the adjustment would be folded into. This avoids the case of something like a stack cookie being corrupted if an exception happens before the pre-increment to the SP occurs.

This also prevents the folding happening if we have a redzone, but the offset being folded is above the redzone amount (128 bytes in this case).

rdar://73269336

Diff Detail

Event Timeline

aemerson created this revision.Jan 21 2021, 2:58 PM
aemerson requested review of this revision.Jan 21 2021, 2:58 PM

Is there a check that this folding doesn't overrun a red-zone if it does exist? If not, fixing that could well lead to a more natural way to solve this (where the bounds being checked are just 0 if there's no red-zone).

Is there a check that this folding doesn't overrun a red-zone if it does exist? If not, fixing that could well lead to a more natural way to solve this (where the bounds being checked are just 0 if there's no red-zone).

Yeah, that's a good idea.

aemerson updated this revision to Diff 325509.Feb 22 2021, 11:31 AM
aemerson retitled this revision from [AArch64] Do not fold SP adjustments into pre-increment addr modes with noredzone. to [AArch64] Do not fold SP adjustments into pre-increment addr modes if it overflows the redzone..
aemerson edited the summary of this revision. (Show Details)

Prevent folding in the offset if it's too large, even if we have a red zone.

t.p.northover accepted this revision.Feb 24 2021, 6:57 AM

Thanks. LGTM.

This revision is now accepted and ready to land.Feb 24 2021, 6:57 AM