diff options
author | Pat Gavlin <pagavlin@microsoft.com> | 2016-12-14 12:23:54 -0800 |
---|---|---|
committer | Pat Gavlin <pagavlin@microsoft.com> | 2016-12-14 12:23:54 -0800 |
commit | 530b45d88b08db93b89da144e22a2f34209971ab (patch) | |
tree | 2d18527cad626f49668b5fdc0f65d0ae168d59f7 /src/jit | |
parent | f25bff4d1645d9e5f03c4810eaf141f8f245f563 (diff) | |
download | coreclr-530b45d88b08db93b89da144e22a2f34209971ab.tar.gz coreclr-530b45d88b08db93b89da144e22a2f34209971ab.tar.bz2 coreclr-530b45d88b08db93b89da144e22a2f34209971ab.zip |
Fix ref count adjustment in `fgMorphBlockStmt`.
LclVar ref counts must be incremented before attempting to remove the
morphed statement, since doing so decrements ref counts (and thus
requires refcounts to be conservatively correct).
Fixes VSO 359734.
Diffstat (limited to 'src/jit')
-rw-r--r-- | src/jit/morph.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp index aef6029b16..de398c83d1 100644 --- a/src/jit/morph.cpp +++ b/src/jit/morph.cpp @@ -15330,6 +15330,12 @@ bool Compiler::fgMorphBlockStmt(BasicBlock* block, GenTreeStmt* stmt DEBUGARG(co stmt->gtStmtExpr = morph; + if (lvaLocalVarRefCounted) + { + // fgMorphTree may have introduced new lclVar references. Bump the ref counts if requested. + lvaRecursiveIncRefCounts(stmt->gtStmtExpr); + } + // Can the entire tree be removed? bool removedStmt = fgCheckRemoveStmt(block, stmt); @@ -15347,12 +15353,6 @@ bool Compiler::fgMorphBlockStmt(BasicBlock* block, GenTreeStmt* stmt DEBUGARG(co if (!removedStmt) { - if (lvaLocalVarRefCounted) - { - // fgMorphTree may have introduced new lclVar references. Bump the ref counts if requested. - lvaRecursiveIncRefCounts(stmt->gtStmtExpr); - } - // Have to re-do the evaluation order since for example some later code does not expect constants as op1 gtSetStmtInfo(stmt); |