diff options
author | Pat Gavlin <pgavlin@gmail.com> | 2016-11-23 14:16:06 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-23 14:16:06 -0800 |
commit | 7c978202b482d634d10c6841c2f60e0a0d600a17 (patch) | |
tree | 7df2be2045c511b0d825d9b14777ca0573543923 /src | |
parent | 60a8b7399bf45c62062ef3ea1d049ebb2b6906cf (diff) | |
parent | c07f2e1d7e111568b45389f07e9e5bd757a866a2 (diff) | |
download | coreclr-7c978202b482d634d10c6841c2f60e0a0d600a17.tar.gz coreclr-7c978202b482d634d10c6841c2f60e0a0d600a17.tar.bz2 coreclr-7c978202b482d634d10c6841c2f60e0a0d600a17.zip |
Merge pull request #8284 from pgavlin/gh8258
Increment lclVar refCounts in fgMorphBlockStmt.
Diffstat (limited to 'src')
-rw-r--r-- | src/jit/assertionprop.cpp | 17 | ||||
-rw-r--r-- | src/jit/compiler.h | 2 | ||||
-rw-r--r-- | src/jit/earlyprop.cpp | 11 | ||||
-rw-r--r-- | src/jit/loopcloning.cpp | 2 | ||||
-rw-r--r-- | src/jit/morph.cpp | 45 | ||||
-rw-r--r-- | src/jit/optcse.cpp | 2 | ||||
-rw-r--r-- | src/jit/optimizer.cpp | 2 |
7 files changed, 33 insertions, 48 deletions
diff --git a/src/jit/assertionprop.cpp b/src/jit/assertionprop.cpp index 7c0f01dc7a..cb0832fe47 100644 --- a/src/jit/assertionprop.cpp +++ b/src/jit/assertionprop.cpp @@ -4683,9 +4683,8 @@ GenTreePtr Compiler::optVNConstantPropOnJTrue(BasicBlock* block, GenTreePtr stmt newStmt = fgInsertStmtNearEnd(block, sideEffList); sideEffList = nullptr; } - fgMorphBlockStmt(block, newStmt DEBUGARG(__FUNCTION__)); - gtSetStmtInfo(newStmt); - fgSetStmtSeq(newStmt); + + fgMorphBlockStmt(block, newStmt->AsStmt() DEBUGARG(__FUNCTION__)); } // Transform the relop's operands to be both zeroes. @@ -4909,9 +4908,7 @@ GenTreePtr Compiler::optVNAssertionPropCurStmt(BasicBlock* block, GenTreePtr stm if (optAssertionPropagatedCurrentStmt) { - fgMorphBlockStmt(block, stmt DEBUGARG("optVNAssertionPropCurStmt")); - gtSetStmtInfo(stmt); - fgSetStmtSeq(stmt); + fgMorphBlockStmt(block, stmt->AsStmt() DEBUGARG("optVNAssertionPropCurStmt")); } // Check if propagation removed statements starting from current stmt. @@ -5108,13 +5105,7 @@ void Compiler::optAssertionPropMain() } #endif // Re-morph the statement. - fgMorphBlockStmt(block, stmt DEBUGARG("optAssertionPropMain")); - - // Recalculate the gtCostSz, etc... - gtSetStmtInfo(stmt); - - // Re-thread the nodes - fgSetStmtSeq(stmt); + fgMorphBlockStmt(block, stmt->AsStmt() DEBUGARG("optAssertionPropMain")); } // Check if propagation removed statements starting from current stmt. diff --git a/src/jit/compiler.h b/src/jit/compiler.h index ee180eecb6..6e859b8c92 100644 --- a/src/jit/compiler.h +++ b/src/jit/compiler.h @@ -3511,7 +3511,7 @@ public: void fgMorphStmts(BasicBlock* block, bool* mult, bool* lnot, bool* loadw); void fgMorphBlocks(); - bool fgMorphBlockStmt(BasicBlock* block, GenTreePtr stmt DEBUGARG(const char* msg)); + bool fgMorphBlockStmt(BasicBlock* block, GenTreeStmt* stmt DEBUGARG(const char* msg)); void fgCheckArgCnt(); void fgSetOptions(); diff --git a/src/jit/earlyprop.cpp b/src/jit/earlyprop.cpp index 80ec6a01d2..7bf6eabdfe 100644 --- a/src/jit/earlyprop.cpp +++ b/src/jit/earlyprop.cpp @@ -612,13 +612,8 @@ void Compiler::optFoldNullCheck(GenTreePtr tree) additionNode->gtFlags & (GTF_EXCEPT | GTF_DONT_CSE); // Re-morph the statement. - fgMorphBlockStmt(compCurBB, curStmt DEBUGARG("optFoldNullCheck")); - - // Recalculate the gtCostSz, etc... - gtSetStmtInfo(curStmt); - - // Re-thread the nodes - fgSetStmtSeq(curStmt); + fgMorphBlockStmt(compCurBB, + curStmt->AsStmt() DEBUGARG("optFoldNullCheck")); } } } @@ -668,4 +663,4 @@ bool Compiler::optCanMoveNullCheckPastTree(GenTreePtr tree, bool isInsideTry) } } return result; -}
\ No newline at end of file +} diff --git a/src/jit/loopcloning.cpp b/src/jit/loopcloning.cpp index 8ce015e607..a1ba14292a 100644 --- a/src/jit/loopcloning.cpp +++ b/src/jit/loopcloning.cpp @@ -698,7 +698,7 @@ void LoopCloneContext::CondToStmtInBlock(Compiler* comp, comp->fgInsertStmtAtEnd(block, stmt); // Remorph. - comp->fgMorphBlockStmt(block, stmt DEBUGARG("Loop cloning condition")); + comp->fgMorphBlockStmt(block, stmt->AsStmt() DEBUGARG("Loop cloning condition")); } //-------------------------------------------------------------------------------------------------- diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp index 43e6302853..d0d81f8928 100644 --- a/src/jit/morph.cpp +++ b/src/jit/morph.cpp @@ -15253,14 +15253,15 @@ bool Compiler::fgFoldConditional(BasicBlock* block) // Returns false if 'stmt' is still in the block (even if other statements were removed). // -bool Compiler::fgMorphBlockStmt(BasicBlock* block, GenTreePtr stmt DEBUGARG(const char* msg)) +bool Compiler::fgMorphBlockStmt(BasicBlock* block, GenTreeStmt* stmt DEBUGARG(const char* msg)) { - noway_assert(stmt->gtOper == GT_STMT); + assert(block != nullptr); + assert(stmt != nullptr); compCurBB = block; compCurStmt = stmt; - GenTreePtr morph = fgMorphTree(stmt->gtStmt.gtStmtExpr); + GenTree* morph = fgMorphTree(stmt->gtStmtExpr); // Bug 1106830 - During the CSE phase we can't just remove // morph->gtOp.gtOp2 as it could contain CSE expressions. @@ -15269,7 +15270,7 @@ bool Compiler::fgMorphBlockStmt(BasicBlock* block, GenTreePtr stmt DEBUGARG(cons // if (!optValnumCSE_phase) { - /* Check for morph as a GT_COMMA with an unconditional throw */ + // Check for morph as a GT_COMMA with an unconditional throw if (fgIsCommaThrow(morph, true)) { #ifdef DEBUG @@ -15281,12 +15282,12 @@ bool Compiler::fgMorphBlockStmt(BasicBlock* block, GenTreePtr stmt DEBUGARG(cons printf("\n"); } #endif - /* Use the call as the new stmt */ + // Use the call as the new stmt morph = morph->gtOp.gtOp1; noway_assert(morph->gtOper == GT_CALL); } - /* we can get a throw as a statement root*/ + // we can get a throw as a statement root if (fgIsThrow(morph)) { #ifdef DEBUG @@ -15301,15 +15302,13 @@ bool Compiler::fgMorphBlockStmt(BasicBlock* block, GenTreePtr stmt DEBUGARG(cons } } - stmt->gtStmt.gtStmtExpr = morph; - - /* Can the entire tree be removed ? */ + stmt->gtStmtExpr = morph; + // Can the entire tree be removed? bool removedStmt = fgCheckRemoveStmt(block, stmt); - /* Or this is the last statement of a conditional branch that was just folded */ - - if ((!removedStmt) && (stmt->gtNext == nullptr) && !fgRemoveRestOfBlock) + // Or this is the last statement of a conditional branch that was just folded? + if (!removedStmt && (stmt->getNextStmt() == nullptr) && !fgRemoveRestOfBlock) { if (fgFoldConditional(block)) { @@ -15322,11 +15321,16 @@ bool Compiler::fgMorphBlockStmt(BasicBlock* block, GenTreePtr stmt DEBUGARG(cons if (!removedStmt) { - /* Have to re-do the evaluation order since for example - * some later code does not expect constants as op1 */ + 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); - /* Have to re-link the nodes for this statement */ + // Have to re-link the nodes for this statement fgSetStmtSeq(stmt); } @@ -15341,18 +15345,13 @@ bool Compiler::fgMorphBlockStmt(BasicBlock* block, GenTreePtr stmt DEBUGARG(cons if (fgRemoveRestOfBlock) { - /* Remove the rest of the stmts in the block */ - - while (stmt->gtNext) + // Remove the rest of the stmts in the block + for (stmt = stmt->getNextStmt(); stmt != nullptr; stmt = stmt->getNextStmt()) { - stmt = stmt->gtNext; - noway_assert(stmt->gtOper == GT_STMT); - fgRemoveStmt(block, stmt); } - // The rest of block has been removed - // and we will always throw an exception + // The rest of block has been removed and we will always throw an exception. // Update succesors of block fgRemoveBlockAsPred(block); diff --git a/src/jit/optcse.cpp b/src/jit/optcse.cpp index f2d094f667..d2d298b852 100644 --- a/src/jit/optcse.cpp +++ b/src/jit/optcse.cpp @@ -2050,7 +2050,7 @@ public: assert(m_pCompiler->fgRemoveRestOfBlock == false); /* re-morph the statement */ - m_pCompiler->fgMorphBlockStmt(blk, stm DEBUGARG("optValnumCSE")); + m_pCompiler->fgMorphBlockStmt(blk, stm->AsStmt() DEBUGARG("optValnumCSE")); } while (lst != nullptr); } diff --git a/src/jit/optimizer.cpp b/src/jit/optimizer.cpp index 2eea1d1a40..bd82f6a6f3 100644 --- a/src/jit/optimizer.cpp +++ b/src/jit/optimizer.cpp @@ -4242,7 +4242,7 @@ void Compiler::optDebugLogLoopCloning(BasicBlock* block, GenTreePtr insertBefore GenTreePtr logCall = gtNewHelperCallNode(CORINFO_HELP_DEBUG_LOG_LOOP_CLONING, TYP_VOID); GenTreePtr stmt = fgNewStmtFromTree(logCall); fgInsertStmtBefore(block, insertBefore, stmt); - fgMorphBlockStmt(block, stmt DEBUGARG("Debug log loop cloning")); + fgMorphBlockStmt(block, stmt->AsStmt() DEBUGARG("Debug log loop cloning")); } #endif |