[llvm] [win][x64] Windows x64 unwind v3: Update epilog inheritance per spec clarification (PR #202778)
Daniel Paoliello via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 10 10:51:34 PDT 2026
================
@@ -579,16 +579,22 @@ static void EmitUnwindInfoV3(MCStreamer &Streamer, WinEH::FrameInfo *Info) {
Twine(EpilogInfos.size()));
// --- Inheritance decisions ---
- // An epilog can use the inherited (3-byte) descriptor when FirstOp,
- // NumberOfOps, NeedsLarge, and relative IP offsets all match the previous
- // epilog.
- for (unsigned I = 1; I < EpilogInfos.size(); ++I) {
- auto &Prev = EpilogInfos[I - 1];
+ // Per the V3 spec, an epilog descriptor with NumberOfOps == 0 inherits its
+ // effective NumberOfOps, FirstOp, IpOffsetOfLastInstruction, and IP offset
+ // array from the first preceding descriptor with NumberOfOps != 0 (the
+ // "base"), not necessarily the immediately preceding descriptor. An epilog
+ // can therefore use the inherited (3-byte) descriptor when FirstOp,
+ // NumberOfOps, NeedsLarge, and relative IP offsets all match that base.
+ for (unsigned I = 1, Base = 0; I < EpilogInfos.size(); ++I) {
+ auto &BaseEI = EpilogInfos[Base];
auto &Curr = EpilogInfos[I];
- if (Curr.FirstOp == Prev.FirstOp && Curr.NumberOfOps == Prev.NumberOfOps &&
- Curr.NeedsLarge == Prev.NeedsLarge &&
- EpilogIpOffsetsMatch(*Curr.Epilog, *Prev.Epilog, OS->getAssembler()))
+ if (Curr.FirstOp == BaseEI.FirstOp &&
+ Curr.NumberOfOps == BaseEI.NumberOfOps &&
+ Curr.NeedsLarge == BaseEI.NeedsLarge &&
+ EpilogIpOffsetsMatch(*Curr.Epilog, *BaseEI.Epilog, OS->getAssembler()))
----------------
dpaoliello wrote:
I believe requiring the flags to match is more for making the encoded data easier to read and avoid garbage leaking into these bits, but maybe @pmsjt can comment.
https://github.com/llvm/llvm-project/pull/202778
More information about the llvm-commits
mailing list