[llvm] [AArch64] Fix miscompilation due to integer overflow in immediate offset for stack store/load instructions with preserve_all (PR #207026)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 08:26:51 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Target/AArch64/AArch64FrameLowering.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
index 369b54d1c..a23c2833e 100644
--- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
@@ -1801,7 +1801,8 @@ void computeCalleeSaveRegisterPairs(const AArch64FrameLowering &AFL,
       int Aligned = AlignOffset(ByteOffset, Scale);
       int PairOffset = IsWindows ? Aligned : Aligned + StackFillDir * 2 * Scale;
       // True when the pair's ldp/stp offset fits the signed 7-bit scaled imm.
-      bool PairFitsImmRange = PairOffset / Scale >= -64 && PairOffset / Scale <= 63;
+      bool PairFitsImmRange =
+          PairOffset / Scale >= -64 && PairOffset / Scale <= 63;
       switch (RPI.Type) {
       case RegPairInfo::GPR:
         if (AArch64::GPR64RegClass.contains(NextReg) && PairFitsImmRange &&

``````````

</details>


https://github.com/llvm/llvm-project/pull/207026


More information about the llvm-commits mailing list