ZAM control-flow tracking now explicitly includes the ends of loops

This commit is contained in:
Vern Paxson 2024-09-11 16:41:24 +02:00 committed by Christian Kreibich
parent b0e21b7e64
commit 56d01ea83b
4 changed files with 24 additions and 5 deletions

View file

@ -1031,6 +1031,23 @@ void ZAMCompiler::KillInst(zeek_uint_t i) {
insts1[j]->aux->cft[CFT_BLOCK_END] += be_cnt;
}
if ( cft.count(CFT_LOOP_END) > 0 ) {
// Propagate block-ends backwards.
int j = i;
while ( --j >= 0 )
if ( insts1[j]->live )
break;
ASSERT(j >= 0);
// Make sure the CFT entry is created.
AddCFT(insts1[j], CFT_LOOP_END);
auto le_cnt = cft[CFT_LOOP_END];
--le_cnt; // we already did one above
insts1[j]->aux->cft[CFT_LOOP_END] += le_cnt;
}
// If's can be killed because their bodies become empty,
// break's because they just lead to their following instruction,
// and next's if they become dead code.