From: Archit Shah Date: Wed, 28 Oct 2020 05:35:26 +0000 (+0000) Subject: [optimizer] Recompute dominators if and/or_pullup succeeds X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/ae7216eb6094534d2a3a739d8867feb33a9fd25e [optimizer] Recompute dominators if and/or_pullup succeeds --- diff --git a/optimize.c b/optimize.c index a7cff960..4115cb55 100644 --- a/optimize.c +++ b/optimize.c @@ -1801,7 +1801,7 @@ opt_j(opt_state_t *opt_state, struct edge *ep) * */ static void -or_pullup(opt_state_t *opt_state, struct block *b) +or_pullup(opt_state_t *opt_state, struct block *b, struct block *root) { bpf_u_int32 val; int at_top; @@ -1962,10 +1962,15 @@ or_pullup(opt_state_t *opt_state, struct block *b) * optimizer gets into one of those infinite loops. */ opt_state->done = 0; + + /* + * Recompute dominator sets as control flow graph has changed. + */ + find_dom(opt_state, root); } static void -and_pullup(opt_state_t *opt_state, struct block *b) +and_pullup(opt_state_t *opt_state, struct block *b, struct block *root) { bpf_u_int32 val; int at_top; @@ -2058,6 +2063,11 @@ and_pullup(opt_state_t *opt_state, struct block *b) * optimizer gets into one of those infinite loops. */ opt_state->done = 0; + + /* + * Recompute dominator sets as control flow graph has changed. + */ + find_dom(opt_state, root); } static void @@ -2104,8 +2114,8 @@ opt_blks(opt_state_t *opt_state, struct icode *ic, int do_stmts) find_inedges(opt_state, ic->root); for (i = 1; i <= maxlevel; ++i) { for (p = opt_state->levels[i]; p; p = p->link) { - or_pullup(opt_state, p); - and_pullup(opt_state, p); + or_pullup(opt_state, p, ic->root); + and_pullup(opt_state, p, ic->root); } } }