Print reason why EH Var was not enregistered (#50215)
authorKunal Pathak <Kunal.Pathak@microsoft.com>
Fri, 26 Mar 2021 07:26:55 +0000 (00:26 -0700)
committerGitHub <noreply@github.com>
Fri, 26 Mar 2021 07:26:55 +0000 (00:26 -0700)
* zero init

* add indicator why EH-var did not get enregistered

* jit format

* review comments

src/coreclr/jit/compiler.h
src/coreclr/jit/lclvars.cpp

index 9b33d63..5e2c237 100644 (file)
@@ -539,6 +539,10 @@ public:
     unsigned char lvFldOffset;
     unsigned char lvFldOrdinal;
 
+#ifdef DEBUG
+    unsigned char lvDisqualifyEHVarReason = 'H';
+#endif
+
 #if FEATURE_MULTIREG_ARGS
     regNumber lvRegNumForSlot(unsigned slotNum)
     {
index 0a73c9d..286e570 100644 (file)
@@ -4099,6 +4099,21 @@ void Compiler::lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt,
 
                 if (varDsc->lvEhWriteThruCandidate || needsExplicitZeroInit)
                 {
+#ifdef DEBUG
+                    if (needsExplicitZeroInit)
+                    {
+                        varDsc->lvDisqualifyEHVarReason = 'Z';
+                        JITDUMP("EH Var V%02u needs explicit zero init. Disqualified as a register candidate.\n",
+                                lclNum);
+                    }
+                    else
+                    {
+                        varDsc->lvDisqualifyEHVarReason = 'M';
+                        JITDUMP("EH Var V%02u has multiple definitions. Disqualified as a register candidate.\n",
+                                lclNum);
+                    }
+
+#endif // DEBUG
                     varDsc->lvEhWriteThruCandidate     = false;
                     varDsc->lvDisqualifyForEhWriteThru = true;
                 }
@@ -4111,6 +4126,7 @@ void Compiler::lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt,
 #endif
                     {
                         varDsc->lvEhWriteThruCandidate = true;
+                        JITDUMP("Marking EH Var V%02u as a register candidate.\n", lclNum);
                     }
                 }
             }
@@ -7365,7 +7381,7 @@ void Compiler::lvaDumpEntry(unsigned lclNum, FrameLayoutState curState, size_t r
         }
         if (lvaEnregEHVars && varDsc->lvLiveInOutOfHndlr)
         {
-            printf("H");
+            printf("%c", varDsc->lvDisqualifyEHVarReason);
         }
         if (varDsc->lvLclFieldExpr)
         {