Optimizer - Updated logging

This commit is contained in:
Emmanuel BENOîT 2017-12-14 18:51:14 +01:00
parent 312392d405
commit 8d95f4d1c7

View file

@ -141,10 +141,6 @@ uint32_t T_OptData::indexOf(
/*= T_OptData - CONTROL FLOW GRAPH CONSTRUCTION ==============================*/
namespace {
#warning Remove this later
#define LL1 2
#define LL2 2
// CFG type shortcuts
using T_CFN_ = T_OptData::T_CtrlFlowNode;
using P_CFN_ = T_OptData::P_CtrlFlowNode;
@ -191,7 +187,7 @@ inline void BCFGFuncEnter_(
sb << "Starting function '" << fn << "' at "
<< ctrlFlowGraph.size( );
return sb;
} , LL1 );
} , 5 );
cfgFunctions.add( fn , T_OptData::T_BasicBlock{
ctrlFlowGraph.size( ) } );
cNode = M_ADDNEW_( );
@ -215,7 +211,7 @@ inline void BCFGFuncExit_(
: 0 )
<< " instructions";
return sb;
} , LL1 );
} , 5 );
auto* frec{ cfgFunctions.get( fn ) };
assert( frec );
frec->count = ctrlFlowGraph.size( ) - frec->first;
@ -251,7 +247,7 @@ inline void BCFGCondEnter_(
: 0 )
<< " instructions";
return sb;
} , LL2 );
} , 6 );
}
inline void BCFGCondExit_(
@ -286,7 +282,7 @@ inline void BCFGCondExit_(
sb << "Exiting conditional instruction, stack size "
<< stack.size( );
return sb;
} , LL2 );
} , 6 );
}
/*----------------------------------------------------------------------------*/
@ -354,7 +350,7 @@ inline bool BCFGVisitor_(
: 0 )
<< " instructions";
return sb;
} , LL2 );
} , 6 );
auto& cs{ data.callSites.addNew( ) };
cs.name = ci.id( );
@ -375,7 +371,7 @@ inline bool BCFGVisitor_(
: 0 )
<< " instructions)";
return sb;
} , LL2 );
} , 6 );
cNode.clear( );
} else {
stack.last( ).hasDefault = stack.last( ).hasDefault
@ -491,7 +487,7 @@ void T_OptData::buildControlFlowGraph(
{
// Keep the old array, we'll reuse its contents
T_Array< P_CtrlFlowNode > old{ std::move( ctrlFlowGraph ) };
M_LOGSTR_( "Building control flow graph" , LL1 );
M_LOGSTR_( "Building control flow graph" , 4 );
// Create special nodes
M_ADDNEW_( );
@ -514,7 +510,7 @@ void T_OptData::buildControlFlowGraph(
BCFGHandleCalls_( *this );
logger( [this](){
return BCFGDumpAll_( *this );
} , LL2 );
} , 6 );
}
#undef M_ADDNEW_
@ -525,12 +521,6 @@ void T_OptData::buildControlFlowGraph(
/*= T_OptData - USE/DEFINE CHAINS ============================================*/
namespace {
#warning Remove this later
#undef LL1
#undef LL2
#define LL1 1
#define LL2 1
void BUDCAddRecord_(
A_Node& n ,
T_String const& id ,
@ -599,7 +589,7 @@ void BUDCAddRecord_(
}
sb << "), instr #" << *instrId;
return sb;
} , LL2 );
} , 6 );
}
void BUDCVisitor_(
@ -758,7 +748,7 @@ void BUDCLink_(
sb << " USE " << use;
return sb;
} , LL2 );
} , 6 );
}
/*----------------------------------------------------------------------------*/
@ -837,7 +827,7 @@ void BUDCWalkGraph_(
}
sb << ')';
return sb;
} , LL1 );
} , 5 );
auto const* const fn{ fnIndex
? &data.cfgFunctions[ *fnIndex ]
@ -845,13 +835,11 @@ void BUDCWalkGraph_(
auto const nFirst{ fn ? fn->first : 0u };
auto const nEnd{ fn ? ( fn->first + fn->count )
: data.ctrlFlowGraph.size( ) };
#if 0
data.logger( [=](){
T_StringBuilder sb{ "Nodes " };
sb << nFirst << " ... " << ( nEnd - 1 );;
return sb;
} , LL2 );
#endif
} , 8 );
changed.add( nFirst );
for ( auto i = nEnd ; i > nFirst + 1 ; i -- ) {
changed.add( i - 1 );
@ -859,13 +847,11 @@ void BUDCWalkGraph_(
while ( changed.size( ) ) {
const auto node{ changed[ 0 ] };
#if 0
data.logger( [=](){
T_StringBuilder sb{ "Checking node " };
sb << node;
return sb;
} , LL2 );
#endif
} , 8 );
assert( node >= nFirst && node < nEnd );
auto const& cn{ *data.ctrlFlowGraph[ node ] };
changed.remove( node );
@ -919,7 +905,6 @@ void BUDCWalkGraph_(
if ( sOut == sInput ) {
continue;
}
#if 0
data.logger( [&](){
T_StringBuilder sb;
sb << "Node " << node << ", setting output to {";
@ -931,8 +916,7 @@ void BUDCWalkGraph_(
}
sb << " }";
return sb;
} , LL2 );
#endif
} , 7 );
sOut = sInput;
// Add the node's successors into the changed set
@ -1028,7 +1012,7 @@ void BUDCWalkGraph_(
void T_OptData::buildUseDefineChains(
T_OpsParserOutput& program ) noexcept
{
M_LOGSTR_( "Building use/define chains" , LL1 );
M_LOGSTR_( "Building use/define chains" , 4 );
varUDChains.clear( );
// Find all definitions and uses, add them to the table
@ -1468,11 +1452,11 @@ void CPReplaceWithConstant_(
p.replace( eid , replacement );
oData.logger( [&]() {
T_StringBuilder sb;
sb << "Propagated constant from " << var.name
sb << "...... Propagated constant from " << var.name
<< " at " << instruction.location( )
<< " (value " << value << ")";
return sb;
} , LL2 );
} , 3 );
return true;
} );
}