From: Ulya Trofimovich Date: Fri, 3 Mar 2017 17:27:35 +0000 (+0000) Subject: Remove dead 'copy' commands. X-Git-Tag: 1.0~39^2~113 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=342379744563365d0d2379a636b6073591814a8a;p=re2c Remove dead 'copy' commands. 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). --- diff --git a/re2c/src/ir/dfa/cfg/dce.cc b/re2c/src/ir/dfa/cfg/dce.cc index 78bc517f..a19d502e 100644 --- a/re2c/src/ir/dfa/cfg/dce.cc +++ b/re2c/src/ir/dfa/cfg/dce.cc @@ -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; + } + } } }