From 93c2cd74a6611ff0c302096654f260c4822fde56 Mon Sep 17 00:00:00 2001 From: Brian Sullivan Date: Thu, 15 Feb 2018 17:15:59 -0800 Subject: [PATCH] Fix for assert(sideEffList) in clr\src\jit\optcse.cpp, Line: 2151 If we return WALK_ABORT this assert will fire when the side effect list 'keepList' is empty. With this fix we don't return WALK_ABORT when the keepList is empty, instead we just place the CSE def into the keepList --- src/jit/optcse.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/jit/optcse.cpp b/src/jit/optcse.cpp index 1ce5442c21..043919e5f6 100644 --- a/src/jit/optcse.cpp +++ b/src/jit/optcse.cpp @@ -312,10 +312,17 @@ Compiler::fgWalkResult Compiler::optUnmarkCSEs(GenTree** pTree, fgWalkData* data // Instead we will add it to the 'keepList'. assert(IS_CSE_DEF(tree->gtCSEnum)); - if (comp->gtTreeHasSideEffects(tree, GTF_PERSISTENT_SIDE_EFFECTS_IN_CSE)) + // If we already have collected any persistent side effects then keepList is non-null + // and we will return WALK_ABORT since we have a CSE def that we must keep. + // + // If we haven't kept any side effects yet, we will create new GT_COMMA list with this one. + // + if ((keepList != nullptr) && comp->gtTreeHasSideEffects(tree, GTF_PERSISTENT_SIDE_EFFECTS_IN_CSE)) { - // If the nested CSE def has persistent side effects then just abort - // as this case is problematic. + // If this nested CSE def has a persistent side effect and + // we are already keeping other side effects then + // just abort as this case is problematic. + // a return WALK_ABORT; } else -- 2.34.1