[AArch64] Do not fold SP adjustments into pre-increment addr modes if it overflows...
authorAmara Emerson <amara@apple.com>
Thu, 21 Jan 2021 22:54:26 +0000 (14:54 -0800)
committerAmara Emerson <amara@apple.com>
Wed, 24 Feb 2021 17:55:48 +0000 (09:55 -0800)
commit0146d206317e1d40775621639a4dde7c43e0f433
tree74347310932a669e9402b618b02d8f47c08a0192
parentb146dfe527ba81297d2949fc423e66c869bf926a
[AArch64] Do not fold SP adjustments into pre-increment addr modes if it overflows the redzone.

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

Differential Revision: https://reviews.llvm.org/D95179
llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.h
llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
llvm/test/CodeGen/AArch64/ldst-nopreidx-sp-redzone.mir [new file with mode: 0644]