summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-08-12 14:40:46 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-08-12 16:18:31 -0400
commit11e309670b83e997d1dc2569faf002647f70a73b (patch)
tree742cf912e7a92e7e7ae82b892d6f2e5697a6399d /src
parent3e9be279725ebfa4be4e572061ab76a4e5f47066 (diff)
downloadbfs-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.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/opt.c b/src/opt.c
index ccd76c8..f735924 100644
--- a/src/opt.c
+++ b/src/opt.c
@@ -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);