From abec165e0dd3ec2f5a46891f3c076b4c55149d56 Mon Sep 17 00:00:00 2001 From: Carol Eidt Date: Thu, 4 Apr 2019 09:31:30 -0700 Subject: [PATCH] Handle local struct pointer arithmetic (#23704) The assert introduced in #23570 was overly aggressive, and didn't account for the fact that pointer arithmetic can exist in the IL, not just introduced by morph. Fix #23693 --- src/jit/importer.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp index ce5c474..8dc9dab 100644 --- a/src/jit/importer.cpp +++ b/src/jit/importer.cpp @@ -10750,19 +10750,11 @@ void Compiler::impImportBlockCode(BasicBlock* block) } else if (lhs->OperIsBlk()) { - // Note that, prior to morph, we will only see ADDR(LCL_VAR) for any assignment to - // a local struct. We should never see LCL_VAR_ADDR or ADD(ADDR(LCL_VAR) + CNS). - // Other local struct references (e.g. FIELD or more complex pointer arithmetic) - // will cause the stack to be spilled. - GenTree* addr = lhs->AsBlk()->Addr(); - if (addr->OperIs(GT_ADDR) && addr->gtGetOp1()->OperIs(GT_LCL_VAR)) - { - lclVar = addr->gtGetOp1()->AsLclVarCommon(); - } - else - { - assert(addr->IsLocalAddrExpr() == nullptr); - } + // Check for ADDR(LCL_VAR), or ADD(ADDR(LCL_VAR),CNS_INT)) + // (the latter may appear explicitly in the IL). + // Local field stores will cause the stack to be spilled when + // they are encountered. + lclVar = lhs->AsBlk()->Addr()->IsLocalAddrExpr(); } if (lclVar != nullptr) { -- 2.7.4