Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/odb/src/db/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ static void cutRow(dbBlock* block,
const int seg_end
= makeSiteLoc(blockage.first, site_width, true, start_origin_x);
segments.emplace_back(start_origin_x, seg_end);
start_origin_x
= makeSiteLoc(blockage.second, site_width, false, start_origin_x);
start_origin_x = std::max(
start_origin_x,
makeSiteLoc(blockage.second, site_width, false, start_origin_x));
Comment on lines +104 to +106
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While this change correctly updates start_origin_x for overlapping blockages, it doesn't prevent the creation of invalid segments. If a blockage overlaps with a previous one, start_origin_x could be greater than blockage.first in the next iteration. This would cause seg_end (calculated on line 102) to be less than start_origin_x, leading to an invalid segment being created on line 103.

A check should be added before line 103 to ensure seg_end > start_origin_x, for example:

if (seg_end > start_origin_x) {
  segments.emplace_back(start_origin_x, seg_end);
}

A more robust long-term solution would be to merge the overlapping row_blockage_xs intervals after sorting. This would simplify the loop and make the logic clearer.

References
  1. When analyzing code within a loop, consider the entire loop structure. Operations at the beginning of the loop or pre-processing (like merging intervals) can affect the logic within the loop body, potentially simplifying it or making certain checks redundant.

}
// Last segment: from after the last blockage to the row's right edge
segments.emplace_back(start_origin_x, row_bb.xMax());
Expand Down
Loading