From f0f1b5b9a8f6dd94b2bf42d48f151ce81659a4ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 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 asymmetrical 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 a7ce8d527250f..f5f8bbb6a3859 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 asymmetrical form + // according to the documentation. if (H) return false; int IntSZ = 8 * RegI;