Print tier in DumpJittedMethods. (dotnet/coreclr#27017)
authorSergey Andreenko <seandree@microsoft.com>
Mon, 7 Oct 2019 17:30:55 +0000 (10:30 -0700)
committerGitHub <noreply@github.com>
Mon, 7 Oct 2019 17:30:55 +0000 (10:30 -0700)
* Print tier in DumpJittedMethods.

I found that useful when reproducing bugs that require `complus_TieredCompilation=1`.

Example:
```
Compiling    0 System.SpanHelpers::IndexOf, IL size = 902, hsh=0xda613814 for Tier-1
Compiling    1 System.Text.Unicode.Utf16Utility::GetPointerToFirstInvalidChar, IL size = 1107, hsh=0xe576e43d
Compiling    2 System.Runtime.Intrinsics.Vector128::CreateScalarUnsafe, IL size = 21, hsh=0x6746a268 for Tier-0
```

* Fix JitFunctionTrace printing.

The opening is using decimal number, but the closing was using hex.

* Add compGetTieringName.

Commit migrated from https://github.com/dotnet/coreclr/commit/a6a38a77b1cedef1ab90a404b53550c851d9c2c3

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

index 760faacec05ccf1f27a23828af06dd7045261fd7..ef589546565c189e746c978a9c1554904728c1c6 100644 (file)
@@ -4229,6 +4229,26 @@ bool Compiler::compRsvdRegCheck(FrameLayoutState curState)
 }
 #endif // _TARGET_ARMARCH_
 
+const char* Compiler::compGetTieringName() const
+{
+    bool tier0 = opts.jitFlags->IsSet(JitFlags::JIT_FLAG_TIER0);
+    bool tier1 = opts.jitFlags->IsSet(JitFlags::JIT_FLAG_TIER1);
+    assert(!tier0 || !tier1); // We don't expect multiple TIER flags to be set at one time.
+
+    if (tier0)
+    {
+        return "Tier-0";
+    }
+    else if (tier1)
+    {
+        return "Tier-1";
+    }
+    else
+    {
+        return "No-Tier";
+    }
+}
+
 void Compiler::compFunctionTraceStart()
 {
 #ifdef DEBUG
@@ -4249,8 +4269,9 @@ void Compiler::compFunctionTraceStart()
         {
             printf("  ");
         }
-        printf("{ Start Jitting Method %d %s (MethodHash=%08x)\n", Compiler::jitTotalMethodCompiled, info.compFullName,
-               info.compMethodHash()); /* } editor brace matching workaround for this printf */
+        printf("{ Start Jitting Method %4d %s (MethodHash=%08x) %s\n", Compiler::jitTotalMethodCompiled,
+               info.compFullName, info.compMethodHash(),
+               compGetTieringName()); /* } editor brace matching workaround for this printf */
     }
 #endif // DEBUG
 }
@@ -4272,10 +4293,14 @@ void Compiler::compFunctionTraceEnd(void* methodCodePtr, ULONG methodCodeSize, b
         {
             printf("  ");
         }
+
+        // Note: that is incorrect if we are compiling several methods at the same time.
+        unsigned methodNumber = Compiler::jitTotalMethodCompiled - 1;
+
         /* { editor brace-matching workaround for following printf */
-        printf("} Jitted Method %03x at" FMT_ADDR "method %s size %08x%s%s\n", Compiler::jitTotalMethodCompiled,
-               DBG_ADDR(methodCodePtr), info.compFullName, methodCodeSize,
-               isNYI ? " NYI" : (compIsForImportOnly() ? " import only" : ""), opts.altJit ? " altjit" : "");
+        printf("} Jitted Method %4d at" FMT_ADDR "method %s size %08x%s%s\n", methodNumber, DBG_ADDR(methodCodePtr),
+               info.compFullName, methodCodeSize, isNYI ? " NYI" : (compIsForImportOnly() ? " import only" : ""),
+               opts.altJit ? " altjit" : "");
     }
 #endif // DEBUG
 }
@@ -5942,8 +5967,9 @@ int Compiler::compCompileHelper(CORINFO_MODULE_HANDLE            classPtr,
 #ifdef DEBUG
     if (JitConfig.DumpJittedMethods() == 1 && !compIsForInlining())
     {
-        printf("Compiling %4d %s::%s, IL size = %u, hsh=0x%x\n", Compiler::jitTotalMethodCompiled, info.compClassName,
-               info.compMethodName, info.compILCodeSize, info.compMethodHash());
+        printf("Compiling %4d %s::%s, IL size = %u, hsh=0x%x %s\n", Compiler::jitTotalMethodCompiled,
+               info.compClassName, info.compMethodName, info.compILCodeSize, info.compMethodHash(),
+               compGetTieringName());
     }
     if (compIsForInlining())
     {
index 28e1dcdd553f12f4fd66b99ef6deef310c834666..0fe76fc5a7e76a0888e0b5194241bed963bdc35a 100644 (file)
@@ -8703,6 +8703,8 @@ public:
 #endif
     }
 
+    const char* compGetTieringName() const;
+
     codeOptimize compCodeOpt()
     {
 #if 0