[llvm] [BOLT] Ensure remember and restore CFIs are in the same list (PR #144348)

Ash Dobrescu via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 16 06:15:48 PDT 2025


https://github.com/Rin18 created https://github.com/llvm/llvm-project/pull/144348

In `addCFIInstruction`, we split the CFI information between `CFIInstrMapType CIEFrameInstructions` and `CFIInstrMapType FrameInstructions`. In some cases we can end up with the remember CFI in `CIEFrameInstructions` and the restore CFI in `FrameInstructions`. This patch adds a check to make sure we do not split remember and restore states and fixes https://github.com/llvm/llvm-project/issues/133501.

>From d8a6f1acd8aafab73475a220b88670173ea4104a Mon Sep 17 00:00:00 2001
From: Ash Dobrescu <ash.dobrescu at arm.com>
Date: Mon, 16 Jun 2025 13:05:02 +0000
Subject: [PATCH] [BOLT] Ensure remember and restore CFIs are in the same list

---
 bolt/include/bolt/Core/BinaryFunction.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bolt/include/bolt/Core/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h
index ca8b786f4ab69..828c56d818b09 100644
--- a/bolt/include/bolt/Core/BinaryFunction.h
+++ b/bolt/include/bolt/Core/BinaryFunction.h
@@ -1663,7 +1663,7 @@ class BinaryFunction {
       Offset = I->first;
     }
     assert(I->first == Offset && "CFI pointing to unknown instruction");
-    if (I == Instructions.begin()) {
+    if (I == Instructions.begin() && Inst.getOperation() != MCCFIInstruction::OpRememberState) {
       CIEFrameInstructions.emplace_back(std::forward<MCCFIInstruction>(Inst));
       return;
     }



More information about the llvm-commits mailing list