From 0f0cf77ecf3b584d6bb8238f8a3ca4dda97762d8 Mon Sep 17 00:00:00 2001 From: SingleAccretion Date: Wed, 15 Jun 2022 17:34:01 +0300 Subject: [PATCH 1/2] Enable local struct args on x86 --- src/coreclr/jit/lclmorph.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/jit/lclmorph.cpp b/src/coreclr/jit/lclmorph.cpp index 3b1b635059afd..c44fc00e70fee 100644 --- a/src/coreclr/jit/lclmorph.cpp +++ b/src/coreclr/jit/lclmorph.cpp @@ -1096,7 +1096,7 @@ class LocalAddressVisitor final : public GenTreeVisitor // | Partial | LCL_FLD | OBJ/LCL_FLD | LCL_FLD | // |------------|---------|-------------|---------| // - // * - On Windows x64 only. + // * - On x86/Windows x64 only. // // |------------|------|------|--------|----------| // | SIMD | CALL | ASG | RETURN | HWI/SIMD | @@ -1114,9 +1114,9 @@ class LocalAddressVisitor final : public GenTreeVisitor 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) From 5e77628eefd0af42098b0fa065d5747e8414ee49 Mon Sep 17 00:00:00 2001 From: SingleAccretion Date: Wed, 27 Apr 2022 22:55:20 +0300 Subject: [PATCH 2/2] Morph --- src/coreclr/jit/morph.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index f8c7b0806e0e3..5c4ee50576beb 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -1419,7 +1419,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? @@ -1491,21 +1490,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) { @@ -4168,7 +4154,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; } } @@ -4215,7 +4201,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. @@ -4224,7 +4210,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); }