Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
JIT: refactor logic for removing box upstream side effects (#13169)
Browse files Browse the repository at this point in the history
Introduce a new method `gtTryRemoveBoxUpstreamEffects` to capture
the logic for cleaning up after a dead value type box into a utility.
Call this from `gtFoldExprSpecial` and now also from the inliner when
it finds a dead box argument.

Also remove the useless `fgExpandInline` field and associated
`fgIsInlining` method, as the jit never set the field to true.

No diffs from the refactoring. The inliner case kicks in in 3 places
in the test tree.

Closes #13136.
  • Loading branch information
AndyAyersMS authored Aug 2, 2017
1 parent fbe621f commit f62e340
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 176 deletions.
12 changes: 3 additions & 9 deletions src/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,7 @@ class Compiler
gtFoldExprConst(GenTreePtr tree);
GenTreePtr gtFoldExprSpecial(GenTreePtr tree);
GenTreePtr gtFoldExprCompare(GenTreePtr tree);
bool gtTryRemoveBoxUpstreamEffects(GenTreePtr tree);

//-------------------------------------------------------------------------
// Get the handle, if any.
Expand Down Expand Up @@ -3614,9 +3615,8 @@ class Compiler
bool fgFuncletsCreated; // true if the funclet creation phase has been run
#endif // FEATURE_EH_FUNCLETS

bool fgGlobalMorph; // indicates if we are during the global morphing phase
// since fgMorphTree can be called from several places
bool fgExpandInline; // indicates that we are creating tree for the inliner
bool fgGlobalMorph; // indicates if we are during the global morphing phase
// since fgMorphTree can be called from several places

bool impBoxTempInUse; // the temp below is valid and available
unsigned impBoxTemp; // a temporary that is used for boxing
Expand Down Expand Up @@ -4479,12 +4479,6 @@ class Compiler

static GenTreePtr fgGetFirstNode(GenTreePtr tree);
static bool fgTreeIsInStmt(GenTree* tree, GenTreeStmt* stmt);

inline bool fgIsInlining()
{
return fgExpandInline;
}

void fgTraverseRPO();

//--------------------- Walking the trees in the IR -----------------------
Expand Down
11 changes: 8 additions & 3 deletions src/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ void Compiler::fgInit()
genReturnBB = nullptr;

/* We haven't reached the global morphing phase */
fgGlobalMorph = false;
fgExpandInline = false;
fgModified = false;
fgGlobalMorph = false;
fgModified = false;

#ifdef DEBUG
fgSafeBasicBlockCreation = true;
Expand Down Expand Up @@ -22676,6 +22675,12 @@ GenTreePtr Compiler::fgInlinePrependStatements(InlineInfo* inlineInfo)
}
#endif // DEBUG
}
else if (argNode->IsBoxedValue())
{
// Try to clean up any unnecessary boxing side effects
// since the box itself will be ignored.
gtTryRemoveBoxUpstreamEffects(argNode);
}
}
}
}
Expand Down
Loading

0 comments on commit f62e340

Please sign in to comment.