From f02b44bfec96e63eb2faba8915e0e1c93f1e81c6 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Tue, 16 Jan 2024 15:39:31 +0100 Subject: [PATCH] Add DOTNET_JitDisasmOnlyOptimized knob (#96960) --- docs/design/coreclr/jit/viewing-jit-dumps.md | 1 + src/coreclr/jit/compiler.cpp | 6 ++++++ src/coreclr/jit/jitconfigvalues.h | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/design/coreclr/jit/viewing-jit-dumps.md b/docs/design/coreclr/jit/viewing-jit-dumps.md index 2d6a596bd9360..d24611be40211 100644 --- a/docs/design/coreclr/jit/viewing-jit-dumps.md +++ b/docs/design/coreclr/jit/viewing-jit-dumps.md @@ -244,6 +244,7 @@ E.g., `DOTNET_JitDisasm=Main`, `DOTNET_JitDisasm=Main Test1 Test2`, `DOTNET_JitD * `DOTNET_JitDisasmDiffable`={1 or 0} - set to 1 to make the generated code "diff-able", namely, replace pointer values in the output with the same well-known, identical values, so they textually compare identically. * `DOTNET_JitDisasmWithAlignmentBoundaries`={1 or 0} - set to 1 to display alignment boundaries in the generated code. +* `DOTNET_JitDisasmOnlyOptimized`={1 or 0} - set to 1 to hide disasm for unoptimized code * `DOTNET_JitDisasmWithCodeBytes`={1 or 0} - set to 1 to display the actual code bytes in addition to textual disassembly. (Don't use if `DOTNET_JitDisasmDiffable=1`.) * `DOTNET_JitStdOutFile`={file name} - if not set, all JIT output goes to standard output. If set, it is the name of a file to which JIT output diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index a69527436913a..f01eb2b74bf0e 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -7151,6 +7151,12 @@ int Compiler::compCompileHelper(CORINFO_MODULE_HANDLE classPtr, compSetOptimizationLevel(); + if ((JitConfig.JitDisasmOnlyOptimized() != 0) && (!opts.OptimizationEnabled())) + { + // Disable JitDisasm for non-optimized code. + opts.disAsm = false; + } + #if COUNT_BASIC_BLOCKS bbCntTable.record(fgBBcount); diff --git a/src/coreclr/jit/jitconfigvalues.h b/src/coreclr/jit/jitconfigvalues.h index 753b7451b875c..82c1a1a0697ae 100644 --- a/src/coreclr/jit/jitconfigvalues.h +++ b/src/coreclr/jit/jitconfigvalues.h @@ -255,8 +255,9 @@ CONFIG_INTEGER(EnableIncompleteISAClass, W("EnableIncompleteISAClass"), 0) // En CONFIG_METHODSET(JitDisasm, W("JitDisasm")) // Print codegen for given methods CONFIG_INTEGER(JitDisasmTesting, W("JitDisasmTesting"), 0) // Display BEGIN METHOD/END METHOD anchors for disasm testing -CONFIG_INTEGER(JitDisasmDiffable, W("JitDisasmDiffable"), 0) // Make the disassembly diff-able -CONFIG_INTEGER(JitDisasmSummary, W("JitDisasmSummary"), 0) // Prints all jitted methods to the console +CONFIG_INTEGER(JitDisasmDiffable, W("JitDisasmDiffable"), 0) // Make the disassembly diff-able +CONFIG_INTEGER(JitDisasmSummary, W("JitDisasmSummary"), 0) // Prints all jitted methods to the console +CONFIG_INTEGER(JitDisasmOnlyOptimized, W("JitDisasmOnlyOptimized"), 0) // Hides disassembly for unoptimized codegen CONFIG_INTEGER(JitDisasmWithAlignmentBoundaries, W("JitDisasmWithAlignmentBoundaries"), 0) // Print the alignment // boundaries. CONFIG_INTEGER(JitDisasmWithCodeBytes, W("JitDisasmWithCodeBytes"), 0) // Print the instruction code bytes