Skip to content

Commit

Permalink
Enable TYP_STRUCT LCL_VAR/LCL_FLD call args on x86 (#70779)
Browse files Browse the repository at this point in the history
* Enable local struct args on x86
  • Loading branch information
SingleAccretion authored Jun 22, 2022
1 parent 9b4f152 commit 604681a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/coreclr/jit/lclmorph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor>
// | Partial | LCL_FLD | OBJ/LCL_FLD | LCL_FLD |
// |------------|---------|-------------|---------|
//
// * - On Windows x64 only.
// * - On x86/Windows x64 only.
//
// |------------|------|------|--------|----------|
// | SIMD | CALL | ASG | RETURN | HWI/SIMD |
Expand All @@ -1113,9 +1113,9 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor>

if (user->IsCall())
{
#ifndef WINDOWS_AMD64_ABI
#if !defined(WINDOWS_AMD64_ABI) && !defined(TARGET_X86)
return IndirTransform::None;
#endif // !WINDOWS_AMD64_ABI
#endif // !defined(WINDOWS_AMD64_ABI) && !defined(TARGET_X86)
}

if (match == StructMatch::Compatible)
Expand Down
24 changes: 5 additions & 19 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,6 @@ GenTree* CallArgs::MakeTmpArgNode(Compiler* comp, CallArg* arg)

if (varTypeIsStruct(type))
{

#if defined(TARGET_AMD64) || defined(TARGET_ARM64) || defined(TARGET_ARM) || defined(TARGET_LOONGARCH64)

// Can this type be passed as a primitive type?
Expand Down Expand Up @@ -1499,21 +1498,8 @@ GenTree* CallArgs::MakeTmpArgNode(Compiler* comp, CallArg* arg)
#endif // !(TARGET_ARM64 || TARGET_LOONGARCH64)
#endif // FEATURE_MULTIREG_ARGS
}

#else // not (TARGET_AMD64 or TARGET_ARM64 or TARGET_ARM or TARGET_LOONGARCH64)

// other targets, we pass the struct by value
assert(varTypeIsStruct(type));

addrNode = comp->gtNewOperNode(GT_ADDR, TYP_BYREF, argNode);

// Get a new Obj node temp to use it as a call argument.
// gtNewObjNode will set the GTF_EXCEPT flag if this is not a local stack object.
argNode = comp->gtNewObjNode(comp->lvaGetStruct(tmpVarNum), addrNode);

#endif // not (TARGET_AMD64 or TARGET_ARM64 or TARGET_ARM or TARGET_LOONGARCH64)

} // (varTypeIsStruct(type))
#endif // (TARGET_AMD64 or TARGET_ARM64 or TARGET_ARM or TARGET_LOONGARCH64)
} // (varTypeIsStruct(type))

if (addrNode != nullptr)
{
Expand Down Expand Up @@ -4173,7 +4159,7 @@ void Compiler::fgMakeOutgoingStructArgCopy(GenTreeCall* call, CallArg* arg)
{
tmp = (unsigned)lclNum;
found = true;
JITDUMP("reusing outgoing struct arg");
JITDUMP("reusing outgoing struct arg\n");
break;
}
}
Expand Down Expand Up @@ -4220,7 +4206,7 @@ void Compiler::fgMakeOutgoingStructArgCopy(GenTreeCall* call, CallArg* arg)
// When on Unix create LCL_FLD for structs passed in more than one registers. See fgMakeTmpArgNode
GenTree* argNode = copyBlk;

#else // FEATURE_FIXED_OUT_ARGS
#else // !FEATURE_FIXED_OUT_ARGS

// Structs are always on the stack, and thus never need temps
// so we have to put the copy and temp all into one expression.
Expand All @@ -4229,7 +4215,7 @@ void Compiler::fgMakeOutgoingStructArgCopy(GenTreeCall* call, CallArg* arg)
// Change the expression to "(tmp=val),tmp"
argNode = gtNewOperNode(GT_COMMA, argNode->TypeGet(), copyBlk, argNode);

#endif // FEATURE_FIXED_OUT_ARGS
#endif // !FEATURE_FIXED_OUT_ARGS

arg->SetEarlyNode(argNode);
}
Expand Down

0 comments on commit 604681a

Please sign in to comment.