From b89dc992e5b87f5300c5dc4e5505373d450612f7 Mon Sep 17 00:00:00 2001 From: Catherine Date: Wed, 5 Aug 2026 16:52:14 +0000 Subject: [PATCH] Revert "hierarchy: fix cache usage by caching false too" This reverts commit ae14b5e6a85c5f66f6a5b7efd2257e3388473c68. --- passes/hierarchy/hierarchy.cc | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/passes/hierarchy/hierarchy.cc b/passes/hierarchy/hierarchy.cc index dceda1624..08b14dca0 100644 --- a/passes/hierarchy/hierarchy.cc +++ b/passes/hierarchy/hierarchy.cc @@ -684,30 +684,24 @@ void hierarchy_clean(RTLIL::Design *design, RTLIL::Module *top, bool purge_lib) bool set_keep_print(std::map &cache, RTLIL::Module *mod) { - auto it = cache.find(mod); - if (it != cache.end()) - return it->second; - cache[mod] = false; - for (auto c : mod->cells()) { - RTLIL::Module *m = mod->design->module(c->type); - if ((m != nullptr && set_keep_print(cache, m)) || c->type == ID($print)) - return cache[mod] = true; - } - return false; + if (cache.count(mod) == 0) + for (auto c : mod->cells()) { + RTLIL::Module *m = mod->design->module(c->type); + if ((m != nullptr && set_keep_print(cache, m)) || c->type == ID($print)) + return cache[mod] = true; + } + return cache[mod]; } bool set_keep_assert(std::map &cache, RTLIL::Module *mod) { - auto it = cache.find(mod); - if (it != cache.end()) - return it->second; - cache[mod] = false; - for (auto c : mod->cells()) { - RTLIL::Module *m = mod->design->module(c->type); - if ((m != nullptr && set_keep_assert(cache, m)) || c->type.in(ID($check), ID($assert), ID($assume), ID($live), ID($fair), ID($cover))) - return cache[mod] = true; - } - return false; + if (cache.count(mod) == 0) + for (auto c : mod->cells()) { + RTLIL::Module *m = mod->design->module(c->type); + if ((m != nullptr && set_keep_assert(cache, m)) || c->type.in(ID($check), ID($assert), ID($assume), ID($live), ID($fair), ID($cover))) + return cache[mod] = true; + } + return cache[mod]; } int find_top_mod_score(Design *design, Module *module, dict &db)