From 1765d037c80f241bf6b391ed84c20cd8deb3dd32 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Tue, 26 Jan 2021 17:41:45 -0800 Subject: [PATCH] JIT: run instrumentation phase just after importing (#47476) As a prerequisite to enabling efficient instrumentation, add instrumentation immediately after importing, so the flow graph more closely reflects the IL level view. --- src/coreclr/jit/compiler.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index efdf66d864b35..036642e254f2b 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -4420,6 +4420,13 @@ void Compiler::compCompile(void** methodCodePtr, ULONG* methodCodeSize, JitFlags // DoPhase(this, PHASE_IMPORTATION, &Compiler::fgImport); + // If instrumenting, add block and class probes. + // + if (compileFlags->IsSet(JitFlags::JIT_FLAG_BBINSTR)) + { + DoPhase(this, PHASE_IBCINSTR, &Compiler::fgInstrumentMethod); + } + // Transform indirect calls that require control flow expansion. // DoPhase(this, PHASE_INDXCALL, &Compiler::fgTransformIndirectCalls); @@ -4494,11 +4501,6 @@ void Compiler::compCompile(void** methodCodePtr, ULONG* methodCodeSize, JitFlags fgRemoveEH(); #endif // !FEATURE_EH - if (compileFlags->IsSet(JitFlags::JIT_FLAG_BBINSTR)) - { - DoPhase(this, PHASE_IBCINSTR, &Compiler::fgInstrumentMethod); - } - // We could allow ESP frames. Just need to reserve space for // pushing EBP if the method becomes an EBP-frame after an edit. // Note that requiring a EBP Frame disallows double alignment. Thus if we change this