Skip to content

Commit

Permalink
Handle local struct pointer arithmetic
Browse files Browse the repository at this point in the history
The assert introduced in dotnet#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
  • Loading branch information
CarolEidt committed Apr 3, 2019
1 parent 0164d68 commit 0de2c3a
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10752,19 +10752,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)
{
Expand Down

0 comments on commit 0de2c3a

Please sign in to comment.