ystests: fix write_smt2_write_smt2_cyclic_dependency_fail
authorEddie Hung <eddie@fpgeh.com>
Fri, 28 Feb 2020 20:33:55 +0000 (12:33 -0800)
committerEddie Hung <eddie@fpgeh.com>
Fri, 28 Feb 2020 20:33:55 +0000 (12:33 -0800)
passes/opt/opt_clean.cc

index f5bb40050ab4a29529b5a3d22ccc8d98ea0c1752..cac265a52d966f5a38c7a1d58b5dda5ccff5d55a 100644 (file)
@@ -51,18 +51,18 @@ struct keep_cache_t
                if (cache.count(module))
                        return cache.at(module);
 
-               bool found_keep = false;
-               if (module->get_bool_attribute(ID::keep))
-                       found_keep = true;
-               else
-                       for (auto cell : module->cells())
-                               if (query(cell, true /* ignore_specify */)) {
-                                       found_keep = true;
-                                       break;
-                               }
-               cache[module] = found_keep;
+               cache[module] = true;
+               if (!module->get_bool_attribute(ID::keep)) {
+                   bool found_keep = false;
+                   for (auto cell : module->cells())
+                       if (query(cell, true /* ignore_specify */)) {
+                           found_keep = true;
+                           break;
+                       }
+                   cache[module] = found_keep;
+               }
 
-               return found_keep;
+               return cache[module];
        }
 
        bool query(Cell *cell, bool ignore_specify = false)