3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-05-09 16:55:49 +00:00

autoname: Check for potential overflow

This commit is contained in:
Krystine Sherwin 2025-05-01 11:47:44 +12:00
parent 22c72a5af4
commit 414a1bf278
No known key found for this signature in database

View file

@ -122,6 +122,15 @@ struct AutonamePass : public Pass {
if (bit.wire != nullptr)
wire_score[bit.wire]++;
for (auto &it : wire_score) {
// (10000*score + new_name.size())*2 must be less than INT32_MAX
// using 24000 allows for a name 2000 characters long
if (it.second > INT32_MAX/24000)
// We can't guarantee an earlier module hasn't already been processed, so use log_error
log_error("Fanout of %s too high (%d bits), unable to continue.\n", it.first->name.c_str(), it.second);
}
int count = 0, iter = 0;
while (1) {
iter++;