From: Andy Ayers Date: Wed, 26 Apr 2023 23:48:46 +0000 (-0700) Subject: JIT: fix phase status for some minimal instrumentation cases (#85411) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~2610 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ffcee5308f6fbc85dbb3575c28d08c358d44180;p=platform%2Fupstream%2Fdotnet%2Fruntime.git JIT: fix phase status for some minimal instrumentation cases (#85411) The instrumentation phase may modify the flow graph in anticipation of doing some instrumentation, but then (because of minimal profiling) decide not to instrument. Make sure the phase status properly reflects that the phase made changes in this case, and a few other cases where we exit early without actually doing any instrumentation. Fixes #85061. --- diff --git a/src/coreclr/jit/fgprofile.cpp b/src/coreclr/jit/fgprofile.cpp index 3f6e02b..a856a72 100644 --- a/src/coreclr/jit/fgprofile.cpp +++ b/src/coreclr/jit/fgprofile.cpp @@ -2455,6 +2455,12 @@ PhaseStatus Compiler::fgInstrumentMethod() } } + // Even though we haven't yet instrumented, we may have made changes in anticipation... + // + const bool madeAnticipatoryChanges = fgCountInstrumentor->ModifiedFlow() || fgHistogramInstrumentor->ModifiedFlow(); + const PhaseStatus earlyExitPhaseStatus = + madeAnticipatoryChanges ? PhaseStatus::MODIFIED_EVERYTHING : PhaseStatus::MODIFIED_NOTHING; + // Optionally, when jitting, if there were no class probes and only one count probe, // suppress instrumentation. // @@ -2478,13 +2484,14 @@ PhaseStatus Compiler::fgInstrumentMethod() { JITDUMP( "Not instrumenting method: minimal probing enabled, and method has only one counter and no class probes\n"); - return PhaseStatus::MODIFIED_NOTHING; + + return earlyExitPhaseStatus; } if (schema.size() == 0) { JITDUMP("Not instrumenting method: no schemas were created\n"); - return PhaseStatus::MODIFIED_NOTHING; + return earlyExitPhaseStatus; } JITDUMP("Instrumenting method: %d count probes and %d class probes\n", fgCountInstrumentor->SchemaCount(), @@ -2515,13 +2522,9 @@ PhaseStatus Compiler::fgInstrumentMethod() if (res != E_NOTIMPL) { noway_assert(!"Error: unexpected hresult from allocPgoInstrumentationBySchema"); - return PhaseStatus::MODIFIED_NOTHING; } - // We may have modified control flow preparing for instrumentation. - // - const bool modifiedFlow = fgCountInstrumentor->ModifiedFlow() || fgHistogramInstrumentor->ModifiedFlow(); - return modifiedFlow ? PhaseStatus::MODIFIED_EVERYTHING : PhaseStatus::MODIFIED_NOTHING; + return earlyExitPhaseStatus; } JITDUMP("Instrumentation data base address is %p\n", dspPtr(profileMemory));