Skip to content

Commit 39c94e0

Browse files
authored
add follow-up assert during unwinding (#112817)
* add follow-up assert during unwinding * review feedback * add a comment
1 parent d8a7c7b commit 39c94e0

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/coreclr/jit/unwindamd64.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,22 @@ void Compiler::unwindSaveRegWindows(regNumber reg, unsigned offset)
423423
code = (UNWIND_CODE*)&func->unwindCodes[func->unwindCodeSlot -= sizeof(UNWIND_CODE)];
424424
code->UnwindOp = (genIsValidFloatReg(reg)) ? UWOP_SAVE_XMM128_FAR : UWOP_SAVE_NONVOL_FAR;
425425
}
426-
code->OpInfo = (BYTE)(genIsValidFloatReg(reg) ? reg - XMMBASE : reg);
426+
unsigned unwindRegNum;
427+
if (genIsValidFloatReg(reg))
428+
{
429+
unwindRegNum = reg - XMMBASE;
430+
}
431+
else
432+
{
433+
assert(genIsValidIntReg(reg));
434+
unwindRegNum = reg;
435+
}
436+
// We only add unwind codes for non-volatile registers and for x86/x64,
437+
// the max registers index for a non-volatile register is 15.
438+
assert(unwindRegNum <= 15);
439+
code->OpInfo = (UCHAR)unwindRegNum;
440+
assert((unsigned)code->OpInfo == unwindRegNum);
441+
427442
unsigned int cbProlog = unwindGetCurrentOffset(func);
428443
noway_assert((BYTE)cbProlog == cbProlog);
429444
code->CodeOffset = (BYTE)cbProlog;

0 commit comments

Comments
 (0)