Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable JitDisasm in Release #73365

Merged
merged 35 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
bf756bc
Use liberal vn for tls indirects
EgorBo Aug 1, 2022
c33bd4b
Merge branch 'main' of github.com:dotnet/runtime into main
EgorBo Aug 3, 2022
e9164de
Merge branch 'main' of github.com:dotnet/runtime into main
EgorBo Aug 3, 2022
24fc8a6
Initial impl
EgorBo Aug 4, 2022
75db099
Enable JitDisasm in Release
EgorBo Aug 4, 2022
0dfb332
Merge branch 'main' of github.com:dotnet/runtime into jit-disasm-release
EgorBo Aug 4, 2022
98a2a9d
Fix compilation errors
EgorBo Aug 4, 2022
3952560
Run jit-format
EgorBo Aug 4, 2022
c2d397a
Don't allocate instrDescDebugInfo when JitDisasm is not set
EgorBo Aug 4, 2022
f760723
fix build
EgorBo Aug 5, 2022
99c9254
clean up
EgorBo Aug 5, 2022
7fe3596
fix build
EgorBo Aug 5, 2022
4d776af
Apply Jakob's patch
EgorBo Aug 6, 2022
e95daa8
Remove some #ifdef DEBUG for displaying frame refs
jakobbotsch Aug 6, 2022
7255863
Fix alignment insertion assuming only emitForceNewIG can create new IGs
jakobbotsch Aug 6, 2022
be97773
Account for debug info when allocating IG buffers
jakobbotsch Aug 6, 2022
8f66d90
C++ify accessors
jakobbotsch Aug 6, 2022
611b9d2
Run jit-format
jakobbotsch Aug 6, 2022
adb7772
Fix a missing m_debugInfoSize add
jakobbotsch Aug 6, 2022
5e020ca
Couple of small cleanups
jakobbotsch Aug 6, 2022
9fa3367
Delete instrDesc constructors
jakobbotsch Aug 6, 2022
c0cb6da
Run jit-format
jakobbotsch Aug 6, 2022
8768b0e
Ensure alignment in inlineInstrDesc
jakobbotsch Aug 6, 2022
29f7c62
Update emitCheckAlignFitInCurIG
jakobbotsch Aug 6, 2022
6a1c872
Revert "Fix alignment insertion assuming only emitForceNewIG can crea…
jakobbotsch Aug 6, 2022
f266806
Oops
jakobbotsch Aug 6, 2022
829b019
Minor assertion nit
jakobbotsch Aug 6, 2022
13190b8
Update codegencommon.cpp
EgorBo Aug 8, 2022
b075a03
Tiny optimization
jakobbotsch Aug 8, 2022
d6759c2
Switch a couple of checks to m_debugInfoSize > 0
jakobbotsch Aug 8, 2022
00e754b
Move assert back
jakobbotsch Aug 8, 2022
318f275
Update emitarm64.cpp
EgorBo Aug 8, 2022
963596d
Add emitFirstInstrDesc and emitAdvanceInstrDesc
jakobbotsch Aug 9, 2022
840f26e
Fix function header
jakobbotsch Aug 9, 2022
4057d73
Fix build, fix bad refactor
jakobbotsch Aug 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/coreclr/jit/codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,13 @@ class CodeGen final : public CodeGenInterface
void* coldCodePtr;
void* consPtr;

#ifdef DEBUG
// Last instr we have displayed for dspInstrs
unsigned genCurDispOffset;

static const char* genInsName(instruction ins);
const char* genInsDisplayName(emitter::instrDesc* id);

static const char* genSizeStr(emitAttr size);
#endif // DEBUG

void genInitialize();

Expand Down
15 changes: 13 additions & 2 deletions src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1740,11 +1740,18 @@ void CodeGen::genGenerateMachineCode()
{
compiler->opts.disAsm = true;
}
#endif
compiler->compCurBB = compiler->fgFirstBB;

