Skip to content
Snippets Groups Projects
Commit c03847e8 authored by jdh8d's avatar jdh8d
Browse files

fixed for building cfg to mark an instruction as a basic block start if more...

fixed for building cfg to mark an instruction as a basic block start if more than one fallthrough reach that block

Former-commit-id: 76da4ad142e2a8924aa9141dd5aa50d05e6c02fe
parent 2b5cb30e
No related branches found
No related tags found
No related merge requests found
......@@ -31,7 +31,8 @@ using namespace libIRDB;
static set<Instruction_t*> FindBlockStarts(Function_t* func)
{
set<Instruction_t*> targets;
InstructionSet_t targets;
InstructionSet_t found_fallthrough_to;
if(func->GetEntryPoint())
/* the entry point of the function is a target instruction for this CFG */
......@@ -40,7 +41,7 @@ static set<Instruction_t*> FindBlockStarts(Function_t* func)
/* for each instruction, decide if it's a block start based on whether or not
* it can be indirectly branched to. Also mark direct targets as block starts.
*/
for(set<Instruction_t*>::iterator it=func->GetInstructions().begin();
for(InstructionSet_t::iterator it=func->GetInstructions().begin();
it!=func->GetInstructions().end();
++it
)
......@@ -65,6 +66,14 @@ static set<Instruction_t*> FindBlockStarts(Function_t* func)
/* there is a target, and a failthrough, and the fallthrough is in this function */
if(target && ft && is_in_container(func->GetInstructions(), ft))
targets.insert(ft);
// we already found a fallthrough to ft, so we have 2+ fallthroughs to ft. mark it as a control flow merge.
if( ft && is_in_container(found_fallthrough_to, ft))
targets.insert(ft);
// if there is a ft, mark that we've seen it now.
if(ft)
found_fallthrough_to.insert(ft);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment