Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/coreclr/src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18571,7 +18571,9 @@ void Compiler::impInlineRecordArgInfo(InlineInfo* pInlineInfo,
inlCurArgInfo->argNode = curArgVal;

GenTree* lclVarTree;
if (impIsAddressInLocal(curArgVal, &lclVarTree) && varTypeIsStruct(lclVarTree))

const bool isAddressInLocal = impIsAddressInLocal(curArgVal, &lclVarTree);
if (isAddressInLocal && varTypeIsStruct(lclVarTree))
{
inlCurArgInfo->argIsByRefToStructLocal = true;
#ifdef FEATURE_SIMD
Expand All @@ -18596,8 +18598,7 @@ void Compiler::impInlineRecordArgInfo(InlineInfo* pInlineInfo,
INDEBUG(curArgVal->AsLclVar()->gtLclILoffs = argNum;)
}

if ((curArgVal->OperKind() & GTK_CONST) ||
((curArgVal->gtOper == GT_ADDR) && (curArgVal->AsOp()->gtOp1->gtOper == GT_LCL_VAR)))
if ((curArgVal->OperKind() & GTK_CONST) || isAddressInLocal)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some code between these 2 changes that doesn't appear in GitHub:

    if (curArgVal->gtFlags & GTF_ALL_EFFECT)
    {
        inlCurArgInfo->argHasGlobRef = (curArgVal->gtFlags & GTF_GLOB_REF) != 0;
        inlCurArgInfo->argHasSideEff = (curArgVal->gtFlags & (GTF_ALL_EFFECT & ~GTF_GLOB_REF)) != 0;
    }

It looks to me that in some cases this will unnecessarily set argHasGlobRef when the arg is a local address. Not sure what impact that has on CQ, if any.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw your comment about that over on dotnet/coreclr#27630. But I didn't see any global ref flag on the test case here, at least when inlining.

I can look into bypassing that for invariant args.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, here I see it in M1 on FIELD and ADDR:

STMT00002 (IL 0x00F...  ???)
               [000012] I-C-G-------              *  CALL      ref    System.Int32.ToString (exactContextHnd=0x02F7E975)
               [000011] ----G------- this in ecx  \--*  ADDR      byref 
               [000010] ----G-------                 \--*  FIELD     int    i
               [000009] ------------                    \--*  ADDR      byref 
               [000008] ------------                       \--*  LCL_VAR   int    V01 loc0         

{
inlCurArgInfo->argIsInvariant = true;
if (inlCurArgInfo->argIsThis && (curArgVal->gtOper == GT_CNS_INT) && (curArgVal->AsIntCon()->gtIconVal == 0))
Expand Down