diff options
author | Marcelina KoĆcielnicka <mwk@0x04.net> | 2020-04-21 19:56:28 +0200 |
---|---|---|
committer | Marcelina KoĆcielnicka <mwk@0x04.net> | 2020-04-22 00:09:01 +0200 |
commit | cd82afb740fc2f1d9bead89fd2683be989acad37 (patch) | |
tree | 3af4de3762183abf8858f0fdd21ff441bca5e429 /passes/cmds | |
parent | 16a3048308f20e4761f491e81a8d4c0b80f5a149 (diff) | |
download | yosys-cd82afb740fc2f1d9bead89fd2683be989acad37.tar.gz yosys-cd82afb740fc2f1d9bead89fd2683be989acad37.tar.bz2 yosys-cd82afb740fc2f1d9bead89fd2683be989acad37.zip |
bugpoint: Don't remove modules or cells while iterating over them.
Reported by @ZirconiumX.
Diffstat (limited to 'passes/cmds')
-rw-r--r-- | passes/cmds/bugpoint.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/passes/cmds/bugpoint.cc b/passes/cmds/bugpoint.cc index ad6a07fa0..a75927393 100644 --- a/passes/cmds/bugpoint.cc +++ b/passes/cmds/bugpoint.cc @@ -133,6 +133,7 @@ struct BugpointPass : public Pass { int index = 0; if (modules) { + Module *removed_module = nullptr; for (auto module : design_copy->modules()) { if (module->get_blackbox_attribute()) @@ -141,10 +142,14 @@ struct BugpointPass : public Pass { if (index++ == seed) { log("Trying to remove module %s.\n", module->name.c_str()); - design_copy->remove(module); - return design_copy; + removed_module = module; + break; } } + if (removed_module) { + design_copy->remove(removed_module); + return design_copy; + } } if (ports) { @@ -178,15 +183,20 @@ struct BugpointPass : public Pass { if (mod->get_blackbox_attribute()) continue; + Cell *removed_cell = nullptr; for (auto cell : mod->cells()) { if (index++ == seed) { log("Trying to remove cell %s.%s.\n", mod->name.c_str(), cell->name.c_str()); - mod->remove(cell); - return design_copy; + removed_cell = cell; + break; } } + if (removed_cell) { + mod->remove(removed_cell); + return design_copy; + } } } if (connections) |