From 6bcccb4c5d1fe69fa173547c7a4d0e36a1312452 Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Mon, 22 Feb 2016 10:58:23 +1100 Subject: [PATCH] Rose: further generalise literal dedupe work --- src/rose/rose_build_misc.cpp | 50 ++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/rose/rose_build_misc.cpp b/src/rose/rose_build_misc.cpp index 94290968..1df1b2d9 100644 --- a/src/rose/rose_build_misc.cpp +++ b/src/rose/rose_build_misc.cpp @@ -680,7 +680,6 @@ bool RoseDedupeAuxImpl::requiresDedupeSupport( const RoseGraph &g = tbi.g; - bool has_role = false; bool has_suffix = false; bool has_outfix = false; @@ -713,33 +712,40 @@ bool RoseDedupeAuxImpl::requiresDedupeSupport( } /* roles */ + + map lits; // Literal ID -> count of occurrences. + + const bool has_role = !roles.empty(); for (auto v : roles) { - if (has_role) { - return true; /* fear that multiple roles may trigger at same - offset */ + for (const auto &lit : g[v].literals) { + lits[lit]++; } - - has_role = true; - - if (g[v].literals.size() > 1) { - const auto &lits = g[v].literals; - DEBUG_PRINTF("vertex %zu lits: %s\n", g[v].idx, - as_string_list(lits).c_str()); - for (auto it = begin(lits); it != end(lits); ++it) { - const auto &lit1 = tbi.literals.right.at(*it); - for (auto jt = next(it); jt != end(lits); ++jt) { - const auto &lit2 = tbi.literals.right.at(*jt); - if (literalsCouldRace(lit1, lit2)) { - DEBUG_PRINTF("literals could race\n"); - return true; - } + if (g[v].eod_accept) { + // Literals plugged into this EOD accept must be taken into account + // as well. + for (auto u : inv_adjacent_vertices_range(v, g)) { + for (const auto &lit : g[u].literals) { + lits[lit]++; } } } + } - if (g[v].eod_accept) { - if (in_degree(v, g) > 1) { - /* may actually map to a number of terminal vertices */ + /* literals */ + + for (const auto &m : lits) { + if (m.second > 1) { + DEBUG_PRINTF("lit %u used by >1 reporting roles\n", m.first); + return true; + } + } + + for (auto it = begin(lits); it != end(lits); ++it) { + const auto &lit1 = tbi.literals.right.at(it->first); + for (auto jt = next(it); jt != end(lits); ++jt) { + const auto &lit2 = tbi.literals.right.at(jt->first); + if (literalsCouldRace(lit1, lit2)) { + DEBUG_PRINTF("literals could race\n"); return true; } }