From 5c84b4f5a1b051b7210f2d3e2c9176694864cf49 Mon Sep 17 00:00:00 2001 From: Eugene Rozenfeld Date: Tue, 14 Jul 2020 13:51:40 -0700 Subject: [PATCH] Fix `fgOptimizeBranch` when run late. `fgOptimizeBranch` can now run during fgInsertGCPolls() so it needs additional processing for newly-created statements. Fixes #39308. --- src/coreclr/src/jit/flowgraph.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/coreclr/src/jit/flowgraph.cpp b/src/coreclr/src/jit/flowgraph.cpp index e0b7e630a9659f..f93af11a09e015 100644 --- a/src/coreclr/src/jit/flowgraph.cpp +++ b/src/coreclr/src/jit/flowgraph.cpp @@ -15333,6 +15333,12 @@ bool Compiler::fgOptimizeBranch(BasicBlock* bJump) // Clone/substitute the expression. Statement* stmt = gtCloneStmt(curStmt); + if (fgStmtListThreaded) + { + gtSetStmtInfo(stmt); + fgSetStmtSeq(stmt); + } + // cloneExpr doesn't handle everything. if (stmt == nullptr) {