Skip to content

Commit 535f604

Browse files
authored
[MC] [Win64EH] Clarify the comment about a skipped case of packed unwind info (llvm#169784)
Clarify the comment from 924defa. 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.
1 parent 885509b commit 535f604

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

llvm/lib/MC/MCWin64EH.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,14 +1252,21 @@ static bool tryARM64PackedUnwind(WinEH::FrameInfo *info, uint32_t FuncLength,
12521252
if (PAC && !FPLRPair)
12531253
return false;
12541254
int H = Nops == 4;
1255-
// There's an inconsistency regarding packed unwind info with homed
1256-
// parameters; according to the documentation, the epilog shouldn't have
1257-
// the same corresponding nops (and thus, to set the H bit, we should
1258-
// require an epilog which isn't exactly symmetrical - we shouldn't accept
1259-
// an exact mirrored epilog for those cases), but in practice,
1260-
// RtlVirtualUnwind behaves as if it does expect the epilogue to contain
1261-
// the same nops. See https://github.com/llvm/llvm-project/issues/54879.
1262-
// To play it safe, don't produce packed unwind info with homed parameters.
1255+
// For packed unwind info with the H bit set, the prolog and epilog
1256+
// actually shouldn't be symmetrical; the epilog shouldn't have any
1257+
// nop instructions/opcodes while the prolog has them. We currently
1258+
// require exactly symmetrical prologs/epilogs, which is wrong for this
1259+
// case - therefore, don't emit packed unwind info for this case.
1260+
// See https://github.com/llvm/llvm-project/issues/54879 for details.
1261+
//
1262+
// Additionally - older versions of Windows also deviated from the
1263+
// documentation here; older versions of Windows (at least up until
1264+
// 10.0.22000.2176) incorrectly did assume that the epilog has matching
1265+
// nop instructions. This is fixed at least in version 10.0.26100.6899.
1266+
// As long as we can't assume that the generated code always will run on
1267+
// a new enough version, don't emit the packed format here, even if the
1268+
// implementation would be fixed to match for the asymmetrical form
1269+
// according to the documentation.
12631270
if (H)
12641271
return false;
12651272
int IntSZ = 8 * RegI;

0 commit comments

Comments
 (0)