Skip to content

Commit

Permalink
Fix an optimizer bug
Browse files Browse the repository at this point in the history
Good on me for noticing it a few weeks ago in dotnet#79722...

```
// Otherwise, must be local lhs form. TODO-Bug: this doesn't account for LCL_FLD.
// This will miss memory havoc induced by address-exposed local field stores.
```
  • Loading branch information
SingleAccretion committed Jan 4, 2023
1 parent 225eb65 commit 040c4da
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8601,13 +8601,12 @@ bool Compiler::optComputeLoopSideEffectsOfBlock(BasicBlock* blk)
}
}
// Otherwise, must be local lhs form. I should assert that.
else if (lhs->OperGet() == GT_LCL_VAR)
else if (lhs->OperIsLocal())
{
GenTreeLclVar* lhsLcl = lhs->AsLclVar();
GenTree* rhs = tree->AsOp()->gtOp2;
ValueNum rhsVN = rhs->gtVNPair.GetLiberal();
GenTreeLclVarCommon* lhsLcl = lhs->AsLclVarCommon();
ValueNum rhsVN = tree->AsOp()->gtOp2->gtVNPair.GetLiberal();
// If we gave the RHS a value number, propagate it.
if (rhsVN != ValueNumStore::NoVN)
if (lhsLcl->OperIs(GT_LCL_VAR) && (rhsVN != ValueNumStore::NoVN))
{
rhsVN = vnStore->VNNormalValue(rhsVN);
if (lhsLcl->HasSsaName())
Expand Down

0 comments on commit 040c4da

Please sign in to comment.