diff --git a/src/jit/objectalloc.cpp b/src/jit/objectalloc.cpp index d194b10359e0..232745ab8210 100644 --- a/src/jit/objectalloc.cpp +++ b/src/jit/objectalloc.cpp @@ -190,7 +190,7 @@ void ObjectAllocator::MarkEscapingVarsAndBuildConnGraph() { var_types type = comp->lvaTable[lclNum].TypeGet(); - if (type == TYP_REF || type == TYP_I_IMPL || type == TYP_BYREF) + if (type == TYP_REF || genActualType(type) == TYP_I_IMPL || type == TYP_BYREF) { m_ConnGraphAdjacencyMatrix[lclNum] = BitVecOps::MakeEmpty(&m_bitVecTraits); @@ -242,18 +242,21 @@ void ObjectAllocator::ComputeEscapingNodes(BitVecTraits* bitVecTraits, BitVec& e while (iterator.NextElem(&lclNum)) { - doOneMoreIteration = true; - - // newEscapingNodes = adjacentNodes[lclNum] - BitVecOps::Assign(bitVecTraits, newEscapingNodes, m_ConnGraphAdjacencyMatrix[lclNum]); - // newEscapingNodes = newEscapingNodes \ escapingNodes - BitVecOps::DiffD(bitVecTraits, newEscapingNodes, escapingNodes); - // escapingNodesToProcess = escapingNodesToProcess U newEscapingNodes - BitVecOps::UnionD(bitVecTraits, escapingNodesToProcess, newEscapingNodes); - // escapingNodes = escapingNodes U newEscapingNodes - BitVecOps::UnionD(bitVecTraits, escapingNodes, newEscapingNodes); - // escapingNodesToProcess = escapingNodesToProcess \ { lclNum } - BitVecOps::RemoveElemD(bitVecTraits, escapingNodesToProcess, lclNum); + if (m_ConnGraphAdjacencyMatrix[lclNum] != nullptr) + { + doOneMoreIteration = true; + + // newEscapingNodes = adjacentNodes[lclNum] + BitVecOps::Assign(bitVecTraits, newEscapingNodes, m_ConnGraphAdjacencyMatrix[lclNum]); + // newEscapingNodes = newEscapingNodes \ escapingNodes + BitVecOps::DiffD(bitVecTraits, newEscapingNodes, escapingNodes); + // escapingNodesToProcess = escapingNodesToProcess U newEscapingNodes + BitVecOps::UnionD(bitVecTraits, escapingNodesToProcess, newEscapingNodes); + // escapingNodes = escapingNodes U newEscapingNodes + BitVecOps::UnionD(bitVecTraits, escapingNodes, newEscapingNodes); + // escapingNodesToProcess = escapingNodesToProcess \ { lclNum } + BitVecOps::RemoveElemD(bitVecTraits, escapingNodesToProcess, lclNum); + } } } } @@ -392,6 +395,8 @@ bool ObjectAllocator::MorphAllocObjNodes() const unsigned int stackLclNum = MorphAllocObjNodeIntoStackAlloc(asAllocObj, block, stmt); m_HeapLocalToStackLocalMap.AddOrUpdate(lclNum, stackLclNum); + // We keep the set of possibly-stack-pointing pointers as a superset of the set of + // definitely-stack-pointing pointers. All definitely-stack-pointing pointers are in both sets. MarkLclVarAsDefinitelyStackPointing(lclNum); MarkLclVarAsPossiblyStackPointing(lclNum); stmt->gtStmtExpr->gtBashToNOP(); @@ -875,8 +880,7 @@ void ObjectAllocator::RewriteUses() newType = TYP_I_IMPL; tree = m_compiler->gtNewOperNode(GT_ADDR, newType, m_compiler->gtNewLclvNode(newLclNum, TYP_STRUCT)); - lclVarDsc->lvType = newType; - *use = tree; + *use = tree; } else { @@ -885,9 +889,11 @@ void ObjectAllocator::RewriteUses() { tree->ChangeType(newType); } - lclVarDsc->lvType = newType; } + JITDUMP("changing the type of V%02u\n from %s to %s", lclNum, varTypeName(lclVarDsc->lvType), + varTypeName(newType)); + lclVarDsc->lvType = newType; m_allocator->UpdateAncestorTypes(tree, &m_ancestors, newType); } diff --git a/src/jit/objectalloc.h b/src/jit/objectalloc.h index 683ebcffe109..b114c2b7674b 100644 --- a/src/jit/objectalloc.h +++ b/src/jit/objectalloc.h @@ -26,10 +26,12 @@ class ObjectAllocator final : public Phase //=============================================================================== // Data members - bool m_IsObjectStackAllocationEnabled; - bool m_AnalysisDone; - BitVecTraits m_bitVecTraits; - BitVec m_EscapingPointers; + bool m_IsObjectStackAllocationEnabled; + bool m_AnalysisDone; + BitVecTraits m_bitVecTraits; + BitVec m_EscapingPointers; + // We keep the set of possibly-stack-pointing pointers as a superset of the set of + // definitely-stack-pointing pointers. All definitely-stack-pointing pointers are in both sets. BitVec m_PossiblyStackPointingPointers; BitVec m_DefinitelyStackPointingPointers; LocalToLocalMap m_HeapLocalToStackLocalMap;