From: Ulya Trofimovich Date: Fri, 7 Apr 2017 17:49:58 +0000 (+0100) Subject: Don't forget histories when comparing right hand sides of tag commands. X-Git-Tag: 1.0~39^2~72 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a43d840244ab31a22d0fe62c3feb87b2e041e14a;p=re2c Don't forget histories when comparing right hand sides of tag commands. --- diff --git a/re2c/src/dfa/cfg/interfere.cc b/re2c/src/dfa/cfg/interfere.cc index aedf6576..d27cf8ad 100644 --- a/re2c/src/dfa/cfg/interfere.cc +++ b/re2c/src/dfa/cfg/interfere.cc @@ -5,53 +5,51 @@ namespace re2c { -static void interfere(const tcmd_t *cmd, const bool *live, bool *interf, bool *buf1, bool *buf2, size_t nver); +static void interfere(const tcmd_t *cmd, const bool *live, bool *interf, bool *buf, size_t nver); void cfg_t::interference(const cfg_t &cfg, const bool *live, bool *interf) { const size_t nver = static_cast(cfg.dfa.maxtagver) + 1; - bool *buf1 = new bool[nver]; - bool *buf2 = new bool[nver]; + bool *buf = new bool[nver]; const cfg_bb_t *b = cfg.bblocks, *e = b + cfg.nbbfin; memset(interf, 0, nver * nver * sizeof(bool)); for (; b < e; ++b, live += nver) { - interfere(b->cmd, live, interf, buf1, buf2, nver); + interfere(b->cmd, live, interf, buf, nver); } - delete[] buf1; - delete[] buf2; + delete[] buf; } void interfere(const tcmd_t *cmd, const bool *live, bool *interf, - bool *buf1, bool *buf2, size_t nver) + bool *buf, size_t nver) { // LHS of each command iterferes with all tags that are alive after // this command except its RHS and tags that are are assigned to // the same RHS by other commands in this block. - memcpy(buf1, live, nver * sizeof(bool)); for (const tcmd_t *p = cmd; p; p = p->next) { - const tagver_t r = p->rhs; + const tagver_t r = p->rhs, h = p->pred; // alive after this command - memcpy(buf2, buf1, nver * sizeof(bool)); - cfg_t::live_through_bblock(p->next, buf2); + memcpy(buf, live, nver * sizeof(bool)); + cfg_t::live_through_bblock(p->next, buf); // exclude RHS - if (tcmd_t::iscopy(r)) buf2[r] = false; + if (tcmd_t::iscopy(r)) buf[r] = false; // exclude tags assigned to the same RHS for (const tcmd_t *q = cmd; q; q = q->next) { - if (q->rhs == r) buf2[q->lhs] = false; + if (q->rhs == r && q->pred == h) { + buf[q->lhs] = false; + } } const size_t l = static_cast(p->lhs); for (size_t v = 0; v < nver; ++v) { - if (!buf2[v]) continue; + if (!buf[v]) continue; interf[l * nver + v] = interf[v * nver + l] = true; } } } } // namespace re2c -