src/coreclr/src/jit/phase.cpp
//------------------------------------------------------------------------
// PrePhase: perform dumps and checks before a phase executes
//
perform dumps and checks before a phase executes
perform dumps and checks before a phase executes
void Phase::PrePhase()
{
    comp->BeginPhase(m_phase);
#ifdef DEBUG
     In the long run the aim is to get rid of all pre-phase checks
     and dumps, relying instead on post-phase checks and dumps from
     the preceeding phase.
     Currently the list is just the set of phases that have custom
     derivations from the Phase class.
    static Phases s_whitelist[] = {PHASE_ALLOCATE_OBJECTS, PHASE_BUILD_SSA, PHASE_RATIONALIZE, PHASE_LOWERING,
                                   PHASE_STACK_LEVEL_SETTER};
    bool doPrePhase = false;
    for (int i = 0; i < sizeof(s_whitelist) / sizeof(Phases); i++)
    {
        if (m_phase == s_whitelist[i])
        {
            doPrePhase = true;
            break;
        }
    }
    if (VERBOSE)
    {
        if (doPrePhase)
        {
            printf("Trees before %s\n", m_name);
            comp->fgDispBasicBlocks(true);
        }
        if (comp->compIsForInlining())
        {
            printf("\n*************** Inline @[%06u] Starting PHASE %s\n",
                   Compiler::dspTreeID(comp->impInlineInfo->iciCall), m_name);
        }
        else
        {
            printf("\n*************** Starting PHASE %s\n", m_name);
        }
    }
    if (doPrePhase)
    {
        if ((comp->activePhaseChecks == PhaseChecks::CHECK_ALL) && (comp->expensiveDebugCheckLevel >= 2))
        {
             If everyone used the Phase class, this would duplicate the PostPhase() from the previous phase.
             But, not everyone does, so go ahead and do the check here, too.
            comp->fgDebugCheckBBlist();
            comp->fgDebugCheckLinks();
        }
    }
#endif  DEBUG
}
void Phase :: PrePhase ( ) { comp -> BeginPhase ( m_phase ) ; #ifdef DEBUG static Phases s_whitelist [ ] = { PHASE_ALLOCATE_OBJECTS , PHASE_BUILD_SSA , PHASE_RATIONALIZE , PHASE_LOWERING , PHASE_STACK_LEVEL_SETTER } ; bool doPrePhase = false ; for ( int i = 0 ; i < sizeof ( s_whitelist ) / sizeof ( Phases ) ; i ++ ) { if ( m_phase == s_whitelist [ i ] ) { doPrePhase = true ; break ; } } if ( VERBOSE ) { if ( doPrePhase ) { printf ( " \n " , m_name ) ; comp -> fgDispBasicBlocks ( true ) ; } if ( comp -> compIsForInlining ( ) ) { printf ( " \n \n " , Compiler :: dspTreeID ( comp -> impInlineInfo -> iciCall ) , m_name ) ; } else { printf ( " \n \n " , m_name ) ; } } if ( doPrePhase ) { if ( ( comp -> activePhaseChecks == PhaseChecks :: CHECK_ALL ) && ( comp -> expensiveDebugCheckLevel >= 2 ) ) { comp -> fgDebugCheckBBlist ( ) ; comp -> fgDebugCheckLinks ( ) ; } } #endif }
PrePhase: perform dumps and checks before a phase executes
PrePhase : perform dumps and checks before a phase executes
// To help in the incremental conversion of jit activity to phases // without greatly increasing dump size or checked jit time, we // currently whitelist the phases that do pre-phase checks and // dumps via the phase object, and not via explicit calls from // the various methods in the phase. // // In the long run the aim is to get rid of all pre-phase checks // and dumps, relying instead on post-phase checks and dumps from // the preceeding phase. // // Currently the list is just the set of phases that have custom // derivations from the Phase class. // If everyone used the Phase class, this would duplicate the PostPhase() from the previous phase. // But, not everyone does, so go ahead and do the check here, too. // DEBUG