Fix memory leak when one of multiple DFF cells is removed in opt_rmdff
authorBogdan Vukobratovic <bogdan.vukobratovic@gmail.com>
Thu, 27 Jun 2019 20:02:12 +0000 (22:02 +0200)
committerBogdan Vukobratovic <bogdan.vukobratovic@gmail.com>
Thu, 27 Jun 2019 20:02:12 +0000 (22:02 +0200)
When there are multiple DFFs and one of them is removed, its reference lingers
inside bit2driver dict. While invoking handle_dff() function for other DFFs,
this broken reference is used isnside sat_import_cell() function.

passes/opt/opt_rmdff.cc

index 5fc28ae9289f3414d9b23092a2da63ae1bdcf760..17e0d7cd44175fe91a4ab84bd0cb2556011dce6b 100644 (file)
@@ -530,6 +530,11 @@ delete_dff:
        log("Removing %s (%s) from module %s.\n", log_id(dff), log_id(dff->type), log_id(mod));
        remove_init_attr(dff->getPort("\\Q"));
        mod->remove(dff);
+
+       for (auto &entry : bit2driver)
+               if (entry.second == dff)
+                       bit2driver.erase(entry.first);
+
        return true;
 }