JIT: add back no side effect check when optimizing return values (#31836)
authorAndy Ayers <andya@microsoft.com>
Thu, 6 Feb 2020 21:17:05 +0000 (13:17 -0800)
committerGitHub <noreply@github.com>
Thu, 6 Feb 2020 21:17:05 +0000 (13:17 -0800)
Feedback from #31699.

src/coreclr/src/jit/flowgraph.cpp

index 9528f47..23bc843 100644 (file)
@@ -22617,8 +22617,10 @@ Compiler::fgWalkResult Compiler::fgLateDevirtualization(GenTree** pTree, fgWalkD
             JITDUMP(" ... found foldable jtrue at [%06u] in BB%02u\n", dspTreeID(tree), block->bbNum);
             noway_assert((block->bbNext->countOfInEdges() > 0) && (block->bbJumpDest->countOfInEdges() > 0));
 
-            // Had hoped to assert here that we are not losing any
-            // side effects, but can't find a way to express it properly.
+            // We have a constant operand, and should have the all clear to optimize.
+            // Update side effects on the tree, assert there aren't any, and bash to nop.
+            comp->gtUpdateNodeSideEffects(tree);
+            assert((tree->gtFlags & GTF_SIDE_EFFECT) == 0);
             tree->gtBashToNOP();
 
             BasicBlock* bTaken    = nullptr;