From 0a163b553543397c0e6693c6f50e674443f57a55 Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Tue, 28 Mar 2017 11:26:40 +1100 Subject: [PATCH] rose: only use live reports for dedupe assignment --- src/rose/rose_build_misc.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/rose/rose_build_misc.cpp b/src/rose/rose_build_misc.cpp index 5173596f..c9403896 100644 --- a/src/rose/rose_build_misc.cpp +++ b/src/rose/rose_build_misc.cpp @@ -590,6 +590,8 @@ private: map> suffix_map; map> outfix_map; map> puff_map; + + unordered_set live_reports; //!< all live internal reports. }; unique_ptr RoseBuildImpl::generateDedupeAux() const { @@ -606,6 +608,8 @@ RoseDedupeAuxImpl::RoseDedupeAuxImpl(const RoseBuildImpl &tbi_in) set suffixes; for (auto v : vertices_range(g)) { + insert(&live_reports, g[v].reports); + // Literals in the small block table are "shadow" copies of literals in // the other tables that do not run in the same runtime invocation. // Dedupe key assignment will be taken care of by the real literals. @@ -629,12 +633,14 @@ RoseDedupeAuxImpl::RoseDedupeAuxImpl(const RoseBuildImpl &tbi_in) for (const auto &suffix : suffixes) { for (const auto &report_id : all_reports(suffix)) { suffix_map[report_id].insert(suffix); + live_reports.insert(report_id); } } for (const auto &outfix : tbi.outfixes) { for (const auto &report_id : all_reports(outfix)) { outfix_map[report_id].insert(&outfix); + live_reports.insert(report_id); } } @@ -642,11 +648,21 @@ RoseDedupeAuxImpl::RoseDedupeAuxImpl(const RoseBuildImpl &tbi_in) auto *mpv = tbi.mpv_outfix->mpv(); for (const auto &puff : mpv->puffettes) { puff_map[puff.report].insert(&puff); + live_reports.insert(puff.report); } for (const auto &puff : mpv->triggered_puffettes) { puff_map[puff.report].insert(&puff); + live_reports.insert(puff.report); } } + + // Collect live reports from boundary reports. + insert(&live_reports, tbi.boundary.report_at_0); + insert(&live_reports, tbi.boundary.report_at_0_eod); + insert(&live_reports, tbi.boundary.report_at_eod); + + DEBUG_PRINTF("%zu of %zu reports are live\n", live_reports.size(), + tbi.rm.numReports()); } static @@ -716,11 +732,20 @@ bool RoseDedupeAuxImpl::hasSafeMultiReports( } bool RoseDedupeAuxImpl::requiresDedupeSupport( - const ue2::flat_set &reports) const { + const flat_set &reports_in) const { /* TODO: this could be expanded to check for offset or character constraints */ - DEBUG_PRINTF("reports: %s\n", as_string_list(reports).c_str()); + // We don't want to consider dead reports (tracked by ReportManager but no + // longer used) for the purposes of assigning dupe keys. + flat_set reports; + for (auto id : reports_in) { + if (contains(live_reports, id)) { + reports.insert(id); + } + } + + DEBUG_PRINTF("live reports: %s\n", as_string_list(reports).c_str()); const RoseGraph &g = tbi.g;