[llvm] [llvm][AArch64] Simplify reverse iteration fix in #217752. NFC (PR #217979)

Jon Roelofs via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 21 09:58:29 PDT 2026


https://github.com/jroelofs created https://github.com/llvm/llvm-project/pull/217979

This is a follow-up to ab0b549b6b9855e176f6f7ea3f9e5ffe930061c6 where vhscampos noticed that we were skipping MBBI in the backward search for SP adjustment FrameDestroy instructions. Since MBB always points at the PAUTH_EPILOGUE pseudo, there is no functional difference in this change, but it's worth simplifying that because the intent does not look obvious from construction, and we don't lose much from iterating over one extra instruction.

>From ac4786c83889729df2fef71ddfd6b641d18647c3 Mon Sep 17 00:00:00 2001
From: Jon Roelofs <jonathan_roelofs at apple.com>
Date: Fri, 21 Aug 2026 09:52:20 -0700
Subject: [PATCH] [llvm][AArch64] Simplify reverse iteration fix in #217752.
 NFC

This is a follow-up to ab0b549b6b9855e176f6f7ea3f9e5ffe930061c6 where vhscampos
noticed that we were skipping MBBI in the backward search for SP adjustment
FrameDestroy instructions. Since MBB always points at the PAUTH_EPILOGUE pseudo,
there is no functional difference in this change, but it's worth simplifying
that because the intent does not look obvious from construction, and we don't
lose much from iterating over one extra instruction.
---
 llvm/lib/Target/AArch64/AArch64PointerAuth.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp b/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp
index 374f42a02cc08..0e4a51286cf54 100644
--- a/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp
+++ b/llvm/lib/Target/AArch64/AArch64PointerAuth.cpp
@@ -327,7 +327,7 @@ void AArch64PointerAuthImpl::authenticateLR(
   int64_t Offset = -ArgumentStackToRestore;
   SmallVector<MachineInstr *, 2> SPMods;
   if (ArgumentStackToRestore > 0) {
-    for (MachineInstr &MI : reverse(make_range(MBB.begin(), MBBI))) {
+    for (MachineInstr &MI : make_range(MBBI.getReverse(), MBB.rend())) {
       if (!MI.getFlag(MachineInstr::FrameDestroy))
         break;
       if ((MI.getOpcode() == AArch64::ADDXri ||



More information about the llvm-commits mailing list