Report registers as dead in GCInfo before the RhpPInvoke helper. (#14664)
authorSergey Andreenko <seandree@microsoft.com>
Tue, 24 Oct 2017 03:45:04 +0000 (20:45 -0700)
committerJan Kotas <jkotas@microsoft.com>
Tue, 24 Oct 2017 03:45:04 +0000 (20:45 -0700)
* move killGCRefs to the compiler

It makes it accessible from codegen.

* use killGCRefs in codeGen

It terminates live of GCRefs before RhpPInvoke.

* small ref

src/jit/codegenarmarch.cpp
src/jit/codegenxarch.cpp
src/jit/compiler.cpp
src/jit/compiler.h
src/jit/lsra.cpp
src/jit/lsra.h

index 3880305..56cad32 100644 (file)
@@ -2265,7 +2265,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
     // the GC pointer state before the callsite.
     // We can't utilize the typical lazy killing of GC pointers
     // at (or inside) the callsite.
-    if (call->IsUnmanaged())
+    if (compiler->killGCRefs(call))
     {
         genDefineTempLabel(genCreateTempLabel());
     }
index 7da42ce..f1730b9 100644 (file)
@@ -5283,7 +5283,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
     // the GC pointer state before the callsite.
     // We can't utilize the typical lazy killing of GC pointers
     // at (or inside) the callsite.
-    if (call->IsUnmanaged())
+    if (compiler->killGCRefs(call))
     {
         genDefineTempLabel(genCreateTempLabel());
     }
index b8877f2..5c20a87 100644 (file)
@@ -11391,3 +11391,33 @@ HelperCallProperties Compiler::s_helperCallProperties;
 
 /*****************************************************************************/
 /*****************************************************************************/
+
+//------------------------------------------------------------------------
+// killGCRefs:
+// Given some tree node return does it need all GC refs to be spilled from
+// callee save registers.
+//
+// Arguments:
+//    tree       - the tree for which we ask about gc refs.
+//
+// Return Value:
+//    true       - tree kills GC refs on callee save registers
+//    false      - tree doesn't affect GC refs on callee save registers
+bool Compiler::killGCRefs(GenTreePtr tree)
+{
+    if (tree->IsCall())
+    {
+        GenTreeCall* call = tree->AsCall();
+        if (call->IsUnmanaged())
+        {
+            return true;
+        }
+
+        if (call->gtCallMethHnd == eeFindHelper(CORINFO_HELP_JIT_PINVOKE_BEGIN))
+        {
+            assert(opts.ShouldUsePInvokeHelpers());
+            return true;
+        }
+    }
+    return false;
+}
index 3ff6375..6a64a7b 100644 (file)
@@ -9564,6 +9564,8 @@ public:
     void fgMorphMultiregStructArgs(GenTreeCall* call);
     GenTreePtr fgMorphMultiregStructArg(GenTreePtr arg, fgArgTabEntryPtr fgEntryPtr);
 
+    bool killGCRefs(GenTreePtr tree);
+
 }; // end of class Compiler
 
 // Inline methods of CompAllocator.
index c6a999f..c2258f0 100644 (file)
@@ -3083,7 +3083,7 @@ bool LinearScan::buildKillPositionsForNode(GenTree* tree, LsraLocation currentLo
             }
         }
 
-        if (killGCRefs(tree))
+        if (compiler->killGCRefs(tree))
         {
             RefPosition* pos = newRefPosition((Interval*)nullptr, currentLoc, RefTypeKillGCRefs, tree,
                                               (allRegs(TYP_REF) & ~RBM_ARG_REGS));
@@ -3094,35 +3094,6 @@ bool LinearScan::buildKillPositionsForNode(GenTree* tree, LsraLocation currentLo
     return false;
 }
 
-//------------------------------------------------------------------------
-// killGCRefs:
-// Given some tree node return does it need all GC refs to be spilled from
-// callee save registers.
-//
-// Arguments:
-//    tree       - the tree for which we ask about gc refs.
-//
-// Return Value:
-//    true       - tree kills GC refs on callee save registers
-//    false      - tree doesn't affect GC refs on callee save registers
-bool LinearScan::killGCRefs(GenTree* tree)
-{
-    if (tree->IsCall())
-    {
-        if ((tree->gtFlags & GTF_CALL_UNMANAGED) != 0)
-        {
-            return true;
-        }
-
-        if (tree->AsCall()->gtCallMethHnd == compiler->eeFindHelper(CORINFO_HELP_JIT_PINVOKE_BEGIN))
-        {
-            assert(compiler->opts.ShouldUsePInvokeHelpers());
-            return true;
-        }
-    }
-    return false;
-}
-
 //----------------------------------------------------------------------------
 // defineNewInternalTemp: Defines a ref position for an internal temp.
 //
index fed5d6e..55ebe5e 100644 (file)
@@ -772,8 +772,6 @@ private:
     // Given some tree node add refpositions for all the registers this node kills
     bool buildKillPositionsForNode(GenTree* tree, LsraLocation currentLoc);
 
-    bool killGCRefs(GenTree* tree);
-
     regMaskTP allRegs(RegisterType rt);
     regMaskTP allRegs(GenTree* tree);
     regMaskTP allMultiRegCallNodeRegs(GenTreeCall* tree);