[llvm] [win][x64] Unwind v2: When making headroom leave space for the header (PR #188368)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 24 15:48:11 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-mc

Author: Daniel Paoliello (dpaoliello)

<details>
<summary>Changes</summary>

When the `ensureHeadroom` call was added during unwind v2 info emission, it didn't take into account that there is a header of 2-bytes before all the fixups, so not enough space was actually reserved.

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


1 Files Affected:

- (modified) llvm/lib/MC/MCWin64EH.cpp (+2-1) 


``````````diff
diff --git a/llvm/lib/MC/MCWin64EH.cpp b/llvm/lib/MC/MCWin64EH.cpp
index e88c37d22ebea..32f701019e528 100644
--- a/llvm/lib/MC/MCWin64EH.cpp
+++ b/llvm/lib/MC/MCWin64EH.cpp
@@ -335,7 +335,8 @@ static void EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info) {
   // Emit the epilog instructions.
   if (EnableUnwindV2) {
     // Ensure the fixups and appended content apply to the same fragment.
-    OS->ensureHeadroom(info->EpilogMap.size() * 2);
+    // size byte + flags byte + 2 per epilog (for the distance).
+    OS->ensureHeadroom(2 + info->EpilogMap.size() * 2);
 
     bool IsLast = true;
     for (const auto &Epilog : llvm::reverse(info->EpilogMap)) {

``````````

</details>


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


More information about the llvm-commits mailing list