Spill side-effects in impAssignMultiRegTypeToVar.
authorPat Gavlin <pagavlin@microsoft.com>
Wed, 19 Apr 2017 18:26:46 +0000 (11:26 -0700)
committerPat Gavlin <pagavlin@microsoft.com>
Wed, 19 Apr 2017 18:30:17 +0000 (11:30 -0700)
This importer function converts IR from the form

    tree

to
            /- tree
    STMT - =
            \- lclVar

in order to conform to the JIT's representation of multi-register values.
Today, it does not check whether or not the tree being spilled has any
side-effects that may interfere with the side-effects of trees that are
already on the evaluation stack, which can lead to bad codegen. This
change fixes this function to spill any side-effects on the stack
before generating the temp assign.

Fixes #10940.

src/jit/importer.cpp

index e678b15..2e3ca81 100644 (file)
@@ -15051,7 +15051,7 @@ void Compiler::impMarkLclDstNotPromotable(unsigned tmpNum, GenTreePtr src, CORIN
 GenTreePtr Compiler::impAssignMultiRegTypeToVar(GenTreePtr op, CORINFO_CLASS_HANDLE hClass)
 {
     unsigned tmpNum = lvaGrabTemp(true DEBUGARG("Return value temp for multireg return."));
-    impAssignTempGen(tmpNum, op, hClass, (unsigned)CHECK_SPILL_NONE);
+    impAssignTempGen(tmpNum, op, hClass, (unsigned)CHECK_SPILL_ALL);
     GenTreePtr ret = gtNewLclvNode(tmpNum, op->gtType);
 
     // TODO-1stClassStructs: Handle constant propagation and CSE-ing of multireg returns.