]> The Tcpdump Group git mirrors - libpcap/commitdiff
[optimizer] Recompute dominators if and/or_pullup succeeds
authorArchit Shah <[email protected]>
Wed, 28 Oct 2020 05:35:26 +0000 (05:35 +0000)
committerGuy Harris <[email protected]>
Sat, 20 Jan 2024 07:49:14 +0000 (23:49 -0800)
optimize.c

index a7cff9600e2b1119d0ea1f4669a53a445eb4971b..4115cb55dc81f1a552504ebd3f2c5e692a631d79 100644 (file)
@@ -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);
                }
        }
 }