Fix for JitStress test failures
authorBrian Sullivan <briansul@microsoft.com>
Fri, 24 Mar 2017 22:42:04 +0000 (15:42 -0700)
committerBrian Sullivan <briansul@microsoft.com>
Fri, 24 Mar 2017 22:42:04 +0000 (15:42 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/0ef7c0bdfaad3c5e46e47922341b390a52b8dc79

src/coreclr/src/jit/flowgraph.cpp

index 08b0fa8..4c414f6 100644 (file)
@@ -12699,14 +12699,21 @@ void Compiler::fgComputeEdgeWeights()
         // Did we allocate a scratch block as the new first BB?
         if (fgFirstBBisScratch())
         {
-            firstILBlock = firstILBlock->bbNext;
-            // The second block is expected to have a profile-derived weight
+            // Skip past any/all BBF_INTERNAL blocks that may have been added before the first real IL block.
+            // These internal blocks all should be BBJ_NONE blocks.
+            //
+            while (firstILBlock->bbFlags & BBF_INTERNAL)
+            {
+                assert(firstILBlock->bbJumpKind == BBJ_NONE);
+                firstILBlock = firstILBlock->bbNext;
+            }
+            // The 'firstILBlock' is now expected to have a profile-derived weight
             assert(firstILBlock->hasProfileWeight());
         }
 
-        // If the first block only has one ref then we use it's weight
-        // for fgCalledCount. Otherwise we have backedge's into the first block,
-        // so instead we use the sum of the return block weights for fgCalledCount.
+        // If the first block only has one ref then we use it's weight for fgCalledCount.
+        // Otherwise we have backedge's into the first block, so instead we use the sum
+        // of the return block weights for fgCalledCount.
         //
         // If the profile data has a 0 for the returnWeight
         // (i.e. the function never returns because it always throws)