JIT: suppress edge weight second computation pass (#46779)
authorAndy Ayers <andya@microsoft.com>
Mon, 11 Jan 2021 16:27:00 +0000 (08:27 -0800)
committerGitHub <noreply@github.com>
Mon, 11 Jan 2021 16:27:00 +0000 (08:27 -0800)
Follow up to #45615.

We compute edge weights twice. Make sure we either enable or suppress
both the computations.

src/coreclr/jit/flowgraph.cpp

index e70f192..8eef9ab 100644 (file)
@@ -13567,7 +13567,6 @@ void Compiler::fgComputeBlockAndEdgeWeights()
     JITDUMP("*************** In fgComputeBlockAndEdgeWeights()\n");
 
     const bool usingProfileWeights = fgIsUsingProfileWeights();
-    const bool isOptimizing        = opts.OptimizationEnabled();
 
     fgModified             = false;
     fgHaveValidEdgeWeights = false;
@@ -13592,14 +13591,7 @@ void Compiler::fgComputeBlockAndEdgeWeights()
         JITDUMP(" -- no profile data, so using default called count\n");
     }
 
-    if (usingProfileWeights && isOptimizing)
-    {
-        fgComputeEdgeWeights();
-    }
-    else
-    {
-        JITDUMP(" -- not optimizing or no profile data, so not computing edge weights\n");
-    }
+    fgComputeEdgeWeights();
 }
 
 //-------------------------------------------------------------
@@ -13806,6 +13798,15 @@ void Compiler::fgComputeCalledCount(BasicBlock::weight_t returnWeight)
 
 void Compiler::fgComputeEdgeWeights()
 {
+    const bool isOptimizing        = opts.OptimizationEnabled();
+    const bool usingProfileWeights = fgIsUsingProfileWeights();
+
+    if (!isOptimizing || !usingProfileWeights)
+    {
+        JITDUMP(" -- not optimizing or no profile data, so not computing edge weights\n");
+        return;
+    }
+
     BasicBlock*          bSrc;
     BasicBlock*          bDst;
     flowList*            edge;