From f37c0d0df3fb9ac3d9811fc02679b1382383ef00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 10 Dec 2017 11:57:07 +0100 Subject: [PATCH] Optimizer - Call bypass edges in CFG It will make things simpler when walking the graph for locals. --- c-opopt.cc | 20 +++++++++++++++----- c-opopt.hh | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/c-opopt.cc b/c-opopt.cc index d253dac..ecf300c 100644 --- a/c-opopt.cc +++ b/c-opopt.cc @@ -32,10 +32,19 @@ T_StringBuilder& opopt::operator<<( T_OptData::T_CtrlFlowEdge const& value ) noexcept { obj << value.target; - if ( value.type == T_OptData::T_CtrlFlowEdge::CALL ) { + switch ( value.type ) { + case T_OptData::T_CtrlFlowEdge::CALL: obj << "{c}"; - } else if ( value.type == T_OptData::T_CtrlFlowEdge::RET ) { + break; + case T_OptData::T_CtrlFlowEdge::RET: obj << "{r}"; + break; + case T_OptData::T_CtrlFlowEdge::BYPASS: + obj << "{b}"; + break; + + case T_OptData::T_CtrlFlowEdge::FLOW: + break; } return obj; } @@ -401,6 +410,7 @@ inline void BCFGHandleCalls_( // Handle calls constexpr auto tCall{ T_OptData::T_CtrlFlowEdge::CALL }; constexpr auto tRet{ T_OptData::T_CtrlFlowEdge::RET }; + constexpr auto tBypass{ T_OptData::T_CtrlFlowEdge::BYPASS }; for ( auto const& cs : data.callSites ) { auto const* frec{ data.cfgFunctions.get( cs.name ) }; assert( frec ); @@ -420,9 +430,9 @@ inline void BCFGHandleCalls_( bExit.outbound.addNew( cs.retBlock , tRet ); bRet.inbound.addNew( nExit , tRet ); - // Normal flow, skipping the call - bCall.outbound.addNew( cs.retBlock ); - bRet.inbound.addNew( cs.callBlock ); + // Call bypass + bCall.outbound.addNew( cs.retBlock , tBypass ); + bRet.inbound.addNew( cs.callBlock , tBypass ); } } diff --git a/c-opopt.hh b/c-opopt.hh index 91cb932..f4467f6 100644 --- a/c-opopt.hh +++ b/c-opopt.hh @@ -70,7 +70,7 @@ struct T_OptData struct T_CtrlFlowEdge { enum E_Type { - FLOW , CALL , RET + FLOW , CALL , RET , BYPASS }; uint32_t target;