From c57df5585949329154f94ab63a7219856baac739 Mon Sep 17 00:00:00 2001 From: Pat Gavlin Date: Sat, 15 Jul 2017 13:25:49 -0700 Subject: [PATCH 1/3] Fix issues with early dumps of multi-reg-returning calls. The tree dump code was calling `GetReturnRegCount` before the return type descriptor was initialized, which lead to an assert. This change introduces a new debug-only method that simply returns `0` if the return type desc has not been initialized. --- src/jit/gentree.cpp | 4 ++-- src/jit/gentree.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) 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 5618323ad943..13f748431810 100644 --- a/src/jit/gentree.h +++ b/src/jit/gentree.h @@ -3171,6 +3171,13 @@ struct ReturnTypeDesc #endif } +#ifdef DEBUG + unsigned TryGetReturnRegCount() const + { + return m_inited ? GetReturnRegCount() : 0; + } +#endif //DEBUG + //-------------------------------------------------------------------------------------------- // GetReturnRegCount: Get the count of return registers in which the return value is returned. // From 1ef21c73a7553756c5c534939eef531bbd764d32 Mon Sep 17 00:00:00 2001 From: Pat Gavlin Date: Sun, 16 Jul 2017 09:52:55 -0700 Subject: [PATCH 2/3] Format code. --- src/jit/gentree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jit/gentree.h b/src/jit/gentree.h index 13f748431810..1366ad92a24f 100644 --- a/src/jit/gentree.h +++ b/src/jit/gentree.h @@ -3176,7 +3176,7 @@ struct ReturnTypeDesc { return m_inited ? GetReturnRegCount() : 0; } -#endif //DEBUG +#endif // DEBUG //-------------------------------------------------------------------------------------------- // GetReturnRegCount: Get the count of return registers in which the return value is returned. From bf2b27c936dbb11f9c04fa7b490c4997cfea79b9 Mon Sep 17 00:00:00 2001 From: Pat Gavlin Date: Tue, 18 Jul 2017 06:59:53 -0700 Subject: [PATCH 3/3] PR feedback. --- src/jit/gentree.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/jit/gentree.h b/src/jit/gentree.h index 1366ad92a24f..31aae3fdff28 100644 --- a/src/jit/gentree.h +++ b/src/jit/gentree.h @@ -3172,6 +3172,8 @@ struct ReturnTypeDesc } #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;