From 081490735c15d3ba79f79a9899da6154a2cff51c Mon Sep 17 00:00:00 2001 From: Joseph Tremoulet Date: Wed, 12 Apr 2017 13:00:20 -0400 Subject: [PATCH] Enable implicit byref struct promotion Remove the artificial limitation marking them address-taken. Add a hueristic that avoids promoting if there are too few references to the parameter. --- src/jit/morph.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp index bdffc36d07db..1f9fa385948d 100644 --- a/src/jit/morph.cpp +++ b/src/jit/morph.cpp @@ -17778,13 +17778,6 @@ void Compiler::fgRetypeImplicitByRefArgs() size = info.compCompHnd->getClassSize(typeHnd); } - // Temporary change to make reordering no-diff: mark any promoted implicit-by-ref args - // dependent promotions, by marking them address-taken. - if (varDsc->lvPromoted) - { - lvaSetVarAddrExposed(lclNum); - } - if (varDsc->lvPromoted) { // This implicit-by-ref was promoted; create a new temp to represent the @@ -17821,7 +17814,8 @@ void Compiler::fgRetypeImplicitByRefArgs() // through the pointer parameter, the same as we'd do for this // parameter if it weren't promoted at all (otherwise the initialization // of the new temp would just be a needless memcpy at method entry). - bool undoPromotion = lvaGetPromotionType(newVarDsc) == PROMOTION_TYPE_DEPENDENT; + bool undoPromotion = (lvaGetPromotionType(newVarDsc) == PROMOTION_TYPE_DEPENDENT) || + (varDsc->lvRefCnt <= varDsc->lvFieldCnt); if (!undoPromotion) {