Skip to content

Commit

Permalink
Added 'DOTNET_JitDisasmTesting' knob. (dotnet#89373)
Browse files Browse the repository at this point in the history
* Added 'DOTNET_JitDisasmTesting' knob.

* Formatting
  • Loading branch information
TIHan committed Jul 24, 2023
1 parent 08e3814 commit 16ad8cb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1966,7 +1966,7 @@ void CodeGen::genEmitMachineCode()
trackedStackPtrsContig = !compiler->opts.compDbgEnC;
#endif

if (compiler->opts.disAsm)
if (compiler->opts.disAsm && compiler->opts.disTesting)
{
printf("; BEGIN METHOD %s\n", compiler->eeGetMethodFullName(compiler->info.compMethodHnd));
}
Expand All @@ -1990,7 +1990,7 @@ void CodeGen::genEmitMachineCode()
((double)compiler->info.compTotalColdCodeSize * (double)PERFSCORE_CODESIZE_COST_COLD);
#endif // DEBUG || LATE_DISASM

if (compiler->opts.disAsm)
if (compiler->opts.disAsm && compiler->opts.disTesting)
{
printf("; END METHOD %s\n", compiler->eeGetMethodFullName(compiler->info.compMethodHnd));
}
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3038,6 +3038,10 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
if (opts.disAsm)
#endif
{
if (JitConfig.JitDisasmTesting())
{
opts.disTesting = true;
}
if (JitConfig.JitDisasmWithAlignmentBoundaries())
{
opts.disAlignment = true;
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9639,6 +9639,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#endif

bool disAsm; // Display native code as it is generated
bool disTesting; // Display BEGIN METHOD/END METHOD anchors for disasm testing
bool dspDiffable; // Makes the Jit Dump 'diff-able' (currently uses same DOTNET_* flag as disDiffable)
bool disDiffable; // Makes the Disassembly code 'diff-able'
bool disAlignment; // Display alignment boundaries in disassembly code
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/jitconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ CONFIG_STRING(JitStressRange, W("JitStressRange")) // Internal Jit
CONFIG_INTEGER(EnableIncompleteISAClass, W("EnableIncompleteISAClass"), 0) // Enable testing not-yet-implemented
#endif // defined(DEBUG)

CONFIG_METHODSET(JitDisasm, W("JitDisasm")) // Print codegen for given methods
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(JitDisasmWithAlignmentBoundaries, W("JitDisasmWithAlignmentBoundaries"), 0) // Print the alignment
Expand Down
2 changes: 2 additions & 0 deletions src/tests/Common/CLRTest.Jit.targets
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ if [[ ( -z "$DOTNET_JitStress" ) && ( -z "$DOTNET_JitStressRegs" ) && ( -z "$DOT
@(DisasmCheckFiles -> ' dotnet $CORE_ROOT/SuperFileCheck/SuperFileCheck.dll --csharp-list-method-names "%(Identity)" --allow-unused-prefixes --check-prefixes=CHECK,$(TargetArchitecture.ToUpperInvariant()),$(TargetArchitecture.ToUpperInvariant())-$(TargetOS.ToUpperInvariant()) > "$(BashDisasmListOutputFile)"
ERRORLEVEL=$?
export DOTNET_JitDisasm=`cat $(BashDisasmListOutputFile)`
export DOTNET_JitDisasmTesting=1
export DOTNET_JitDiffableDasm=1
export DOTNET_JitStdOutFile=$(BashDisasmOutputFile)
rm -f $(BashDisasmOutputFile)
Expand Down Expand Up @@ -280,6 +281,7 @@ IF "%DOTNET_JitStress%"=="" IF "%DOTNET_JitStressRegs%"=="" IF "%DOTNET_Tailcall
Exit /b 1
)', '%0d%0a')
for /F "delims=" %%g in ($(BatchDisasmListOutputFile)) do set DOTNET_JitDisasm=%%g
set DOTNET_JitDisasmTesting=1
set DOTNET_JitDiffableDasm=1
set DOTNET_JitStdOutFile=$(BatchDisasmOutputFile)
del $(BatchDisasmOutputFile) >nul 2>&1
Expand Down

0 comments on commit 16ad8cb

Please sign in to comment.