From: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 10 Sep 2021 18:08:53 +0000 (-0700) Subject: [release/6.0] Consider finally that jumps to itself as non-empty (#58881) X-Git-Tag: accepted/tizen/unified/20220110.054933~171 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=669ebb45e73289427526a8b8e418e6c1a55f0896;p=platform%2Fupstream%2Fdotnet%2Fruntime.git [release/6.0] Consider finally that jumps to itself as non-empty (#58881) * decrement the reference of unreachable finally * Proper fix Co-authored-by: Kunal Pathak --- diff --git a/src/coreclr/jit/fgehopt.cpp b/src/coreclr/jit/fgehopt.cpp index 06abf45..18cb78a 100644 --- a/src/coreclr/jit/fgehopt.cpp +++ b/src/coreclr/jit/fgehopt.cpp @@ -99,6 +99,14 @@ PhaseStatus Compiler::fgRemoveEmptyFinally() continue; } + // If the finally's block jumps back to itself, then it is not empty. + if ((firstBlock->bbJumpKind == BBJ_ALWAYS) && firstBlock->bbJumpDest == firstBlock) + { + JITDUMP("EH#%u finally has basic block that jumps to itself; skipping.\n", XTnum); + XTnum++; + continue; + } + // Limit for now to finallys that contain only a GT_RETFILT. bool isEmpty = true; diff --git a/src/coreclr/jit/jiteh.cpp b/src/coreclr/jit/jiteh.cpp index da431dd..12e91d0 100644 --- a/src/coreclr/jit/jiteh.cpp +++ b/src/coreclr/jit/jiteh.cpp @@ -4410,7 +4410,7 @@ void Compiler::fgExtendEHRegionBefore(BasicBlock* block) #endif // DEBUG // The first block of a handler has an artificial extra refcount. Transfer that to the new block. - assert(block->bbRefs > 0); + noway_assert(block->countOfInEdges() > 0); block->bbRefs--; HBtab->ebdHndBeg = bPrev; @@ -4459,7 +4459,7 @@ void Compiler::fgExtendEHRegionBefore(BasicBlock* block) #endif // DEBUG // The first block of a filter has an artificial extra refcount. Transfer that to the new block. - assert(block->bbRefs > 0); + noway_assert(block->countOfInEdges() > 0); block->bbRefs--; HBtab->ebdFilter = bPrev;