diff options
author | Carol Eidt <carol.eidt@microsoft.com> | 2019-03-08 13:09:41 -0800 |
---|---|---|
committer | Carol Eidt <carol.eidt@microsoft.com> | 2019-03-08 13:09:41 -0800 |
commit | 384eefbd899ced778d99314df0d9e76fdccf71a4 (patch) | |
tree | 68af0d80f2ffbe0f2721d555e407c43cedc350f7 /src | |
parent | d17b66c8bbc21fc8be18d901e691ed7e9bc8d7ce (diff) | |
download | coreclr-384eefbd899ced778d99314df0d9e76fdccf71a4.tar.gz coreclr-384eefbd899ced778d99314df0d9e76fdccf71a4.tar.bz2 coreclr-384eefbd899ced778d99314df0d9e76fdccf71a4.zip |
Fix handling of struct setup assignments
In #22791 I was creating struct assignments with COMMAs on the rhs, but that isn't handled downstream.
Fix #23059
Diffstat (limited to 'src')
-rw-r--r-- | src/jit/flowgraph.cpp | 3 | ||||
-rw-r--r-- | src/jit/importer.cpp | 18 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/jit/flowgraph.cpp b/src/jit/flowgraph.cpp index 2207a0750a..4888ce27ec 100644 --- a/src/jit/flowgraph.cpp +++ b/src/jit/flowgraph.cpp @@ -21152,7 +21152,8 @@ void Compiler::fgDebugCheckFlags(GenTree* tree) // If parent is a TYP_VOID, we don't no need to propagate TYP_INT up. We are fine. if (op2 && op2->gtOper == GT_ASG) { - assert(tree->gtType == TYP_VOID); + // We can have ASGs on the RHS of COMMAs in setup arguments to a call. + assert(tree->gtType == TYP_VOID || tree->gtOper == GT_COMMA); } switch (oper) diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp index 4399381856..9c2236d5a7 100644 --- a/src/jit/importer.cpp +++ b/src/jit/importer.cpp @@ -1359,14 +1359,24 @@ GenTree* Compiler::impAssignStructPtr(GenTree* destAddr, { // Insert op1 after '*pAfterStmt' *pAfterStmt = fgInsertStmtAfter(block, *pAfterStmt, gtNewStmt(src->gtOp.gtOp1, ilOffset)); - // Evaluate the second thing using recursion. - return impAssignStructPtr(destAddr, src->gtOp.gtOp2, structHnd, curLevel, pAfterStmt, ilOffset, block); + } + else if (impTreeLast != nullptr) + { + // Do the side-effect as a separate statement. + impAppendTree(src->gtOp.gtOp1, curLevel, ilOffset); } else { - // We don't have an instruction to insert after, so use the entire comma expression as our rhs. - asgType = impNormStructType(structHnd); + // In this case we have neither been given a statement to insert after, nor are we + // in the importer where we can append the side effect. + // Instead, we're going to sink the assignment below the COMMA. + src->gtOp.gtOp2 = + impAssignStructPtr(destAddr, src->gtOp.gtOp2, structHnd, curLevel, pAfterStmt, ilOffset, block); + return src; } + + // Evaluate the second thing using recursion. + return impAssignStructPtr(destAddr, src->gtOp.gtOp2, structHnd, curLevel, pAfterStmt, ilOffset, block); } else if (src->IsLocal()) { |