From 249e877bcafa63d15f456b3540def22d9e9cdf31 Mon Sep 17 00:00:00 2001 From: Peter Kukol Date: Thu, 22 Sep 2016 17:26:08 -0700 Subject: [PATCH] Split MORPH into multiple phases. (dotnet/coreclr#7314) * Split MORPH into multiple phases. Commit migrated from https://github.com/dotnet/coreclr/commit/9811c769c00542f5e919deaab153d45e951c96d3 --- src/coreclr/src/jit/compiler.cpp | 6 +++--- src/coreclr/src/jit/compphases.h | 9 +++++++-- src/coreclr/src/jit/morph.cpp | 10 ++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/coreclr/src/jit/compiler.cpp b/src/coreclr/src/jit/compiler.cpp index e5fd4cf..07613e7 100644 --- a/src/coreclr/src/jit/compiler.cpp +++ b/src/coreclr/src/jit/compiler.cpp @@ -4094,6 +4094,8 @@ void Compiler::compCompile(void** methodCodePtr, ULONG* methodCodeSize, CORJIT_F fgRemovePreds(); } + EndPhase(PHASE_IMPORTATION); + if (compIsForInlining()) { /* Quit inlining if fgImport() failed for any reason. */ @@ -4112,8 +4114,6 @@ void Compiler::compCompile(void** methodCodePtr, ULONG* methodCodeSize, CORJIT_F assert(!compDonotInline()); - EndPhase(PHASE_IMPORTATION); - // Maybe the caller was not interested in generating code if (compIsForImportOnly()) { @@ -4162,7 +4162,7 @@ void Compiler::compCompile(void** methodCodePtr, ULONG* methodCodeSize, CORJIT_F /* Massage the trees so that we can generate code out of them */ fgMorph(); - EndPhase(PHASE_MORPH); + EndPhase(PHASE_MORPH_END); /* GS security checks for unsafe buffers */ if (getNeedsGSSecurityCookie()) diff --git a/src/coreclr/src/jit/compphases.h b/src/coreclr/src/jit/compphases.h index f193d04..fa3d585 100644 --- a/src/coreclr/src/jit/compphases.h +++ b/src/coreclr/src/jit/compphases.h @@ -22,7 +22,12 @@ CompPhaseNameMacro(PHASE_PRE_IMPORT, "Pre-import", "PRE-IMP", false, -1) CompPhaseNameMacro(PHASE_IMPORTATION, "Importation", "IMPORT", false, -1) CompPhaseNameMacro(PHASE_POST_IMPORT, "Post-import", "POST-IMP", false, -1) -CompPhaseNameMacro(PHASE_MORPH, "Morph", "MORPH", false, -1) +CompPhaseNameMacro(PHASE_MORPH_INIT, "Morph - Init", "MOR-INIT" ,false, -1) +CompPhaseNameMacro(PHASE_MORPH_INLINE, "Morph - Inlining", "MOR-INL", false, -1) +CompPhaseNameMacro(PHASE_MORPH_IMPBYREF, "Morph - ByRefs", "MOR-BYREF",false, -1) +CompPhaseNameMacro(PHASE_STR_ADRLCL, "Morph - Structs/AddrExp", "MOR-STRAL",false, -1) +CompPhaseNameMacro(PHASE_MORPH_GLOBAL, "Morph - Global", "MOR-GLOB", false, -1) +CompPhaseNameMacro(PHASE_MORPH_END, "Morph - Finish", "MOR-END", false, -1) CompPhaseNameMacro(PHASE_GS_COOKIE, "GS Cookie", "GS-COOK", false, -1) CompPhaseNameMacro(PHASE_COMPUTE_PREDS, "Compute preds", "PREDS", false, -1) CompPhaseNameMacro(PHASE_MARK_GC_POLL_BLOCKS, "Mark GC poll blocks", "GC-POLL", false, -1) @@ -55,7 +60,7 @@ CompPhaseNameMacro(PHASE_OPTIMIZE_INDEX_CHECKS, "Optimize index checks", #if FEATURE_VALNUM_CSE CompPhaseNameMacro(PHASE_OPTIMIZE_VALNUM_CSES, "Optimize Valnum CSEs", "OPT-CSE", false, -1) -#endif +#endif CompPhaseNameMacro(PHASE_VN_COPY_PROP, "VN based copy prop", "CP-PROP", false, -1) #if ASSERTION_PROP diff --git a/src/coreclr/src/jit/morph.cpp b/src/coreclr/src/jit/morph.cpp index 0ca2954..99f1da4 100644 --- a/src/coreclr/src/jit/morph.cpp +++ b/src/coreclr/src/jit/morph.cpp @@ -16846,6 +16846,8 @@ void Compiler::fgMorph() fgDebugCheckBBlist(false, false); #endif // DEBUG + EndPhase(PHASE_MORPH_INIT); + /* Inline */ fgInline(); #if 0 @@ -16855,6 +16857,8 @@ void Compiler::fgMorph() RecordStateAtEndOfInlining(); // Record "start" values for post-inlining cycles and elapsed time. + EndPhase(PHASE_MORPH_INLINE); + #ifdef DEBUG /* Inliner could add basic blocks. Check that the flowgraph data is up-to-date */ fgDebugCheckBBlist(false, false); @@ -16863,6 +16867,8 @@ void Compiler::fgMorph() /* For x64 and ARM64 we need to mark irregular parameters early so that they don't get promoted */ fgMarkImplicitByRefArgs(); + EndPhase(PHASE_MORPH_IMPBYREF); + /* Promote struct locals if necessary */ fgPromoteStructs(); @@ -16875,10 +16881,14 @@ void Compiler::fgMorph() fgStress64RsltMul(); #endif // DEBUG + EndPhase(PHASE_STR_ADRLCL); + /* Morph the trees in all the blocks of the method */ fgMorphBlocks(); + EndPhase(PHASE_MORPH_GLOBAL); + #if 0 JITDUMP("trees after fgMorphBlocks\n"); DBEXEC(VERBOSE, fgDispBasicBlocks(true)); -- 2.7.4