[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
Thu Jun 11 15:48:16 PDT 2026


================
@@ -702,14 +714,27 @@ static void EmitUnwindInfoV3(MCStreamer &Streamer, WinEH::FrameInfo *Info) {
 
   // --- Emit epilog descriptors ---
   const MCSymbol *PrevEpilogStart = nullptr;
+  uint8_t BaseEpiFlags = 0;
   for (const auto &EI : EpilogInfos) {
     const auto &Epilog = *EI.Epilog;
 
     // FlagsAndNumOps: bits [2:0] = flags, bits [7:3] = NumberOfOps.
     // For inherited descriptors, NumberOfOps = 0.
+    //
+    // Per the V3 spec, Flags bits 0 and 1 are NOT inherited by a descriptor
+    // with NumberOfOps == 0; the producer must replicate them so they have the
+    // same value as the base descriptor's. Since inheritance requires a
+    // matching NeedsLarge value, EI.NeedsLarge already equals the base's, so we
+    // emit EPILOG_INFO_LARGE for inherited descriptors too.
     uint8_t EpiFlags = 0;
-    if (EI.NeedsLarge && !EI.Inherited)
+    if (EI.NeedsLarge)
       EpiFlags |= Win64EH::EPILOG_INFO_LARGE;
+    // An inherited descriptor must replicate the base descriptor's flags bits
----------------
dpaoliello wrote:

I'd prefer to keep this to detect the case where we the flags WOULD be different (due to a bug, change in spec, or whatever). If you really feel strongly that we should be copying then I can invert this to use the copied bits but then assert they are the same as the calculated ones.

https://github.com/llvm/llvm-project/pull/202778


More information about the llvm-commits mailing list