Skip to content

Commit

Permalink
JIT: initial workup for suppressing dumps and checks post-phase (#33305)
Browse files Browse the repository at this point in the history
Allow phases to declare what parts of jit state they might have modified,
and suppress dumps and checks based on these declarations.

Existing phases that don't know about this are handled by defaulting to
reporting that everything might have been modified.

Changed over all explicit phases to return status, as well as a handful
of phases that are methods on the Compiler object. Also converted a few
lambda phases into Compiler phase methods.
  • Loading branch information
AndyAyersMS authored Mar 30, 2020
1 parent 59be94b commit 6de9884
Show file tree
Hide file tree
Showing 17 changed files with 364 additions and 205 deletions.
3 changes: 2 additions & 1 deletion src/coreclr/src/jit/codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -1535,9 +1535,10 @@ class CodeGenPhase final : public Phase
}

protected:
virtual void DoPhase() override
virtual PhaseStatus DoPhase() override
{
(codeGen->*action)();
return PhaseStatus::MODIFIED_EVERYTHING;
}

private:
Expand Down
28 changes: 10 additions & 18 deletions src/coreclr/src/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4202,19 +4202,7 @@ void Compiler::compCompile(void** methodCodePtr, ULONG* methodCodeSize, JitFlags

// Import: convert the instrs in each basic block to a tree based intermediate representation
//
auto importPhase = [this]() {
fgImport();

assert(!fgComputePredsDone);
if (fgCheapPredsValid)
{
// Remove cheap predecessors before inlining and fat call transformation;
// allowing the cheap predecessor lists to be inserted causes problems
// with splitting existing blocks.
fgRemovePreds();
}
};
DoPhase(this, PHASE_IMPORTATION, importPhase);
DoPhase(this, PHASE_IMPORTATION, &Compiler::fgImport);

// Transform indirect calls that require control flow expansion.
//
Expand Down Expand Up @@ -4419,11 +4407,15 @@ void Compiler::compCompile(void** methodCodePtr, ULONG* methodCodeSize, JitFlags

// Clone code in finallys to reduce overhead for non-exceptional paths
//
auto cloneFinallyPhase = [this]() {
fgCloneFinally();
fgUpdateFinallyTargetFlags();
};
DoPhase(this, PHASE_CLONE_FINALLY, cloneFinallyPhase);
DoPhase(this, PHASE_CLONE_FINALLY, &Compiler::fgCloneFinally);

#if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)

// Update finally target flags after EH optimizations
//
DoPhase(this, PHASE_UPDATE_FINALLY_FLAGS, &Compiler::fgUpdateFinallyTargetFlags);

#endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)

#if DEBUG
if (lvaEnregEHVars)
Expand Down
31 changes: 21 additions & 10 deletions src/coreclr/src/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,13 @@ enum class PhaseChecks
CHECK_ALL
};

// Specify compiler data that a phase might modify
enum class PhaseStatus : unsigned
{
MODIFIED_NOTHING,
MODIFIED_EVERYTHING
};

// The following enum provides a simple 1:1 mapping to CLR API's
enum API_ICorJitInfo_Names
{
Expand Down Expand Up @@ -4359,31 +4366,35 @@ class Compiler

void fgInit();

void fgImport();
PhaseStatus fgImport();

void fgTransformIndirectCalls();
PhaseStatus fgTransformIndirectCalls();

void fgTransformPatchpoints();
PhaseStatus fgTransformPatchpoints();

void fgInline();
PhaseStatus fgInline();

void fgRemoveEmptyTry();
PhaseStatus fgRemoveEmptyTry();

void fgRemoveEmptyFinally();
PhaseStatus fgRemoveEmptyFinally();

void fgMergeFinallyChains();
PhaseStatus fgMergeFinallyChains();

void fgCloneFinally();
PhaseStatus fgCloneFinally();

void fgCleanupContinuation(BasicBlock* continuation);

void fgUpdateFinallyTargetFlags();
#if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)

PhaseStatus fgUpdateFinallyTargetFlags();

void fgClearAllFinallyTargetBits();

void fgAddFinallyTargetFlags();

void fgTailMergeThrows();
#endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)

PhaseStatus fgTailMergeThrows();
void fgTailMergeThrowsFallThroughHelper(BasicBlock* predBlock,
BasicBlock* nonCanonicalBlock,
BasicBlock* canonicalBlock,
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/src/jit/compphases.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ CompPhaseNameMacro(PHASE_EMPTY_TRY, "Remove empty try",
CompPhaseNameMacro(PHASE_EMPTY_FINALLY, "Remove empty finally", "EMPTYFIN", false, -1, false)
CompPhaseNameMacro(PHASE_MERGE_FINALLY_CHAINS, "Merge callfinally chains", "MRGCFCHN", false, -1, false)
CompPhaseNameMacro(PHASE_CLONE_FINALLY, "Clone finally", "CLONEFIN", false, -1, false)
CompPhaseNameMacro(PHASE_UPDATE_FINALLY_FLAGS, "Update finally target flags", "UPD-FTF", false, -1, false)
CompPhaseNameMacro(PHASE_COMPUTE_PREDS, "Compute preds", "PREDS", false, -1, false)
CompPhaseNameMacro(PHASE_EARLY_UPDATE_FLOW_GRAPH,"Update flow graph early pass", "UPD-FG-E", false, -1, false)
CompPhaseNameMacro(PHASE_STR_ADRLCL, "Morph - Structs/AddrExp", "MOR-STRAL",false, -1, false)
Expand Down
Loading

0 comments on commit 6de9884

Please sign in to comment.