if (compiler->opts.disAsm)
{
printf("; Assembly listing for method %s\n", compiler->info.compFullName);
#ifdef DEBUG
const char* fullName = compiler->info.compFullName;
#else
const char* fullName = compiler->eeGetMethodFullName(compiler->info.compMethodHnd);
#endif

printf("; Assembly listing for method %s\n", fullName);

printf("; Emitting ");

Expand Down Expand Up @@ -1905,7 +1912,6 @@ void CodeGen::genGenerateMachineCode()
printf("; invoked as altjit\n");
}
}
#endif // DEBUG

// We compute the final frame layout before code generation. This is because LSRA
// has already computed exactly the maximum concurrent number of spill temps of each type that are
Expand Down Expand Up @@ -2057,6 +2063,11 @@ void CodeGen::genEmitMachineCode()
printf("*************** After end code gen, before unwindEmit()\n");
GetEmitter()->emitDispIGlist(true);
}
#else
if (compiler->opts.disAsm)
{
printf("\n; Total bytes of code %d\n\n", codeSize);
}
#endif

*nativeSizeOfCode = codeSize;
Expand Down
32 changes: 21 additions & 11 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2076,10 +2076,6 @@ unsigned char Compiler::compGetJitDefaultFill(Compiler* comp)
return defaultFill;
}

#endif // DEBUG

/*****************************************************************************/
#ifdef DEBUG
/*****************************************************************************/

VarName Compiler::compVarName(regNumber reg, bool isFloatReg)
Expand Down Expand Up @@ -2124,13 +2120,15 @@ VarName Compiler::compVarName(regNumber reg, bool isFloatReg)
return nullptr;
}

#endif // DEBUG

const char* Compiler::compRegVarName(regNumber reg, bool displayVar, bool isFloatReg)
{

#ifdef TARGET_ARM
isFloatReg = genIsValidFloatReg(reg);
#endif

#ifdef DEBUG
if (displayVar && (reg != REG_NA))
{
VarName varName = compVarName(reg, isFloatReg);
Expand All @@ -2148,6 +2146,7 @@ const char* Compiler::compRegVarName(regNumber reg, bool displayVar, bool isFloa
return nameVarReg[index];
}
}
#endif

/* no debug info required or no variable in that register
-> return standard name */
Expand Down Expand Up @@ -2194,6 +2193,7 @@ const char* Compiler::compRegNameForSize(regNumber reg, size_t size)
return sizeNames[reg][size - 1];
}

#ifdef DEBUG
const char* Compiler::compLocalVarName(unsigned varNum, unsigned offs)
{
unsigned i;
Expand All @@ -2214,9 +2214,8 @@ const char* Compiler::compLocalVarName(unsigned varNum, unsigned offs)

return nullptr;
}
#endif

/*****************************************************************************/
#endif // DEBUG
/*****************************************************************************/

void Compiler::compSetProcessor()
Expand Down Expand Up @@ -2819,14 +2818,15 @@ void Compiler::compInitOptions(JitFlags* jitFlags)

opts.compJitEarlyExpandMDArrays = (JitConfig.JitEarlyExpandMDArrays() != 0);

opts.disAsm = false;
opts.disDiffable = false;
opts.dspDiffable = false;
#ifdef DEBUG
opts.dspInstrs = false;
opts.dspLines = false;
opts.varNames = false;
opts.dmpHex = false;
opts.disAsm = false;
opts.disAsmSpilled = false;
opts.disDiffable = false;
opts.disAddr = false;
opts.disAlignment = false;
opts.dspCode = false;
Expand Down Expand Up @@ -3069,8 +3069,17 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
}
s_pJitFunctionFileInitialized = true;
}

#endif // DEBUG
#else // DEBUG
if (!JitConfig.JitDisasm().isEmpty())
{
const char* methodName = info.compCompHnd->getMethodName(info.compMethodHnd, nullptr);
const char* className = info.compCompHnd->getClassName(info.compClassHnd);
if (JitConfig.JitDisasm().contains(methodName, className, &info.compMethodInfo->args))
jkotas marked this conversation as resolved.
Show resolved Hide resolved
{
opts.disAsm = true;
}
}
#endif // !DEBUG

//-------------------------------------------------------------------------

Expand Down Expand Up @@ -6732,6 +6741,7 @@ int Compiler::compCompileHelper(CORINFO_MODULE_HANDLE classPtr,
}
#endif

