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

Use normal VNs when adding NRE exception sets #76639

Merged
merged 1 commit into from
Oct 7, 2022
Merged
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
23 changes: 9 additions & 14 deletions src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10463,7 +10463,7 @@ void Compiler::fgValueNumberAddExceptionSetForIndirection(GenTree* tree, GenTree
// We evaluate the baseAddr ValueNumber further in order
// to obtain a better value to use for the null check exception.
//
ValueNumPair baseVNP = baseAddr->gtVNPair;
ValueNumPair baseVNP = vnStore->VNPNormalPair(baseAddr->gtVNPair);
ValueNum baseLVN = baseVNP.GetLiberal();
ValueNum baseCVN = baseVNP.GetConservative();
ssize_t offsetL = 0;
Expand Down Expand Up @@ -10530,26 +10530,21 @@ void Compiler::fgValueNumberAddExceptionSetForIndirection(GenTree* tree, GenTree
}
}

// Create baseVNP, from the values we just computed,
baseVNP = ValueNumPair(baseLVN, baseCVN);

// The exceptions in "baseVNP" should have been added to the "tree"'s set already.
assert(vnStore->VNPExcIsSubset(vnStore->VNPExceptionSet(tree->gtVNPair), vnStore->VNPExceptionSet(baseVNP)));
assert(vnStore->VNPExcIsSubset(vnStore->VNPExceptionSet(tree->gtVNPair),
vnStore->VNPExceptionSet(ValueNumPair(baseLVN, baseCVN))));

// The normal VN for base address is used to create the NullPtrExc
ValueNumPair vnpBaseNorm = vnStore->VNPNormalPair(baseVNP);
ValueNumPair excChkSet = vnStore->VNPForEmptyExcSet();
// The normal VNs for base address are used to create the NullPtrExcs
ValueNumPair excChkSet = vnStore->VNPForEmptyExcSet();

if (!vnStore->IsKnownNonNull(vnpBaseNorm.GetLiberal()))
if (!vnStore->IsKnownNonNull(baseLVN))
{
excChkSet.SetLiberal(
vnStore->VNExcSetSingleton(vnStore->VNForFunc(TYP_REF, VNF_NullPtrExc, vnpBaseNorm.GetLiberal())));
excChkSet.SetLiberal(vnStore->VNExcSetSingleton(vnStore->VNForFunc(TYP_REF, VNF_NullPtrExc, baseLVN)));
}

if (!vnStore->IsKnownNonNull(vnpBaseNorm.GetConservative()))
if (!vnStore->IsKnownNonNull(baseCVN))
{
excChkSet.SetConservative(
vnStore->VNExcSetSingleton(vnStore->VNForFunc(TYP_REF, VNF_NullPtrExc, vnpBaseNorm.GetConservative())));
excChkSet.SetConservative(vnStore->VNExcSetSingleton(vnStore->VNForFunc(TYP_REF, VNF_NullPtrExc, baseCVN)));
}

// Add the NullPtrExc to "tree"'s value numbers.
Expand Down