Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix volatility checks in VN and loop side effects code #85467

Merged
merged 2 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8611,7 +8611,7 @@ bool Compiler::optComputeLoopSideEffectsOfBlock(BasicBlock* blk)
{
GenTree* arg = lhs->AsIndir()->Addr()->gtEffectiveVal(/*commaOnly*/ true);

if ((tree->gtFlags & GTF_IND_VOLATILE) != 0)
if ((lhs->gtFlags & GTF_IND_VOLATILE) != 0)
{
memoryHavoc |= memoryKindSet(GcHeap, ByrefExposed);
continue;
Expand Down
17 changes: 7 additions & 10 deletions src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10633,8 +10633,13 @@ void Compiler::fgValueNumberTree(GenTree* tree)
ValueNumPair addrXvnp;
vnStore->VNPUnpackExc(addr->gtVNPair, &addrNvnp, &addrXvnp);

// To be able to propagate exception sets, we give location nodes the "Void" VN.
if ((tree->gtFlags & GTF_IND_ASG_LHS) != 0)
{
tree->gtVNPair = vnStore->VNPWithExc(vnStore->VNPForVoid(), addrXvnp);
}
// Is the dereference immutable? If so, model it as referencing the read-only heap.
if (tree->gtFlags & GTF_IND_INVARIANT)
else if (tree->gtFlags & GTF_IND_INVARIANT)
{
assert(!isVolatile); // We don't expect both volatile and invariant

Expand Down Expand Up @@ -10709,9 +10714,7 @@ void Compiler::fgValueNumberTree(GenTree* tree)
ValueNum newUniq = vnStore->VNForExpr(compCurBB, tree->TypeGet());
tree->gtVNPair = vnStore->VNPWithExc(ValueNumPair(newUniq, newUniq), addrXvnp);
}
// In general we skip GT_IND nodes on that are the LHS of an assignment. (We labeled these earlier.)
// We will "evaluate" this as part of the assignment.
else if ((tree->gtFlags & GTF_IND_ASG_LHS) == 0)
else
{
var_types loadType = tree->TypeGet();
ssize_t offset = 0;
Expand Down Expand Up @@ -10754,12 +10757,6 @@ void Compiler::fgValueNumberTree(GenTree* tree)

tree->gtVNPair = vnStore->VNPWithExc(tree->gtVNPair, addrXvnp);
}

// To be able to propagate exception sets, we give location nodes the "Void" VN.
if ((tree->gtFlags & GTF_IND_ASG_LHS) != 0)
{
tree->gtVNPair = vnStore->VNPWithExc(vnStore->VNPForVoid(), addrXvnp);
}
}
else if (tree->OperGet() == GT_CAST)
{
Expand Down