diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp index e97e14fccce9..9503206874ce 100644 --- a/src/jit/gentree.cpp +++ b/src/jit/gentree.cpp @@ -9915,7 +9915,7 @@ void Compiler::gtDispRegVal(GenTree* tree) // 0th reg is gtRegNum, which is already printed above. // Print the remaining regs of a multi-reg call node. GenTreeCall* call = tree->AsCall(); - unsigned regCount = call->GetReturnTypeDesc()->GetReturnRegCount(); + unsigned regCount = call->GetReturnTypeDesc()->TryGetReturnRegCount(); for (unsigned i = 1; i < regCount; ++i) { printf(",%s", compRegVarName(call->GetRegNumByIdx(i))); @@ -9925,7 +9925,7 @@ void Compiler::gtDispRegVal(GenTree* tree) { GenTreeCopyOrReload* copyOrReload = tree->AsCopyOrReload(); GenTreeCall* call = tree->gtGetOp1()->AsCall(); - unsigned regCount = call->GetReturnTypeDesc()->GetReturnRegCount(); + unsigned regCount = call->GetReturnTypeDesc()->TryGetReturnRegCount(); for (unsigned i = 1; i < regCount; ++i) { printf(",%s", compRegVarName(copyOrReload->GetRegNumByIdx(i))); diff --git a/src/jit/gentree.h b/src/jit/gentree.h index 557e28189c2d..08154367cb31 100644 --- a/src/jit/gentree.h +++ b/src/jit/gentree.h @@ -3171,6 +3171,15 @@ struct ReturnTypeDesc #endif } +#ifdef DEBUG + // NOTE: we only use this function when writing out IR dumps. These dumps may take place before the ReturnTypeDesc + // has been initialized. + unsigned TryGetReturnRegCount() const + { + return m_inited ? GetReturnRegCount() : 0; + } +#endif // DEBUG + //-------------------------------------------------------------------------------------------- // GetReturnRegCount: Get the count of return registers in which the return value is returned. //