mirror of https://github.com/YosysHQ/yosys.git
bugpoint: Don't remove modules or cells while iterating over them.
Reported by @ZirconiumX.
This commit is contained in:
parent
16a3048308
commit
cd82afb740
|
@ -133,6 +133,7 @@ struct BugpointPass : public Pass {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if (modules)
|
if (modules)
|
||||||
{
|
{
|
||||||
|
Module *removed_module = nullptr;
|
||||||
for (auto module : design_copy->modules())
|
for (auto module : design_copy->modules())
|
||||||
{
|
{
|
||||||
if (module->get_blackbox_attribute())
|
if (module->get_blackbox_attribute())
|
||||||
|
@ -141,10 +142,14 @@ struct BugpointPass : public Pass {
|
||||||
if (index++ == seed)
|
if (index++ == seed)
|
||||||
{
|
{
|
||||||
log("Trying to remove module %s.\n", module->name.c_str());
|
log("Trying to remove module %s.\n", module->name.c_str());
|
||||||
design_copy->remove(module);
|
removed_module = module;
|
||||||
return design_copy;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (removed_module) {
|
||||||
|
design_copy->remove(removed_module);
|
||||||
|
return design_copy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ports)
|
if (ports)
|
||||||
{
|
{
|
||||||
|
@ -178,15 +183,20 @@ struct BugpointPass : public Pass {
|
||||||
if (mod->get_blackbox_attribute())
|
if (mod->get_blackbox_attribute())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Cell *removed_cell = nullptr;
|
||||||
for (auto cell : mod->cells())
|
for (auto cell : mod->cells())
|
||||||
{
|
{
|
||||||
if (index++ == seed)
|
if (index++ == seed)
|
||||||
{
|
{
|
||||||
log("Trying to remove cell %s.%s.\n", mod->name.c_str(), cell->name.c_str());
|
log("Trying to remove cell %s.%s.\n", mod->name.c_str(), cell->name.c_str());
|
||||||
mod->remove(cell);
|
removed_cell = cell;
|
||||||
return design_copy;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (removed_cell) {
|
||||||
|
mod->remove(removed_cell);
|
||||||
|
return design_copy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (connections)
|
if (connections)
|
||||||
|
|
Loading…
Reference in New Issue