From 06e7c52f2c1b1757923cc2ef195de20a08e5ac1a Mon Sep 17 00:00:00 2001 From: Sergey Andreenko Date: Fri, 12 Jun 2020 21:07:47 -0700 Subject: [PATCH] Keep block init/copy as baseline. Total bytes of diff: -21971 (-0.07% of base) 3075 total methods with Code Size differences (1589 improved, 1486 regressed), 184523 unchanged. Note: it improves code with retyping as well: 808 total methods with Code Size differences (808 improved, 0 regressed), 186790 unchanged. Found 55 files with textual diffs. Crossgen CodeSize Diffs for System.Private.CoreLib.dll, framework assemblies for default jit Summary of Code Size diffs: (Lower is better) Total bytes of diff: -22923 (-0.07% of base) --- src/coreclr/src/jit/lclmorph.cpp | 30 ++++++++++++++++++++++++++++++ src/coreclr/src/jit/lclvars.cpp | 5 +++++ 2 files changed, 35 insertions(+) diff --git a/src/coreclr/src/jit/lclmorph.cpp b/src/coreclr/src/jit/lclmorph.cpp index 176f1994d85ad..cdb8cc7e7637d 100644 --- a/src/coreclr/src/jit/lclmorph.cpp +++ b/src/coreclr/src/jit/lclmorph.cpp @@ -521,6 +521,36 @@ class LocalAddressVisitor final : public GenTreeVisitor PopValue(); break; + case GT_RETURN: + if (TopValue(0).Node() != node) + { + assert(TopValue(1).Node() == node); + assert(TopValue(0).Node() == node->gtGetOp1()); + GenTreeUnOp* ret = node->AsUnOp(); + GenTree* retVal = ret->gtGetOp1(); + if (!m_compiler->compDoOldStructRetyping() && retVal->OperIs(GT_LCL_VAR)) + { + // TODO-1stClassStructs: this block is a temporary workaround to keep diffs small, + // having `doNotEnreg` affect block init and copy transformations that affect many methods. + // I have a change that introduces more precise and effective solution for that, but it would + // be merged separatly. + GenTreeLclVar* lclVar = retVal->AsLclVar(); + unsigned lclNum = lclVar->GetLclNum(); + if (!m_compiler->lvaIsImplicitByRefLocal(lclVar->GetLclNum())) + { + LclVarDsc* varDsc = m_compiler->lvaGetDesc(lclNum); + if (varDsc->lvFieldCnt > 1) + { + m_compiler->lvaSetVarDoNotEnregister(lclNum DEBUGARG(Compiler::DNER_IsStructArg)); + } + } + } + + EscapeValue(TopValue(0), node); + PopValue(); + } + break; + default: while (TopValue(0).Node() != node) { diff --git a/src/coreclr/src/jit/lclvars.cpp b/src/coreclr/src/jit/lclvars.cpp index f8757328e8513..7a274991934b8 100644 --- a/src/coreclr/src/jit/lclvars.cpp +++ b/src/coreclr/src/jit/lclvars.cpp @@ -1974,6 +1974,11 @@ bool Compiler::StructPromotionHelper::ShouldPromoteStructVar(unsigned lclNum) shouldPromote = false; } } + else if (!compiler->compDoOldStructRetyping() && (lclNum == compiler->genReturnLocal) && (structPromotionInfo.fieldCnt > 1)) + { + // TODO-1stClassStructs: a temporary solution to keep diffs small, it will be fixed later. + shouldPromote = false; + } // // If the lvRefCnt is zero and we have a struct promoted parameter we can end up with an extra store of