[llvm] [BOLT] Introduce helpers to match `MCInst`s one at a time (NFC) (PR #138883)

Maksim Panchenko via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 27 16:10:51 PDT 2025


================
@@ -389,81 +390,58 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
 
     // Iterate over the instructions of BB in reverse order, matching opcodes
     // and operands.
-    MCPhysReg TestedReg = 0;
-    MCPhysReg ScratchReg = 0;
+
     auto It = BB.end();
-    auto StepAndGetOpcode = [&It, &BB]() -> int {
-      if (It == BB.begin())
-        return -1;
-      --It;
-      return It->getOpcode();
+    auto StepBack = [&]() {
+      while (It != BB.begin()) {
+        --It;
+        if (!isCFI(*It))
----------------
maksfb wrote:

While virtually identical, you likely want `isPseudo()`.

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


More information about the llvm-commits mailing list