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

Delete JitDoOldStructRetyping artifacts. #51092

Merged
merged 2 commits into from
Apr 13, 2021
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
6 changes: 0 additions & 6 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5851,7 +5851,6 @@ class Compiler
unsigned argIndex,
CORINFO_CLASS_HANDLE copyBlkClass);

void fgFixupStructReturn(GenTree* call);
GenTree* fgMorphLocalVar(GenTree* tree, bool forceRemorph);

public:
Expand Down Expand Up @@ -9624,11 +9623,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#endif // TARGET_AMD64
}

bool compDoOldStructRetyping()
{
return JitConfig.JitDoOldStructRetyping();
}

// Returns true if the method returns a value in more than one return register
// TODO-ARM-Bug: Deal with multi-register genReturnLocaled structs?
// TODO-ARM64: Does this apply for ARM64 too?
Expand Down
9 changes: 1 addition & 8 deletions src/coreclr/jit/fgbasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2560,14 +2560,7 @@ void Compiler::fgFindBasicBlocks()
{
// The lifetime of this var might expand multiple BBs. So it is a long lifetime compiler temp.
lvaInlineeReturnSpillTemp = lvaGrabTemp(false DEBUGARG("Inline return value spill temp"));
if (compDoOldStructRetyping())
{
lvaTable[lvaInlineeReturnSpillTemp].lvType = info.compRetNativeType;
}
else
{
lvaTable[lvaInlineeReturnSpillTemp].lvType = info.compRetType;
}
lvaTable[lvaInlineeReturnSpillTemp].lvType = info.compRetType;

// If the method returns a ref class, set the class of the spill temp
// to the method's return value. We may update this later if it turns
Expand Down
50 changes: 1 addition & 49 deletions src/coreclr/jit/fginline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,56 +618,8 @@ Compiler::fgWalkResult Compiler::fgUpdateInlineReturnExpressionPlaceHolder(GenTr
#endif // FEATURE_MULTIREG_RET

case SPK_EnclosingType:
{
// For enclosing type returns, we must return the call value to a temp since
// the return type is larger than the struct type.
if (!tree->IsCall())
{
break;
}

GenTreeCall* call = tree->AsCall();

assert(call->gtReturnType == TYP_STRUCT);

if (call->gtReturnType != TYP_STRUCT)
{
break;
}

JITDUMP("\nCall returns small struct via enclosing type, retyping. Before:\n");
DISPTREE(call);

// Create new struct typed temp for return value
const unsigned tmpNum =
comp->lvaGrabTemp(true DEBUGARG("small struct return temp for rejected inline"));
comp->lvaSetStruct(tmpNum, retClsHnd, false);
GenTree* assign = comp->gtNewTempAssign(tmpNum, call);

// Modify assign tree and call return types to the primitive return type
call->gtReturnType = returnType;
call->gtType = returnType;
assign->gtType = returnType;

// Modify the temp reference in the assign as a primitive reference via GT_LCL_FLD
GenTree* tempAsPrimitive = assign->AsOp()->gtOp1;
assert(tempAsPrimitive->gtOper == GT_LCL_VAR);
tempAsPrimitive->gtType = returnType;
tempAsPrimitive->ChangeOper(GT_LCL_FLD);

// Return temp as value of call tree via comma
GenTree* tempAsStruct = comp->gtNewLclvNode(tmpNum, TYP_STRUCT);
GenTree* comma = comp->gtNewOperNode(GT_COMMA, TYP_STRUCT, assign, tempAsStruct);
parent->ReplaceOperand(pTree, comma);

JITDUMP("\nAfter:\n");
DISPTREE(comma);
}
break;

case SPK_PrimitiveType:
// We should have already retyped the call as a primitive type
// when we first imported the call
// No work needs to be done, the call has struct type and should keep it.
break;

case SPK_ByReference:
Expand Down
13 changes: 3 additions & 10 deletions src/coreclr/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2317,17 +2317,10 @@ class MergedReturns

if (comp->compMethodReturnsNativeScalarType())
{
if (!comp->compDoOldStructRetyping())
returnLocalDsc.lvType = genActualType(comp->info.compRetType);
if (varTypeIsStruct(returnLocalDsc.lvType))
{
returnLocalDsc.lvType = genActualType(comp->info.compRetType);
if (varTypeIsStruct(returnLocalDsc.lvType))
{
comp->lvaSetStruct(returnLocalNum, comp->info.compMethodInfo->args.retTypeClass, false);
}
}
else
{
returnLocalDsc.lvType = genActualType(comp->info.compRetNativeType);
comp->lvaSetStruct(returnLocalNum, comp->info.compMethodInfo->args.retTypeClass, false);
}
}
else if (comp->compMethodReturnsRetBufAddr())
Expand Down
3 changes: 0 additions & 3 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15623,7 +15623,6 @@ GenTree* Compiler::gtNewTempAssign(
{
// It could come from `ASG(struct, 0)` that was propagated to `RETURN struct(0)`,
// and now it is merging to a struct again.
assert(!compDoOldStructRetyping());
assert(tmp == genReturnLocal);
ok = true;
}
Expand Down Expand Up @@ -15676,15 +15675,13 @@ GenTree* Compiler::gtNewTempAssign(
// 2. we are propagation `ASG(struct V01, 0)` to `RETURN(struct V01)`, `CNT_INT` doesn't `structHnd`;
// in these cases, we can use the type of the merge return for the assignment.
assert(val->OperIs(GT_IND, GT_LCL_FLD, GT_CNS_INT));
assert(!compDoOldStructRetyping());
assert(tmp == genReturnLocal);
valStructHnd = lvaGetStruct(genReturnLocal);
assert(valStructHnd != NO_CLASS_HANDLE);
}

if ((valStructHnd != NO_CLASS_HANDLE) && val->IsConstInitVal())
{
assert(!compDoOldStructRetyping());
asg = gtNewAssignNode(dest, val);
}
else if (varTypeIsStruct(varDsc) && ((valStructHnd != NO_CLASS_HANDLE) || varTypeIsSIMD(valTyp)))
Expand Down
Loading