From 3e271954768ec502d1827c18d911d046f234c5a1 Mon Sep 17 00:00:00 2001 From: Sergey Andreenko Date: Fri, 26 Apr 2019 15:50:37 -0700 Subject: [PATCH] Fix the case when we replace `stmt->gtStmtExpr`. --- src/jit/assertionprop.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/jit/assertionprop.cpp b/src/jit/assertionprop.cpp index d569458..5b62e88 100644 --- a/src/jit/assertionprop.cpp +++ b/src/jit/assertionprop.cpp @@ -3905,9 +3905,18 @@ GenTree* Compiler::optAssertionProp_Update(GenTree* newTree, GenTree* tree, GenT GenTree** useEdge = linkData.result; GenTree* parent = linkData.parent; noway_assert(useEdge != nullptr); - assert(parent != nullptr); - parent->ReplaceOperand(useEdge, newTree); + if (parent != nullptr) + { + parent->ReplaceOperand(useEdge, newTree); + } + else + { + // If there's no parent, the tree being replaced is the root of the + // statement. + assert((stmt->gtStmtExpr == tree) && (&stmt->gtStmtExpr == useEdge)); + stmt->gtStmtExpr = newTree; + } // We only need to ensure that the gtNext field is set as it is used to traverse // to the next node in the tree. We will re-morph this entire statement in -- 2.7.4