Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Add helpers for printing assertion indexes
  • Loading branch information
SingleAccretion committed Jul 8, 2021
commit 89dabd660688abf47fc16d665415476be6ebf487
61 changes: 58 additions & 3 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ void Compiler::optAssertionInit(bool isLocalProp)
}

#ifdef DEBUG
void Compiler::optPrintAssertion(AssertionDsc* curAssertion, AssertionIndex assertionIndex /* =0 */)
void Compiler::optPrintAssertion(AssertionDsc* curAssertion, AssertionIndex assertionIndex /* = 0 */)
{
if (curAssertion->op1.kind == O1K_EXACT_TYPE)
{
Expand Down Expand Up @@ -778,13 +778,68 @@ void Compiler::optPrintAssertion(AssertionDsc* curAssertion, AssertionIndex asse

if (assertionIndex > 0)
{
printf(" index=#%02u, mask=", assertionIndex);
printf("%s", BitVecOps::ToString(apTraits, BitVecOps::MakeSingleton(apTraits, assertionIndex - 1)));
printf(", index = ");
optPrintAssertionIndex(assertionIndex);
}
printf("\n");
}

void Compiler::optPrintAssertionIndex(AssertionIndex index)
{
if (index == NO_ASSERTION_INDEX)
{
printf("#NA");
return;
}

printf("#%02u", index);
}

void Compiler::optPrintAssertionIndices(ASSERT_TP assertions)
{
if (BitVecOps::IsEmpty(apTraits, assertions))
{
optPrintAssertionIndex(NO_ASSERTION_INDEX);
return;
}

BitVecOps::Iter iter(apTraits, assertions);
unsigned bitIndex = 0;
if (iter.NextElem(&bitIndex))
{
optPrintAssertionIndex(static_cast<AssertionIndex>(bitIndex + 1));
while (iter.NextElem(&bitIndex))
{
printf(" ");
optPrintAssertionIndex(static_cast<AssertionIndex>(bitIndex + 1));
}
}
}
#endif // DEBUG

/* static */
void Compiler::optDumpAssertionIndices(const char* header, ASSERT_TP assertions, const char* footer /* = nullptr */ )
{
#ifdef DEBUG
Compiler* compiler = JitTls::GetCompiler();
if (compiler->verbose)
{
printf(header);
compiler->optPrintAssertionIndices(assertions);
if (footer != nullptr)
{
printf(footer);
}
}
#endif // DEBUG
}

/* static */
void Compiler::optDumpAssertionIndices(ASSERT_TP assertions, const char* footer /* = nullptr */ )
{
optDumpAssertionIndices("", assertions, footer);
}

/******************************************************************************
*
* Helper to retrieve the "assertIndex" assertion. Note that assertIndex 0
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7491,9 +7491,14 @@ class Compiler

#ifdef DEBUG
void optPrintAssertion(AssertionDsc* newAssertion, AssertionIndex assertionIndex = 0);
void optPrintAssertionIndex(AssertionIndex index);
void optPrintAssertionIndices(ASSERT_TP assertions);
void optDebugCheckAssertion(AssertionDsc* assertion);
void optDebugCheckAssertions(AssertionIndex AssertionIndex);
#endif
static void optDumpAssertionIndices(const char* header, ASSERT_TP assertions, const char* footer = nullptr);
static void optDumpAssertionIndices(ASSERT_TP assertions, const char* footer = nullptr);

void optAddCopies();
#endif // ASSERTION_PROP

Expand Down