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

Don't propagate const TYP_REF as TYP_I_IMPL #75661

Merged
merged 15 commits into from
Sep 17, 2022
Merged
6 changes: 6 additions & 0 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3420,6 +3420,12 @@ GenTree* Compiler::optConstantAssertionProp(AssertionDsc* curAssertion,
// Here we have to allocate a new 'large' node to replace the old one
newTree = gtNewIconHandleNode(curAssertion->op2.u1.iconVal,
curAssertion->op2.u1.iconFlags & GTF_ICON_HDL_MASK);

// Make sure we don't change TYP_REF to an integer for non-null handles
if (!tree->IsIntegralConst(0))
{
newTree->ChangeType(TYP_REF);
}
}
else
{
Expand Down
11 changes: 9 additions & 2 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11121,8 +11121,15 @@ void Compiler::gtDispConst(GenTree* tree)

if (tree->TypeGet() == TYP_REF)
{
assert(tree->AsIntCon()->gtIconVal == 0);
printf(" null");
if (tree->AsIntCon()->gtIconVal == 0)
{
printf(" null");
}
else
{
assert(doesMethodHaveFrozenString());
printf(" 0x%llx", dspIconVal);
}
}
else if ((tree->AsIntCon()->gtIconVal > -1000) && (tree->AsIntCon()->gtIconVal < 1000))
{
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/optcse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,9 @@ unsigned Compiler::optValnumCSE_Index(GenTree* tree, Statement* stmt)
assert(vnStore->IsVNConstant(vnLibNorm));

// We don't share small offset constants when they require a reloc
// Also, we don't share non-null const gc handles
//
if (!tree->AsIntConCommon()->ImmedValNeedsReloc(this))
if (!tree->AsIntConCommon()->ImmedValNeedsReloc(this) && ((tree->IsIntegralConst(0)) || !varTypeIsGC(tree)))
{
// Here we make constants that have the same upper bits use the same key
//
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8162,7 +8162,7 @@ void Compiler::fgValueNumberTreeConst(GenTree* tree)
}
else
{
assert(tree->IsIconHandle(GTF_ICON_STR_HDL)); // Constant object can be only frozen string.
assert(doesMethodHaveFrozenString()); // Constant object can be only frozen string.
tree->gtVNPair.SetBoth(
vnStore->VNForHandle(ssize_t(tree->AsIntConCommon()->IconValue()), tree->GetIconHandleFlag()));
}
Expand Down