[llvm] [MC] [Win64EH] Clarify the Windows versions with bugs that are avoided (PR #169784)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 28 03:10:02 PST 2025


https://github.com/mstorsjo updated https://github.com/llvm/llvm-project/pull/169784

>From 725194ad5caae34359600a234cc8432abf4f02b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Thu, 27 Nov 2025 11:58:50 +0200
Subject: [PATCH] [MC] [Win64EH] Clarify the comment about a skipped case of
 packed unwind info

Clarify the comment from 924defada9bc0e3c89b0c0e288d7cb4dd654e7d4.
There is no longer any ambiguity about this case; newer versions
of Windows correctly match the documentation, making it clear that
the older versions were incorrect. Mention specific versions that have
and don't have the inconsistency.

Even if we wouldn't care about the older versions of Windows, we can't
enable this case of unwind info packing, unless the implementation
also is changed to match for assymetrical prologs/epilogs.
---
 llvm/lib/MC/MCWin64EH.cpp | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/MC/MCWin64EH.cpp b/llvm/lib/MC/MCWin64EH.cpp
index 6d146f6cedd6e..ac285a14c6bd7 100644
--- a/llvm/lib/MC/MCWin64EH.cpp
+++ b/llvm/lib/MC/MCWin64EH.cpp
@@ -1252,14 +1252,21 @@ static bool tryARM64PackedUnwind(WinEH::FrameInfo *info, uint32_t FuncLength,
   if (PAC && !FPLRPair)
     return false;
   int H = Nops == 4;
-  // There's an inconsistency regarding packed unwind info with homed
-  // parameters; according to the documentation, the epilog shouldn't have
-  // the same corresponding nops (and thus, to set the H bit, we should
-  // require an epilog which isn't exactly symmetrical - we shouldn't accept
-  // an exact mirrored epilog for those cases), but in practice,
-  // RtlVirtualUnwind behaves as if it does expect the epilogue to contain
-  // the same nops. See https://github.com/llvm/llvm-project/issues/54879.
-  // To play it safe, don't produce packed unwind info with homed parameters.
+  // For packed unwind info with the H bit set, the prolog and epilog
+  // actually shouldn't be symmetrical; the epilog shouldn't have any
+  // nop instructions/opcodes while the prolog has them. We currently
+  // require exactly symmetrical prologs/epilogs, which is wrong for this
+  // case - therefore, don't emit packed unwind info for this case.
+  // See https://github.com/llvm/llvm-project/issues/54879 for details.
+  //
+  // Additionally - older versions of Windows also deviated from the
+  // documentation here; older versions of Windows (at least up until
+  // 10.0.22000.2176) incorrectly did assume that the epilog has matching
+  // nop instructions. This is fixed at least in version 10.0.26100.6899.
+  // As long as we can't assume that the generated code always will run on
+  // a new enough version, don't emit the packed format here, even if the
+  // implementation would be fixed to match for the assymetrical form
+  // according to the documentation.
   if (H)
     return false;
   int IntSZ = 8 * RegI;



More information about the llvm-commits mailing list