From 1b8e8d5d5d9187306fbce40568e9203b22f7ce65 Mon Sep 17 00:00:00 2001 From: Carol Eidt Date: Fri, 4 Jan 2019 14:32:34 -0800 Subject: [PATCH] [x86] Make copies of odd-size structs PR dotnet/coreclr#21304 inadvertently disabled this code for x86. This led to AV failures on desktop, but the same code silently loads the larger size on coreclr without AV'ing. Add an assert that we don't see this kind of node in x86 codegen. Commit migrated from https://github.com/dotnet/coreclr/commit/1ac4b90ffbb741da2d2166cf880415aab6028ec1 --- src/coreclr/src/jit/codegenxarch.cpp | 6 ++++++ src/coreclr/src/jit/morph.cpp | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/coreclr/src/jit/codegenxarch.cpp b/src/coreclr/src/jit/codegenxarch.cpp index cf9055c..fdd3fab 100644 --- a/src/coreclr/src/jit/codegenxarch.cpp +++ b/src/coreclr/src/jit/codegenxarch.cpp @@ -5303,6 +5303,12 @@ void CodeGen::genCallInstruction(GenTreeCall* call) { GenTreeObj* obj = source->AsObj(); unsigned argBytes = roundUp(obj->gtBlkSize, TARGET_POINTER_SIZE); +#ifdef _TARGET_X86_ + // If we have an OBJ, we must have created a copy if the original arg was not a + // local and was not a multiple of TARGET_POINTER_SIZE. + // Note that on x64/ux this will be handled by unrolling in genStructPutArgUnroll. + assert((argBytes == obj->gtBlkSize) || obj->Addr()->IsLocalAddrExpr()); +#endif // _TARGET_X86_ assert((curArgTabEntry->numSlots * TARGET_POINTER_SIZE) == argBytes); } #endif // FEATURE_PUT_STRUCT_ARG_STK diff --git a/src/coreclr/src/jit/morph.cpp b/src/coreclr/src/jit/morph.cpp index 09c6fc7..f1fe1b3 100644 --- a/src/coreclr/src/jit/morph.cpp +++ b/src/coreclr/src/jit/morph.cpp @@ -3831,7 +3831,6 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) unsigned roundupSize = (unsigned)roundUp(originalSize, TARGET_POINTER_SIZE); var_types structBaseType = argEntry->argType; -#ifndef _TARGET_X86_ // First, handle the case where the argument is passed by reference. if (argEntry->passedByRef) { @@ -3844,6 +3843,9 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) else { // This is passed by value. + CLANG_FORMAT_COMMENT_ANCHOR; + +#ifndef _TARGET_X86_ // Check to see if we can transform this into load of a primitive type. // 'size' must be the number of pointer sized items assert(size == roundupSize / TARGET_POINTER_SIZE); @@ -4053,6 +4055,7 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) size = 1; } +#endif // !_TARGET_X86_ #ifndef UNIX_AMD64_ABI // We still have a struct unless we converted the GT_OBJ into a GT_IND above... @@ -4087,7 +4090,6 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) } #endif // !UNIX_AMD64_ABI } -#endif // !_TARGET_X86_ } if (argEntry->isPassedInRegisters()) -- 2.7.4