[llvm] [AArch64] Fix miscompilation due to integer overflow in immediate offset for stack store/load instructions with preserve_all (PR #207026)
Ömer Sinan Ağacan via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 2 01:38:53 PDT 2026
================
@@ -1794,27 +1784,39 @@ void computeCalleeSaveRegisterPairs(const AArch64FrameLowering &AFL,
bool NeedsWinCFI = AFL.needsWinCFI(MF);
int Scale = TRI->getSpillSize(*RPI.RC);
+ // A paired LDP/STP can only encode a signed 7-bit scaled offset ([-64,
+ // 63]). When the callee-save area is large (e.g. preserve_all spills 30+
+ // registers), the highest pairs fall outside that range. Only pair if the
+ // resulting offset is encodable; otherwise leave the register unpaired and
+ // let it be spilled with a single STR/LDR, which has a much wider 12-bit
+ // immediate.
----------------
osa1 wrote:
I feel like the 4 lines of straightforward code below doesn't require this much documentation. Was this generated by AI? (please declare it if it is, per https://llvm.org/docs/AIToolPolicy.html)
https://github.com/llvm/llvm-project/pull/207026
More information about the llvm-commits
mailing list