From 32c86dc15302bc9bf2ab671db2eb3e7cc19fb44f Mon Sep 17 00:00:00 2001 From: SingleAccretion Date: Mon, 5 Apr 2021 01:21:38 +0300 Subject: [PATCH] Do not confuse fgDispBasicBlocks in fgMorphBlocks The logic in "fgDispBasicBlocks" has a check for promoted implicit by-refs that only allows them during global morph via an 'assert(fgGlobalMorph)'. However, "fgMorphBlocks" was calling "fgDispBasicBlocks" after having set "fgGlobalMorph" to "false", leading it to falsely believe it was not actually being called during global morph and asserting with a message like "assertion failed 'fgGlobalMorph' - during 'Morph - Global'". Fix this by setting "fgGlobalMorph" to "false" at the very end of "fgMorphBlocks". --- src/coreclr/jit/morph.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 8fbce8a586e79..a3879b8ea2b5e 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -17226,10 +17226,6 @@ void Compiler::fgMorphBlocks() block = block->bbNext; } while (block != nullptr); - // We are done with the global morphing phase - fgGlobalMorph = false; - compCurBB = nullptr; - // Under OSR, we no longer need to specially protect the original method entry // if (opts.IsOSR() && (fgEntryBB != nullptr) && (fgEntryBB->bbFlags & BBF_IMPORTED)) @@ -17247,6 +17243,10 @@ void Compiler::fgMorphBlocks() fgDispBasicBlocks(true); } #endif + + // We are done with the global morphing phase + fgGlobalMorph = false; + compCurBB = nullptr; } //------------------------------------------------------------------------