diff options
author | Clifford Wolf <clifford@clifford.at> | 2013-05-23 13:19:28 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2013-05-23 13:19:28 +0200 |
commit | f674150f1c5200f76e0f23739b06fde6a143bb6d (patch) | |
tree | 7dcf5371c2d6c68ea9a2525d385af4482f0f6873 /passes/opt | |
parent | cbe423a1fe67a9f7154d56d968fb059a4f92f2ad (diff) | |
download | yosys-f674150f1c5200f76e0f23739b06fde6a143bb6d.tar.gz yosys-f674150f1c5200f76e0f23739b06fde6a143bb6d.tar.bz2 yosys-f674150f1c5200f76e0f23739b06fde6a143bb6d.zip |
Fixed memory corruption bug in opt_rmunused
Diffstat (limited to 'passes/opt')
-rw-r--r-- | passes/opt/opt_rmunused.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/passes/opt/opt_rmunused.cc b/passes/opt/opt_rmunused.cc index 6cec9b294..3d6d755af 100644 --- a/passes/opt/opt_rmunused.cc +++ b/passes/opt/opt_rmunused.cc @@ -172,7 +172,6 @@ static void rmunused_module_signals(RTLIL::Module *module) RTLIL::SigSpec s1 = RTLIL::SigSpec(wire), s2 = s1; assign_map.apply(s2); if (!used_signals.check_any(s2) && wire->port_id == 0) { - log(" removing unused non-port wire %s.\n", wire->name.c_str()); del_wires.push_back(wire); } else { s1.expand(); @@ -187,6 +186,8 @@ static void rmunused_module_signals(RTLIL::Module *module) if (new_conn.first.width > 0) { new_conn.first.optimize(); new_conn.second.optimize(); + used_signals.add(new_conn.first); + used_signals.add(new_conn.second); module->connections.push_back(new_conn); } } @@ -216,13 +217,19 @@ static void rmunused_module_signals(RTLIL::Module *module) } } - for (auto wire : del_wires) { - module->wires.erase(wire->name); - delete wire; - } + int del_wires_count = 0; + for (auto wire : del_wires) + if (!used_signals.check_any(RTLIL::SigSpec(wire))) { + if (check_public_name(wire->name)) { + log(" removing unused non-port wire %s.\n", wire->name.c_str()); + del_wires_count++; + } + module->wires.erase(wire->name); + delete wire; + } - if (del_wires.size() > 0) - log(" removed %zd unused temporary wires.\n", del_wires.size()); + if (del_wires_count > 0) + log(" removed %d unused temporary wires.\n", del_wires_count); } static void rmunused_module(RTLIL::Module *module) |