summaryrefslogtreecommitdiff
path: root/src/jit/importer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/jit/importer.cpp')
-rw-r--r--src/jit/importer.cpp18
1 files changed, 14 insertions, 4 deletions
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())
{