Currently, dead stores are removed after the initial promotion of symbols to pseudos (simplify_one_symbol()). But more complex promotions are done later during memops simplification (simplify_loads()) and dead stores should be removed there too but aren't. Fix this by calling kill_dead_stores() after memops simplification. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- memops.c | 12 ++++++++++++ validation/optim/kill-stores0.c | 1 - validation/optim/kill-stores1.c | 1 - 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/memops.c b/memops.c index df2e4d6c2..20806175b 100644 --- a/memops.c +++ b/memops.c @@ -190,6 +190,7 @@ next_store: void simplify_memops(struct entrypoint *ep) { struct basic_block *bb; + pseudo_t pseudo; FOR_EACH_PTR_REVERSE(ep->bbs, bb) { simplify_loads(bb); @@ -198,4 +199,15 @@ void simplify_memops(struct entrypoint *ep) FOR_EACH_PTR_REVERSE(ep->bbs, bb) { kill_dominated_stores(bb); } END_FOR_EACH_PTR_REVERSE(bb); + + FOR_EACH_PTR(ep->accesses, pseudo) { + struct symbol *var = pseudo->sym; + unsigned long mod; + if (!var) + continue; + mod = var->ctype.modifiers; + if (mod & (MOD_VOLATILE | MOD_NONLOCAL | MOD_STATIC)) + continue; + kill_dead_stores(ep, pseudo, local_pseudo(pseudo)); + } END_FOR_EACH_PTR(pseudo); } diff --git a/validation/optim/kill-stores0.c b/validation/optim/kill-stores0.c index eb6eaa4e3..00c005ffd 100644 --- a/validation/optim/kill-stores0.c +++ b/validation/optim/kill-stores0.c @@ -28,7 +28,6 @@ static int baz(struct p p, struct q q) /* * check-name: kill-stores0 * check-command: test-linearize $file - * check-known-to-fail * * check-output-ignore * check-output-excludes: store\\. diff --git a/validation/optim/kill-stores1.c b/validation/optim/kill-stores1.c index 095378720..16a5dcf0d 100644 --- a/validation/optim/kill-stores1.c +++ b/validation/optim/kill-stores1.c @@ -38,7 +38,6 @@ static void foo5(void) /* * check-name: kill-stores1 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-pattern(4): load\\. -- 2.16.2 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html