compMethodID = 0;
#ifdef DEBUG
/* Give the function a unique number */

Expand Down
38 changes: 27 additions & 11 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9170,6 +9170,9 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
bool optRepeat; // Repeat optimizer phases k times
#endif

bool disAsm; // Display native code as it is generated
bool dspDiffable; // Makes the Jit Dump 'diff-able' (currently uses same COMPlus_* flag as disDiffable)
bool disDiffable; // Makes the Disassembly code 'diff-able'
#ifdef DEBUG
bool compProcedureSplittingEH; // Separate cold code from hot code for functions with EH
bool dspCode; // Display native code generated
Expand All @@ -9179,19 +9182,16 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
bool dspLines; // Display source-code lines intermixed with native code output
bool dmpHex; // Display raw bytes in hex of native code output
bool varNames; // Display variables names in native code output
bool disAsm; // Display native code as it is generated
bool disAsmSpilled; // Display native code when any register spilling occurs
bool disasmWithGC; // Display GC info interleaved with disassembly.
bool disDiffable; // Makes the Disassembly code 'diff-able'
bool disAddr; // Display process address next to each instruction in disassembly code
bool disAlignment; // Display alignment boundaries in disassembly code
bool disAsm2; // Display native code after it is generated using external disassembler
bool dspOrder; // Display names of each of the methods that we ngen/jit
bool dspUnwind; // Display the unwind info output
bool dspDiffable; // Makes the Jit Dump 'diff-able' (currently uses same COMPlus_* flag as disDiffable)
bool compLongAddress; // Force using large pseudo instructions for long address
// (IF_LARGEJMP/IF_LARGEADR/IF_LARGLDC)
bool dspGCtbls; // Display the GC tables
bool compLongAddress; // Force using large pseudo instructions for long address
// (IF_LARGEJMP/IF_LARGEADR/IF_LARGLDC)
bool dspGCtbls; // Display the GC tables
#endif

bool compExpandCallsEarly; // True if we should expand virtual call targets early for this method
Expand Down Expand Up @@ -9296,9 +9296,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

static bool s_pJitFunctionFileInitialized;
static MethodSet* s_pJitMethodSet;
#endif // DEBUG

#ifdef DEBUG
// silence warning of cast to greater size. It is easier to silence than construct code the compiler is happy with, and
// it is safe in this case
#pragma warning(push)
Expand All @@ -9316,6 +9314,24 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
return (o == ZERO) ? ZERO : (opts.dspDiffable ? T(0xD1FFAB1E) : o);
}
#pragma warning(pop)
#else
#pragma warning(push)
#pragma warning(disable : 4312)
template <typename T>
T dspPtr(T p)
{
return p;
}

template <typename T>
T dspOffset(T o)
{
return o;
}
#pragma warning(pop)
#endif

#ifdef DEBUG

static int dspTreeID(GenTree* tree)
{
Expand Down Expand Up @@ -9788,11 +9804,11 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

public:
#ifdef DEBUG
LONG compMethodID;
unsigned compGenTreeID;
unsigned compStatementID;
unsigned compBasicBlockID;
#endif
LONG compMethodID;

BasicBlock* compCurBB; // the current basic block in process
Statement* compCurStmt; // the current statement in process
Expand Down Expand Up @@ -10000,12 +10016,12 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

const char* compLocalVarName(unsigned varNum, unsigned offs);
VarName compVarName(regNumber reg, bool isFloatReg = false);
const char* compRegVarName(regNumber reg, bool displayVar = false, bool isFloatReg = false);
const char* compRegNameForSize(regNumber reg, size_t size);
const char* compFPregVarName(unsigned fpReg, bool displayVar = false);
void compDspSrcLinesByNativeIP(UNATIVE_OFFSET curIP);
void compDspSrcLinesByLineNum(unsigned line, bool seek = false);
#endif // DEBUG
const char* compRegNameForSize(regNumber reg, size_t size);
const char* compRegVarName(regNumber reg, bool displayVar = false, bool isFloatReg = false);

//-------------------------------------------------------------------------

Expand Down
Loading