[llvm] [win][x64] Windows x64 unwind v3: Update epilog inheritance per spec clarification (PR #202778)
Evgenii Kudriashov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 10 05:53:57 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()))
----------------
e-kud wrote:
I wonder how it works. So during encoding we want the Large flag to be matching when during decoding we take it independently. It looks like we have a limitation in case of Large/Non-large inheritance during encoding but I see that `EPILOG_INFO_V3` is the same for large and non-large epilogs. Which makes me think that Large equality is redundant here.
Strictly speaking it must be matching otherwise we have a bug.
https://github.com/llvm/llvm-project/pull/202778
More information about the llvm-commits
mailing list