Skip to content

Commit

Permalink
couple tweaks to optRemoveRedundantZeroInits (dotnet#102531)
Browse files Browse the repository at this point in the history
* couple tweaks to optRemoveRedundantZeroInits

* Apply suggestions from code review

Co-authored-by: Aman Khalid <amankhalid@microsoft.com>

---------

Co-authored-by: Aman Khalid <amankhalid@microsoft.com>
  • Loading branch information
2 people authored and steveharter committed May 28, 2024
1 parent 7beb4a4 commit facee18
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5918,7 +5918,12 @@ void Compiler::optRemoveRedundantZeroInits()
{
if (((tree->gtFlags & GTF_CALL) != 0))
{
hasGCSafePoint = true;
// if this is not a No-GC helper
if (!tree->IsCall() || !emitter::emitNoGChelper(tree->AsCall()->GetHelperNum()))
{
// assume that we have a safe point.
hasGCSafePoint = true;
}
}

hasImplicitControlFlow |= hasEHSuccs && ((tree->gtFlags & GTF_EXCEPT) != 0);
Expand Down Expand Up @@ -6071,9 +6076,10 @@ void Compiler::optRemoveRedundantZeroInits()
(!hasImplicitControlFlow || (lclDsc->lvTracked && !lclDsc->lvLiveInOutOfHndlr)))
{
// If compMethodRequiresPInvokeFrame() returns true, lower may later
// insert a call to CORINFO_HELP_INIT_PINVOKE_FRAME which is a gc-safe point.
if (!lclDsc->HasGCPtr() ||
(!GetInterruptible() && !hasGCSafePoint && !compMethodRequiresPInvokeFrame()))
// insert a call to CORINFO_HELP_INIT_PINVOKE_FRAME but that is not a gc-safe point.
assert(emitter::emitNoGChelper(CORINFO_HELP_INIT_PINVOKE_FRAME));

if (!lclDsc->HasGCPtr() || (!GetInterruptible() && !hasGCSafePoint))
{
// The local hasn't been used and won't be reported to the gc between
// the prolog and this explicit initialization. Therefore, it doesn't
Expand Down

0 comments on commit facee18

Please sign in to comment.