From ff2b735579b004f118e780cfc299bfbad863eb84 Mon Sep 17 00:00:00 2001 From: Lubomir Litchev Date: Wed, 9 Dec 2015 05:52:28 -0800 Subject: [PATCH] Fix a tight assert for System V struct returning. When having a single eightbyte structs, the type of the struct is normalized to the type of the single eight byte, thus replacing the TYP_STRUCT. Account for this in the importer. --- src/jit/importer.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp index 5204abe..83600f8 100644 --- a/src/jit/importer.cpp +++ b/src/jit/importer.cpp @@ -6999,7 +6999,6 @@ GenTreePtr Compiler::impFixupStructReturnType(GenTreePtr op, CORINFO_CL unsigned lclNum = op->gtLclVarCommon.gtLclNum; // Make sure this struct type stays as struct so that we can return it in registers. lvaTable[lclNum].lvDontPromote = true; - return op; } @@ -13637,7 +13636,14 @@ bool Compiler::impReturnInstruction(BasicBlock *block, int prefixFlags, OPCODE & bool restoreType = false; if ((op2->OperGet() == GT_CALL) && (info.compRetType == TYP_STRUCT)) { - noway_assert(op2->TypeGet() == TYP_STRUCT); // If not, then impFixupStructReturnType() must have touched it! + // If the op2 type is not TYP_STRUCT, then the impFixupStructReturnType has changed it. + // For System V a single eightbyte struct's type could be normalized to the type of the single eightbyte. + bool isNormalizedType = false; +#if defined(FEATURE_UNIX_AMD64_STRUCT_PASSING) + GenTreeCall* callTreePtr = op2->AsCall(); + isNormalizedType = callTreePtr->structDesc.passedInRegisters && (callTreePtr->structDesc.eightByteCount == 1); +#endif // defined(FEATURE_UNIX_AMD64_STRUCT_PASSING) + noway_assert(op2->TypeGet() == TYP_STRUCT || isNormalizedType); op2->gtType = info.compRetNativeType; restoreType = true; } -- 2.7.4