From b98750179bdb7c5c327104b75db762fbc9707980 Mon Sep 17 00:00:00 2001 From: vsadov <8218165+VSadov@users.noreply.github.com> Date: Tue, 21 May 2024 17:44:35 -0700 Subject: [PATCH 1/2] couple tweaks to optRemoveRedundantZeroInits --- src/coreclr/jit/optimizer.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/coreclr/jit/optimizer.cpp b/src/coreclr/jit/optimizer.cpp index 8e7e09efaba73..cff4de08337e5 100644 --- a/src/coreclr/jit/optimizer.cpp +++ b/src/coreclr/jit/optimizer.cpp @@ -5918,7 +5918,12 @@ void Compiler::optRemoveRedundantZeroInits() { if (((tree->gtFlags & GTF_CALL) != 0)) { - hasGCSafePoint = true; + // if this is not a No-GC heleper + if (!tree->IsCall() || !emitter::emitNoGChelper(tree->AsCall()->GetHelperNum())) + { + // assume that we have a safe point. + hasGCSafePoint = true; + } } hasImplicitControlFlow |= hasEHSuccs && ((tree->gtFlags & GTF_EXCEPT) != 0); @@ -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 From 6f8069c0153f43375552b7d273d1f1303f6ad94f Mon Sep 17 00:00:00 2001 From: Vladimir Sadov Date: Wed, 22 May 2024 10:09:38 -0700 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Aman Khalid --- src/coreclr/jit/optimizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/optimizer.cpp b/src/coreclr/jit/optimizer.cpp index cff4de08337e5..5c7b97b306bf4 100644 --- a/src/coreclr/jit/optimizer.cpp +++ b/src/coreclr/jit/optimizer.cpp @@ -5918,7 +5918,7 @@ void Compiler::optRemoveRedundantZeroInits() { if (((tree->gtFlags & GTF_CALL) != 0)) { - // if this is not a No-GC heleper + // if this is not a No-GC helper if (!tree->IsCall() || !emitter::emitNoGChelper(tree->AsCall()->GetHelperNum())) { // assume that we have a safe point.