Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit e87474f

Browse files
authored
Merge pull request #6401 from AndyAyersMS/PropagateOptMethodFlags
Jit: fix issues with optMethodFlags
2 parents 3516aae + 43e5f18 commit e87474f

File tree

5 files changed

+34
-17
lines changed

5 files changed

+34
-17
lines changed

src/jit/compiler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,6 +1801,9 @@ void Compiler::compInit(ArenaAllocator * pAlloc, InlineInfo * inl
18011801
//Used by fgFindJumpTargets for inlining heuristics.
18021802
opts.instrCount = 0;
18031803

1804+
// Used to track when we should consider running EarlyProp
1805+
optMethodFlags = 0;
1806+
18041807
for (unsigned i = 0; i < MAX_LOOP_NUM; i++)
18051808
{
18061809
AllVarSetOps::AssignNoCopy(this, optLoopTable[i].lpAsgVars, AllVarSetOps::UninitVal());

src/jit/compiler.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5544,7 +5544,7 @@ protected :
55445544
};
55455545

55465546
#define OMF_HAS_NEWARRAY 0x00000001 // Method contains 'new' of an array
5547-
#define OMF_HAS_NEWOBJ 0x00800002 // Method contains 'new' of an object type.
5547+
#define OMF_HAS_NEWOBJ 0x00000002 // Method contains 'new' of an object type.
55485548
#define OMF_HAS_ARRAYREF 0x00000004 // Method contains array element loads or stores.
55495549
#define OMF_HAS_VTABLEREF 0x00000008 // Method contains method table reference.
55505550

@@ -5561,8 +5561,6 @@ protected :
55615561
OPK_OBJ_GETTYPE
55625562
};
55635563

5564-
bool impHasArrayRef;
5565-
55665564
bool gtIsVtableRef(GenTreePtr tree);
55675565
GenTreePtr getArrayLengthFromAllocation(GenTreePtr tree);
55685566
GenTreePtr getObjectHandleNodeFromAllocation(GenTreePtr tree);
@@ -5573,7 +5571,6 @@ protected :
55735571
bool optDoEarlyPropForFunc();
55745572
void optEarlyProp();
55755573

5576-
55775574
#if ASSERTION_PROP
55785575
/**************************************************************************
55795576
* Value/Assertion propagation

src/jit/earlyprop.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@ bool Compiler::gtIsVtableRef(GenTreePtr tree)
4343
{
4444
if (tree->OperGet() == GT_IND)
4545
{
46-
GenTreeIndir* indir = tree->AsIndir();
46+
GenTree* addr = tree->AsIndir()->Addr();
4747

48-
if (!indir->HasIndex())
48+
if (addr->OperIsAddrMode())
4949
{
50-
// Check if the base is an reference pointer.
51-
if (indir->Base()->TypeGet() == TYP_REF)
52-
{
53-
return true;
54-
}
50+
GenTreeAddrMode* addrMode = addr->AsAddrMode();
51+
52+
return (!addrMode->HasIndex() &&
53+
(addrMode->Base()->TypeGet() == TYP_REF));
5554
}
5655
}
5756

src/jit/flowgraph.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22248,6 +22248,22 @@ void Compiler::fgInsertInlineeBlocks(InlineInfo* pInlineInfo)
2224822248
compNeedsGSSecurityCookie |= InlineeCompiler->compNeedsGSSecurityCookie;
2224922249
compGSReorderStackLayout |= InlineeCompiler->compGSReorderStackLayout;
2225022250

22251+
// Update optMethodFlags
22252+
22253+
#ifdef DEBUG
22254+
unsigned optMethodFlagsBefore = optMethodFlags;
22255+
#endif
22256+
22257+
optMethodFlags |= InlineeCompiler->optMethodFlags;
22258+
22259+
#ifdef DEBUG
22260+
if (optMethodFlags != optMethodFlagsBefore)
22261+
{
22262+
JITDUMP("INLINER: Updating optMethodFlags -- root:%0x callee:%0x new:%0x\n",
22263+
optMethodFlagsBefore, InlineeCompiler->optMethodFlags, optMethodFlags);
22264+
}
22265+
#endif
22266+
2225122267
// If there is non-NULL return, replace the GT_CALL with its return value expression,
2225222268
// so later it will be picked up by the GT_RET_EXPR node.
2225322269
if ((pInlineInfo->inlineCandidateInfo->fncRetType != TYP_VOID) || (iciCall->gtCall.gtReturnType == TYP_STRUCT))

src/jit/importer.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10053,10 +10053,11 @@ void Compiler::impImportBlockCode(BasicBlock * block)
1005310053

1005410054
/* Mark the block as containing an index expression */
1005510055

10056-
if (op1->gtOper == GT_LCL_VAR)
10056+
if (op1->gtOper == GT_LCL_VAR)
1005710057
{
10058-
if (op2->gtOper == GT_LCL_VAR ||
10059-
op2->gtOper == GT_ADD)
10058+
if (op2->gtOper == GT_LCL_VAR ||
10059+
op2->gtOper == GT_CNS_INT ||
10060+
op2->gtOper == GT_ADD)
1006010061
{
1006110062
block->bbFlags |= BBF_HAS_INDX;
1006210063
optMethodFlags |= OMF_HAS_ARRAYREF;
@@ -10281,10 +10282,11 @@ void Compiler::impImportBlockCode(BasicBlock * block)
1028110282

1028210283
// Mark the block as containing an index expression
1028310284

10284-
if (op3->gtOper == GT_LCL_VAR)
10285+
if (op3->gtOper == GT_LCL_VAR)
1028510286
{
10286-
if (op1->gtOper == GT_LCL_VAR ||
10287-
op1->gtOper == GT_ADD)
10287+
if (op1->gtOper == GT_LCL_VAR ||
10288+
op1->gtOper == GT_CNS_INT ||
10289+
op1->gtOper == GT_ADD)
1028810290
{
1028910291
block->bbFlags |= BBF_HAS_INDX;
1029010292
optMethodFlags |= OMF_HAS_ARRAYREF;

0 commit comments

Comments
 (0)