From 0ee1d0c2c5c16777ff480413ff50bb7744342501 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Fri, 13 Dec 2019 10:43:12 -0800 Subject: [PATCH] JIT: detect address of field as an invariant inlining arg 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 c474744aec68e2..6efad156a31d81 100644 --- a/src/coreclr/src/jit/importer.cpp +++ b/src/coreclr/src/jit/importer.cpp @@ -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 @@ -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) { inlCurArgInfo->argIsInvariant = true; if (inlCurArgInfo->argIsThis && (curArgVal->gtOper == GT_CNS_INT) && (curArgVal->AsIntCon()->gtIconVal == 0))