fix double-free when fo goes to same cell

This commit is contained in:
Stefan Holst committed 2023-07-10 20:08:48 +09:00
1 parent ec5626b8ca
commit d8f605a47a
1 file changed
+6 -6
+6 -6
View File
@@ -279,7 +279,7 @@ class SimOps:
# allocate memory for the rest of the circuit # allocate memory for the rest of the circuit
for op_start, op_stop in zip(self.level_starts, self.level_stops): for op_start, op_stop in zip(self.level_starts, self.level_stops):
free_list = [] free_set = set()
for op in self.ops[op_start:op_stop]: for op in self.ops[op_start:op_stop]:
# if we fork-strip, always take the stems # if we fork-strip, always take the stems
i0_idx = stems[op[2]] if stems[op[2]] >= 0 else op[2] i0_idx = stems[op[2]] if stems[op[2]] >= 0 else op[2]
@@ -290,15 +290,15 @@ class SimOps:
ref_count[i1_idx] -= 1 ref_count[i1_idx] -= 1
ref_count[i2_idx] -= 1 ref_count[i2_idx] -= 1
ref_count[i3_idx] -= 1 ref_count[i3_idx] -= 1
if ref_count[i0_idx] <= 0: free_list.append(self.c_locs[i0_idx]) if ref_count[i0_idx] <= 0: free_set.add(self.c_locs[i0_idx])
if ref_count[i1_idx] <= 0: free_list.append(self.c_locs[i1_idx]) if ref_count[i1_idx] <= 0: free_set.add(self.c_locs[i1_idx])
if ref_count[i2_idx] <= 0: free_list.append(self.c_locs[i2_idx]) if ref_count[i2_idx] <= 0: free_set.add(self.c_locs[i2_idx])
if ref_count[i3_idx] <= 0: free_list.append(self.c_locs[i3_idx]) if ref_count[i3_idx] <= 0: free_set.add(self.c_locs[i3_idx])
o_idx = op[1] o_idx = op[1]
cap = max(c_caps_min, c_caps[o_idx]) cap = max(c_caps_min, c_caps[o_idx])
self.c_locs[o_idx], self.c_caps[o_idx] = h.alloc(cap), cap self.c_locs[o_idx], self.c_caps[o_idx] = h.alloc(cap), cap
if c_reuse: if c_reuse:
for loc in free_list: for loc in free_set:
h.free(loc) h.free(loc)
# copy memory location and capacity from stems to fanout lines # copy memory location and capacity from stems to fanout lines