Fix the arg name/number dumping for call args in LIR
authorBruce Forstall <brucefo@microsoft.com>
Mon, 14 Nov 2016 03:17:36 +0000 (19:17 -0800)
committerBruce Forstall <brucefo@microsoft.com>
Mon, 14 Nov 2016 22:11:09 +0000 (14:11 -0800)
Use the arg number in the arg info table. Before this, I saw cases
where the args were named: arg0, arg1, arg1, arg3, instead of:
arg0, arg2, arg1, arg3, for example.

src/jit/gentree.cpp

index 9ed1f51..aa879ef 100644 (file)
@@ -11886,22 +11886,8 @@ void Compiler::gtDispLIRNode(GenTree* node)
 
     const bool nodeIsCall = node->IsCall();
 
-    int numCallEarlyArgs = 0;
-    if (nodeIsCall)
-    {
-        GenTreeCall* call = node->AsCall();
-        for (GenTreeArgList* args = call->gtCallArgs; args != nullptr; args = args->Rest())
-        {
-            if (!args->Current()->IsArgPlaceHolderNode() && args->Current()->IsValue())
-            {
-                numCallEarlyArgs++;
-            }
-        }
-    }
-
     // Visit operands
-    IndentInfo operandArc    = IIArcTop;
-    int        callArgNumber = 0;
+    IndentInfo operandArc = IIArcTop;
     for (GenTree* operand : node->Operands())
     {
         if (operand->IsArgPlaceHolderNode() || !operand->IsValue())
@@ -11932,20 +11918,22 @@ void Compiler::gtDispLIRNode(GenTree* node)
             }
             else
             {
-                int callLateArgNumber = callArgNumber - numCallEarlyArgs;
+                fgArgTabEntryPtr curArgTabEntry = gtArgEntryByNode(call, operand);
+                assert(curArgTabEntry);
+
                 if (operand->OperGet() == GT_LIST)
                 {
                     int listIndex = 0;
                     for (GenTreeArgList* element = operand->AsArgList(); element != nullptr; element = element->Rest())
                     {
                         operand = element->Current();
-                        if (callLateArgNumber < 0)
+                        if (curArgTabEntry->lateArgInx == (unsigned)-1)
                         {
-                            gtGetArgMsg(call, operand, callArgNumber, listIndex, buf, sizeof(buf));
+                            gtGetArgMsg(call, operand, curArgTabEntry->argNum, listIndex, buf, sizeof(buf));
                         }
                         else
                         {
-                            gtGetLateArgMsg(call, operand, callLateArgNumber, listIndex, buf, sizeof(buf));
+                            gtGetLateArgMsg(call, operand, curArgTabEntry->lateArgInx, listIndex, buf, sizeof(buf));
                         }
 
                         displayOperand(operand, buf, operandArc, indentStack);
@@ -11954,19 +11942,17 @@ void Compiler::gtDispLIRNode(GenTree* node)
                 }
                 else
                 {
-                    if (callLateArgNumber < 0)
+                    if (curArgTabEntry->lateArgInx == (unsigned)-1)
                     {
-                        gtGetArgMsg(call, operand, callArgNumber, -1, buf, sizeof(buf));
+                        gtGetArgMsg(call, operand, curArgTabEntry->argNum, -1, buf, sizeof(buf));
                     }
                     else
                     {
-                        gtGetLateArgMsg(call, operand, callLateArgNumber, -1, buf, sizeof(buf));
+                        gtGetLateArgMsg(call, operand, curArgTabEntry->lateArgInx, -1, buf, sizeof(buf));
                     }
 
                     displayOperand(operand, buf, operandArc, indentStack);
                 }
-
-                callArgNumber++;
             }
         }
         else if (node->OperIsDynBlkOp())