@@ -65,6 +65,8 @@ static StringRef getUnwindCodeTypeName(uint8_t Code) {
6565 case UOP_SaveXMM128: return " SAVE_XMM128" ;
6666 case UOP_SaveXMM128Big: return " SAVE_XMM128_FAR" ;
6767 case UOP_PushMachFrame: return " PUSH_MACHFRAME" ;
68+ case UOP_Epilog:
69+ return " EPILOG" ;
6870 }
6971}
7072
@@ -99,6 +101,7 @@ static unsigned getNumUsedSlots(const UnwindCode &UnwindCode) {
99101 case UOP_AllocSmall:
100102 case UOP_SetFPReg:
101103 case UOP_PushMachFrame:
104+ case UOP_Epilog:
102105 return 1 ;
103106 case UOP_SaveNonVol:
104107 case UOP_SaveXMM128:
@@ -254,7 +257,8 @@ void Dumper::printRuntimeFunctionEntry(const Context &Ctx,
254257// Prints one unwind code. Because an unwind code can occupy up to 3 slots in
255258// the unwind codes array, this function requires that the correct number of
256259// slots is provided.
257- void Dumper::printUnwindCode (const UnwindInfo& UI, ArrayRef<UnwindCode> UC) {
260+ void Dumper::printUnwindCode (const UnwindInfo &UI, ArrayRef<UnwindCode> UC,
261+ bool &SeenFirstEpilog) {
258262 assert (UC.size () >= getNumUsedSlots (UC[0 ]));
259263
260264 SW.startLine () << format (" 0x%02X: " , unsigned (UC[0 ].u .CodeOffset ))
@@ -306,6 +310,24 @@ void Dumper::printUnwindCode(const UnwindInfo& UI, ArrayRef<UnwindCode> UC) {
306310 case UOP_PushMachFrame:
307311 OS << " errcode=" << (UC[0 ].getOpInfo () == 0 ? " no" : " yes" );
308312 break ;
313+
314+ case UOP_Epilog:
315+ if (SeenFirstEpilog) {
316+ uint32_t Offset =
317+ (UC[0 ].getOpInfo () << 8 ) | static_cast <uint32_t >(UC[0 ].u .CodeOffset );
318+ if (Offset == 0 ) {
319+ OS << " padding" ;
320+ } else {
321+ OS << " offset=" << format (" 0x%X" , Offset);
322+ }
323+ } else {
324+ SeenFirstEpilog = true ;
325+ bool AtEnd = (UC[0 ].getOpInfo () & 0x1 ) != 0 ;
326+ uint32_t Length = UC[0 ].u .CodeOffset ;
327+ OS << " atend=" << (AtEnd ? " yes" : " no" )
328+ << " , length=" << format (" 0x%X" , Length);
329+ }
330+ break ;
309331 }
310332
311333 OS << " \n " ;
@@ -330,14 +352,15 @@ void Dumper::printUnwindInfo(const Context &Ctx, const coff_section *Section,
330352 {
331353 ListScope UCS (SW, " UnwindCodes" );
332354 ArrayRef<UnwindCode> UC (&UI.UnwindCodes [0 ], UI.NumCodes );
355+ bool SeenFirstEpilog = false ;
333356 for (const UnwindCode *UCI = UC.begin (), *UCE = UC.end (); UCI < UCE; ++UCI) {
334357 unsigned UsedSlots = getNumUsedSlots (*UCI);
335358 if (UsedSlots > UC.size ()) {
336359 errs () << " corrupt unwind data" ;
337360 return ;
338361 }
339362
340- printUnwindCode (UI, ArrayRef (UCI, UCE));
363+ printUnwindCode (UI, ArrayRef (UCI, UCE), SeenFirstEpilog );
341364 UCI = UCI + UsedSlots - 1 ;
342365 }
343366 }
0 commit comments