]> granicus.if.org Git - re2c/commitdiff
Remove dead 'copy' commands.
authorUlya Trofimovich <skvadrik@gmail.com>
Fri, 3 Mar 2017 17:27:35 +0000 (17:27 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Fri, 3 Mar 2017 17:27:35 +0000 (17:27 +0000)
For some reason dead code elimination pass simply ignored 'copy' commands
and removed only dead 'save' commands. Strange as it seems, this went
unnoticed until now (when one of the POSIX tests compiled into C++ code
that triggered GCC warning about use of uninitialized variable).

re2c/src/ir/dfa/cfg/dce.cc

index 78bc517fba80b6d22654dac4b0c0da232871f93c..a19d502e26457664509e8feb4acda6d4f1978cec 100644 (file)
@@ -17,6 +17,13 @@ void cfg_t::dead_code_elimination(cfg_t &cfg, const bool *live)
                                ps = &s->next;
                        }
                }
+               for (tagcopy_t *c, **pc = &b->cmd->copy; (c = *pc);) {
+                       if (!live[c->lhs]) {
+                               *pc = c->next;
+                       } else {
+                               pc = &c->next;
+                       }
+               }
        }
 }