diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-08-12 14:40:46 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-08-12 16:18:31 -0400 |
commit | 11e309670b83e997d1dc2569faf002647f70a73b (patch) | |
tree | 742cf912e7a92e7e7ae82b892d6f2e5697a6399d /src | |
parent | 3e9be279725ebfa4be4e572061ab76a4e5f47066 (diff) | |
download | bfs-11e309670b83e997d1dc2569faf002647f70a73b.tar.xz |
opt: Copy data flow back up from the nested context in optimize()
This fixes warnings on commands like `bfs -exclude -true` or
`bfs -exclude -type f -type f`, because the data flow is properly shared
between the -exclude expression and the main one.
Fixes: 4a36bb9 ("expr: Make expressions variadic")
Diffstat (limited to 'src')
-rw-r--r-- | src/opt.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -2127,6 +2127,8 @@ static struct bfs_expr *optimize(struct bfs_opt *opt, struct bfs_expr *expr) { }; struct df_domain impure; + df_init_top(&opt->after_true); + df_init_top(&opt->after_false); for (int i = 0; i < 3; ++i) { struct bfs_opt nested = *opt; @@ -2140,9 +2142,11 @@ static struct bfs_expr *optimize(struct bfs_opt *opt, struct bfs_expr *expr) { continue; } + const struct visitor *visitor = passes[j].visitor; + // Skip reordering the first time through the passes, to // make warnings more understandable - if (passes[j].visitor == &reorder) { + if (visitor == &reorder) { if (i == 0) { continue; } else { @@ -2150,10 +2154,15 @@ static struct bfs_expr *optimize(struct bfs_opt *opt, struct bfs_expr *expr) { } } - expr = visit(&nested, expr, passes[j].visitor); + expr = visit(&nested, expr, visitor); if (!expr) { return NULL; } + + if (visitor == &data_flow) { + opt->after_true = nested.after_true; + opt->after_false = nested.after_false; + } } opt_leave(&nested, NULL); |