Skip to content

Commit ac5f930

Browse files
authored
JIT: remove single-def restriction from escape analysis type refinement (#113808)
Instead, model all assignments to unescaped locals in the connection graph, and deduce the new type via graph analysis. Update the INDEX_ADDR expansion to handle cases where the array is stack allocated (interior pointers are now TYP_I_IMPL, not TYP_BYREF). Also use the new "unknown source" to do a more accurate analysis with OSR; only OSR locals have unknown values.
1 parent d7347b5 commit ac5f930

File tree

5 files changed

+324
-240
lines changed

5 files changed

+324
-240
lines changed

src/coreclr/jit/gentree.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7291,6 +7291,7 @@ bool GenTree::OperSupportsOrderingSideEffect() const
72917291

72927292
switch (OperGet())
72937293
{
7294+
case GT_ARR_ADDR:
72947295
case GT_BOUNDS_CHECK:
72957296
case GT_IND:
72967297
case GT_BLK:

src/coreclr/jit/gentree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ enum GenTreeFlags : unsigned int
450450
GTF_VAR_MOREUSES = 0x00800000, // GT_LCL_VAR -- this node has additional uses, for example due to cloning
451451
GTF_VAR_CONTEXT = 0x00400000, // GT_LCL_VAR -- this node is part of a runtime lookup
452452
GTF_VAR_EXPLICIT_INIT = 0x00200000, // GT_LCL_VAR -- this node is an "explicit init" store. Valid until rationalization.
453+
GTF_VAR_CONNECTED = 0x00100000, // GT_STORE_LCL_VAR -- this store was modelled in the connection graph during escape analysis
453454

454455
// For additional flags for GT_CALL node see GTF_CALL_M_*
455456

src/coreclr/jit/morph.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,17 +3181,21 @@ GenTree* Compiler::fgMorphIndexAddr(GenTreeIndexAddr* indexAddr)
31813181
}
31823182
#endif
31833183

3184+
// Note the array reference may now be TYP_I_IMPL, TYP_BYREF, or TYP_REF
3185+
//
3186+
var_types const arrPtrType = arrRef->TypeIs(TYP_I_IMPL) ? TYP_I_IMPL : TYP_BYREF;
3187+
31843188
// First element's offset
31853189
GenTree* elemOffset = gtNewIconNode(elemOffs, TYP_I_IMPL);
31863190
if (groupArrayRefWithElemOffset)
31873191
{
3188-
GenTree* basePlusOffset = gtNewOperNode(GT_ADD, TYP_BYREF, arrRef, elemOffset);
3189-
addr = gtNewOperNode(GT_ADD, TYP_BYREF, basePlusOffset, addr);
3192+
GenTree* basePlusOffset = gtNewOperNode(GT_ADD, arrPtrType, arrRef, elemOffset);
3193+
addr = gtNewOperNode(GT_ADD, arrPtrType, basePlusOffset, addr);
31903194
}
31913195
else
31923196
{
31933197
addr = gtNewOperNode(GT_ADD, TYP_I_IMPL, addr, elemOffset);
3194-
addr = gtNewOperNode(GT_ADD, TYP_BYREF, arrRef, addr);
3198+
addr = gtNewOperNode(GT_ADD, arrPtrType, arrRef, addr);
31953199
}
31963200

31973201
// TODO-Throughput: bash the INDEX_ADDR to ARR_ADDR here instead of creating a new node.

0 commit comments

Comments
 (0)