Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0f36487

Browse files
authored
Re-work fix for flow graph update. (dotnet#40162)
In dotnet#39878 I switched fgUpdateChangedFlowGraph to call fgComputeReachability, which both removes unreachable blocks and calls fgComputeDoms. As mentioned in that PR, in addition to removing unreachable blocks fgRemoveUnreachableBlocks updates `BBF_LOOP_HEAD` flags even if no unreachable blocks were found. That resulted in some diffs, both positive and negative, from downstream effects: e.g., in some cases we now recognize more loops, which changes weights, etc. Some of the negative diffs affected benchmarks we are tracking, e.g., in dotnet#40094 `System.Text.RegularExpressions.Tests.Perf_Regex_Common` had a 10% regression because of codegen diffs in the large dynamic method created when compiling regular expressions. Because of these regressions, I decided to go with a more surgical fix for the original issue (assert when computing dominators after inlining GC polls). The downstream phases don't really need the dominator info so I changed fgUpdateChangedFlowGraph to not re-compute dominators after GC poll inlining. This reverses all diffs from dotnet#39878 and fixes dotnet#40094.
1 parent a83dc69 commit 0f36487

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/coreclr/src/jit/compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4968,7 +4968,7 @@ class Compiler
49684968

49694969
// When the flow graph changes, we need to update the block numbers, predecessor lists, reachability sets, and
49704970
// dominators.
4971-
void fgUpdateChangedFlowGraph();
4971+
void fgUpdateChangedFlowGraph(bool computeDoms = true);
49724972

49734973
public:
49744974
// Compute the predecessors of the blocks in the control flow graph.

src/coreclr/src/jit/flowgraph.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,7 +1868,7 @@ bool Compiler::fgReachable(BasicBlock* b1, BasicBlock* b2)
18681868
* it again.
18691869
*/
18701870

1871-
void Compiler::fgUpdateChangedFlowGraph()
1871+
void Compiler::fgUpdateChangedFlowGraph(bool computeDoms)
18721872
{
18731873
// We need to clear this so we don't hit an assert calling fgRenumberBlocks().
18741874
fgDomsComputed = false;
@@ -1878,7 +1878,11 @@ void Compiler::fgUpdateChangedFlowGraph()
18781878

18791879
fgComputePreds();
18801880
fgComputeEnterBlocksSet();
1881-
fgComputeReachability();
1881+
fgComputeReachabilitySets();
1882+
if (computeDoms)
1883+
{
1884+
fgComputeDoms();
1885+
}
18821886
}
18831887

18841888
/*****************************************************************************
@@ -3725,7 +3729,8 @@ PhaseStatus Compiler::fgInsertGCPolls()
37253729
{
37263730
noway_assert(opts.OptimizationEnabled());
37273731
fgReorderBlocks();
3728-
fgUpdateChangedFlowGraph();
3732+
constexpr bool computeDoms = false;
3733+
fgUpdateChangedFlowGraph(computeDoms);
37293734
}
37303735
#ifdef DEBUG
37313736
if (verbose)

0 commit comments

Comments
 (0)