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

JIT: Type fat pointer locals precisely, and avoid unnecessary normalization in inlining #99806

Merged
merged 2 commits into from
Mar 15, 2024
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
16 changes: 14 additions & 2 deletions src/coreclr/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1151,14 +1151,26 @@ bool Compiler::fgCastNeeded(GenTree* tree, var_types toType)
//
// Is the tree as GT_CAST or a GT_CALL ?
//
if (tree->OperGet() == GT_CAST)
if (tree->OperIs(GT_CAST))
{
fromType = tree->CastToType();
}
else if (tree->OperGet() == GT_CALL)
else if (tree->OperIs(GT_CALL))
{
fromType = (var_types)tree->AsCall()->gtReturnType;
}
else if (tree->OperIs(GT_LCL_VAR))
{
LclVarDsc* varDsc = lvaGetDesc(tree->AsLclVarCommon());
if (varDsc->lvNormalizeOnStore())
{
fromType = varDsc->TypeGet();
}
else
{
fromType = tree->TypeGet();
}
}
else
{
fromType = tree->TypeGet();
Expand Down
10 changes: 9 additions & 1 deletion src/coreclr/jit/importercalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,11 +1406,19 @@ var_types Compiler::impImportCall(OPCODE opcode,
// Such form allows to find statements with fat calls without walking through whole trees
// and removes problems with cutting trees.
assert(IsTargetAbi(CORINFO_NATIVEAOT_ABI));
if (call->OperGet() != GT_LCL_VAR) // can be already converted by impFixupCallStructReturn.
if (!call->OperIs(GT_LCL_VAR)) // can be already converted by impFixupCallStructReturn.
{
unsigned calliSlot = lvaGrabTemp(true DEBUGARG("calli"));
LclVarDsc* varDsc = lvaGetDesc(calliSlot);
// Keep the information about small typedness to avoid
// inserting unnecessary casts around normalization.
if (call->IsCall() && varTypeIsSmall(call->AsCall()->gtReturnType))
{
assert(call->AsCall()->NormalizesSmallTypesOnReturn());
varDsc->lvType = call->AsCall()->gtReturnType;
}

// TODO-Bug: CHECK_SPILL_NONE here looks wrong.
impStoreTemp(calliSlot, call, CHECK_SPILL_NONE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not fix it then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened #99808 about fixing it. I mainly think we should separate the diffs + create a regression test for it.

// impStoreTemp can change src arg list and return type for call that returns struct.
var_types type = genActualType(lvaTable[calliSlot].TypeGet());
Expand Down