From 3fb2aba3df7032c1267e95ca34a67d7852ed685f Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Mon, 16 Dec 2019 12:03:15 -0800 Subject: [PATCH] JIT: detect address of field as an invariant inlining arg (#845) Update the check for arg invariance to include addresses of fields in local structs. This allows the inliner to directly substitute more arguments into the body of the inlinee. Resolves dotnet/coreclr#27630. --- src/coreclr/src/jit/importer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/coreclr/src/jit/importer.cpp b/src/coreclr/src/jit/importer.cpp index 9bab7520553dd..a4091921eb591 100644 --- a/src/coreclr/src/jit/importer.cpp +++ b/src/coreclr/src/jit/importer.cpp @@ -18582,7 +18582,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 @@ -18607,8 +18609,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) { inlCurArgInfo->argIsInvariant = true; if (inlCurArgInfo->argIsThis && (curArgVal->gtOper == GT_CNS_INT) && (curArgVal->AsIntCon()->gtIconVal == 0))