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

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 16 06:16:38 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-bolt

Author: Ash Dobrescu (Rin18)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/144348.diff


1 Files Affected:

- (modified) bolt/include/bolt/Core/BinaryFunction.h (+1-1) 


``````````diff
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;
     }

``````````

</details>


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


More information about the llvm-commits mailing list