Skip to content

Commit

Permalink
Use normal VNs when adding NRE exception sets (dotnet#76639)
Browse files Browse the repository at this point in the history
  • Loading branch information
SingleAccretion committed Oct 7, 2022
1 parent ca50108 commit 6367772
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10464,7 +10464,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 @@ -10531,26 +10531,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

0 comments on commit 6367772

Please sign in to comment.