@@ -295,28 +295,47 @@ static void sync_clustered_netlist_to_routing(void){
295
295
/* 1. Remove all nets, pins and ports from the clustered netlist.
296
296
* If the clock net is not routed, don't remove entries for the clock net
297
297
* otherwise we won't have data to rebuild them. */
298
+ std::vector<ClusterNetId> nets_to_remove;
299
+ std::vector<ClusterPinId> pins_to_remove;
300
+ std::vector<ClusterPortId> ports_to_remove;
301
+
298
302
for (auto net_id: clb_netlist.nets ()){
299
303
auto atom_net_id = atom_lookup.atom_net (net_id);
300
304
if (!clock_net_is_routed && route_ctx.is_clock_net [atom_net_id])
301
305
continue ;
302
306
303
- clb_netlist.remove_net (net_id);
304
- atom_lookup.remove_clb_net (net_id);
307
+ nets_to_remove.push_back (net_id);
305
308
}
306
309
for (auto pin_id: clb_netlist.pins ()){
307
310
ClusterNetId clb_net_id = clb_netlist.pin_net (pin_id);
308
311
auto atom_net_id = atom_lookup.atom_net (clb_net_id);
309
312
if (!clock_net_is_routed && atom_net_id && route_ctx.is_clock_net [atom_net_id])
310
313
continue ;
311
- clb_netlist.remove_pin (pin_id);
314
+
315
+ pins_to_remove.push_back (pin_id);
312
316
}
313
317
for (auto port_id: clb_netlist.ports ()){
314
318
ClusterNetId clb_net_id = clb_netlist.port_net (port_id, 0 );
315
319
auto atom_net_id = atom_lookup.atom_net (clb_net_id);
316
320
if (!clock_net_is_routed && atom_net_id && route_ctx.is_clock_net [atom_net_id])
317
321
continue ;
322
+
323
+ ports_to_remove.push_back (port_id);
324
+ }
325
+
326
+ /* ClusteredNetlist's iterators rely on internal lookups, so we mark for removal
327
+ * while iterating, then remove in bulk */
328
+ for (auto net_id: nets_to_remove){
329
+ clb_netlist.remove_net (net_id);
330
+ atom_lookup.remove_clb_net (net_id);
331
+ }
332
+ for (auto pin_id: pins_to_remove){
333
+ clb_netlist.remove_pin (pin_id);
334
+ }
335
+ for (auto port_id: ports_to_remove){
318
336
clb_netlist.remove_port (port_id);
319
337
}
338
+
320
339
/* 2. Reset all internal lookups for netlist */
321
340
auto remapped = clb_netlist.compress ();
322
341
rebuild_atom_nets_lookup (remapped);
0 commit comments