From dfccb3ffb4eaed1ab3b13ea74186ec7d7b4ccf9f Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Wed, 29 Jul 2020 09:07:23 -0700 Subject: [PATCH] Port JIT fix to Preview 8: ensure fgFirstBB has appropriate flags Port of #40038 to Preview 8. Fix #39023 Release jits might sometimes generate bad GC info. Mysterious intermittent crashes. Without this fix jit GC info generation for some methods is non-deterministically bad. Yes, problem does not occur in 3.1. Very low. --- src/coreclr/src/jit/flowgraph.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/coreclr/src/jit/flowgraph.cpp b/src/coreclr/src/jit/flowgraph.cpp index ab39e2c25d232..6dd724bf1828e 100644 --- a/src/coreclr/src/jit/flowgraph.cpp +++ b/src/coreclr/src/jit/flowgraph.cpp @@ -175,6 +175,8 @@ void Compiler::fgInit() #ifdef FEATURE_SIMD fgPreviousCandidateSIMDFieldAsgStmt = nullptr; #endif + + fgHasSwitch = false; } bool Compiler::fgHaveProfileData() @@ -476,7 +478,8 @@ void Compiler::fgEnsureFirstBBisScratch() noway_assert(fgLastBB != nullptr); - block->bbFlags |= (BBF_INTERNAL | BBF_IMPORTED); + // Set the expected flags + block->bbFlags |= (BBF_INTERNAL | BBF_IMPORTED | BBF_JMP_TARGET | BBF_HAS_LABEL); // This new first BB has an implicit ref, and no others. block->bbRefs = 1;