Uh oh!
There was an error while loading. Please reload this page.
JIT: Fix managed return value debug info for floating-point returns - #129321
Conversation
PR dotnet#128479 introduced emitting managed return values as native vars but used storeVariableInRegisters(REG_FLOATRET, REG_NA) for float returns, which sets vlType=VLT_REG (integer register). The DBI then fails to read the return value because it looks in an integer register instead of XMM0. Fix by using VLT_REG_FP with a 0-based FP register index, which is what the DBI's VLT_REG_FP handler expects (it adds REGISTER_AMD64_XMM0 to convert to CorDebugRegister). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
There was a problem hiding this comment.
Pull request overview
This PR updates managed call return-value debug-info emission in the JIT so that floating-point return values are reported using the FP-specific location kind (VLT_REG_FP) with the expected 0-based FP register index, enabling the debugger to read the return value from the correct FP register.
Changes:
- Emit FP return locations using
VLT_REG_FPinstead ofstoreVariableInRegisters(REG_FLOATRET, REG_NA)for non-x86 targets. - Encode the FP register as a 0-based index (
REG_FLOATRET - REG_FP_FIRST) for debugger consumption. - Add comments documenting the
VLT_REG_FPencoding expectation.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
siFillRegisterVarLoc was storing the raw JIT register number (e.g., 32 for XMM0) in vlReg.vlrReg when encoding VLT_REG_FP. The DBI expects a 0-based FP register index and adds the platform-specific base (REGISTER_AMD64_XMM0, REGISTER_ARM64_V0, etc.) when converting to CorDebugRegister. Emit (GetRegNum() - REG_FP_FIRST) so the DBI computes the correct register. Also fix eeDispVar to reconstruct the full register number when displaying VLT_REG_FP entries in JIT dumps, and add genIsValidIntReg asserts to storeVariableInRegisters to catch misuse for non-integer register types. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
psiBegProlog was passing XMM/V register numbers through storeVariableInRegisters which unconditionally encodes as VLT_REG (integer register type). Route FP parameters to VLT_REG_FP with a 0-based FP register index instead. For SysV x64 mixed struct passing (GPR + XMM), drop the XMM register from VLT_REG_REG encoding since the debug info protocol cannot represent mixed integer/FP register pairs. Add genIsValidIntReg asserts to storeVariableInRegisters to guard against future misuse with non-integer registers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
On Linux x64 (SysV ABI) and RISC-V, structs can be returned in a mix of int and float registers (e.g. ValueTuple<double, int> returns in XMM0 + RAX). The VLT_REG_REG encoding only supports integer registers, so storeVariableInRegisters asserts genIsValidIntReg on these platforms. Skip recording managed return value info for multi-reg returns that involve float registers, since the encoding cannot represent them. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Add references to dotnet#129344 at both locations where mixed int/float multi-reg returns are unsupported in VarLoc encoding. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
tommcdon
commented
Jun 18, 2026
/ba-g issues are unrelated |
Uh oh!
There was an error while loading. Please reload this page.
…129321) PR #128479 introduced emitting managed return values as native vars but used storeVariableInRegisters(REG_FLOATRET, REG_NA) for float returns, which sets vlType=VLT_REG (integer register). The DBI then fails to read the return value because it looks in an integer register instead of XMM0. Fix by using VLT_REG_FP with a 0-based FP register index, which is what the DBI's VLT_REG_FP handler expects (it adds REGISTER_AMD64_XMM0 to convert to CorDebugRegister). Found via Visual Studio testing --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… x64 (#129992) Adds managed-return-value (MRV) debug-info encoding for value-class returns that live in two registers. Additionally, this change implements CordbJITILFrame::GetNativeVariable for x86 x87 FP-stack return/local variables (missed scenario from #129321) Fixes#129344 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PR #128479 introduced emitting managed return values as native vars but used storeVariableInRegisters(REG_FLOATRET, REG_NA) for float returns, which sets vlType=VLT_REG (integer register). The DBI then fails to read the return value because it looks in an integer register instead of XMM0.
Fix by using VLT_REG_FP with a 0-based FP register index, which is what the DBI's VLT_REG_FP handler expects (it adds REGISTER_AMD64_XMM0 to convert to CorDebugRegister).
Found via Visual Studio testing