[llvm] [win][x64] Unwind v2: When making headroom leave space for the header (PR #188368)
Daniel Paoliello via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 24 15:47:34 PDT 2026
https://github.com/dpaoliello created https://github.com/llvm/llvm-project/pull/188368
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.
>From 1ba6d234d5a4aaf50a7cabdd8f8f975517d5b246 Mon Sep 17 00:00:00 2001
From: "Daniel Paoliello (HE/HIM)" <danpao at microsoft.com>
Date: Fri, 20 Mar 2026 14:46:16 -0700
Subject: [PATCH] [win][x64] Unwind v2: When making headroom leave space for
the header
---
llvm/lib/MC/MCWin64EH.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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)) {
More information about the llvm-commits
mailing list