From 1d401a7991f4c0f133b7355acc400132da1aa4a0 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Wed, 19 Feb 2020 10:45:10 -0800 Subject: clean: ignore specify-s inside cells when determining whether to keep --- passes/opt/opt_clean.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'passes/opt') diff --git a/passes/opt/opt_clean.cc b/passes/opt/opt_clean.cc index 2f69b3d4c..f5bb40050 100644 --- a/passes/opt/opt_clean.cc +++ b/passes/opt/opt_clean.cc @@ -51,20 +51,26 @@ struct keep_cache_t if (cache.count(module)) return cache.at(module); - cache[module] = true; - if (!module->get_bool_attribute(ID::keep)) { - bool found_keep = false; + bool found_keep = false; + if (module->get_bool_attribute(ID::keep)) + found_keep = true; + else for (auto cell : module->cells()) - if (query(cell)) found_keep = true; - cache[module] = found_keep; - } + if (query(cell, true /* ignore_specify */)) { + found_keep = true; + break; + } + cache[module] = found_keep; - return cache[module]; + return found_keep; } - bool query(Cell *cell) + bool query(Cell *cell, bool ignore_specify = false) { - if (cell->type.in(ID($memwr), ID($meminit), ID($assert), ID($assume), ID($live), ID($fair), ID($cover), ID($specify2), ID($specify3), ID($specrule))) + if (cell->type.in(ID($memwr), ID($meminit), ID($assert), ID($assume), ID($live), ID($fair), ID($cover))) + return true; + + if (!ignore_specify && cell->type.in(ID($specify2), ID($specify3), ID($specrule))) return true; if (cell->has_keep_attr()) -- cgit v1.2.3