Skip to content

odb: more refactoring of tmg_conn - #11579

Merged
maliberty merged 11 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:odb-refactor-order-wires
Oct 3, 2026
Merged

maliberty merged 11 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:odb-refactor-order-wires

Conversation

@AcKoucher

@AcKoucher AcKoucher commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

General Organization

  • Make all tmg_conn method definitions live in tmg_conn.cpp.
  • Only write the definition in .h if it is a oneliner.
  • Leave public only the truly public methods.

Structural Changes

  • Decouple the target net setter from the top-level API. We now have tmg_conn::setNet.
  • Make static void function tmg_getDriveTerm a method of tmg_conn.
  • Remove all tmg_conn methods that just forwarded graph APIs. They were somewhat hiding that the DFS is referring to the ConnectionGraph.
  • Split tmg_conn::loadNet into:
tmg_conn::clear()
tmg_conn::loadWire()
tmg_conn::loadTerminals()
  • tmg_conn::clear() now resets the entire state i.e., all member variables and it's called at the end of the top-level function.

Removals

  • Remove unused checker tmg_conn::checkConnOrdered. Not only it wasn't being used but the name oversold what it did. It basically just checked if a wire path's first point was a terminal. If we want a proper checker for normalized connectivity, we can write it ourselves. This method was defined alone in tmg_conn_w.cpp which I removed.
  • TestOrderWires no longer tries to exercise the post-ordering path that was supposed to test the method cited above.
  • tmg_conn::isConnected was also dead.
  • Redundant net state setters in top-level function.

Type of Change

  • Refactoring

Impact

None.

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass.
  • My code follows the repository's formatting guidelines.
  • I have signed my commits (DCO).

Related Issues

None.

Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
    1) Make the structure of the top-level comment cleaner.
    2) Remove check method that was never reached.

Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
@AcKoucher AcKoucher self-assigned this Sep 29, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request refactors the tmg_conn class by removing tmg_conn_w.cpp and restructuring how nets are analyzed. Specifically, it separates net assignment (setNet) from analysis (analyzeNet), moves several graph-related traversal methods directly into ConnectionGraph, and cleans up unused methods. The review feedback highlights a critical issue where clear() does not reset net-specific state variables (like connected_ and has_special_wires_), leading to potential state leakage across reused instances. Additionally, several defensive null checks are recommended for connection_graph_ to prevent potential null pointer dereferences in checkVisited(), getDisconnectedStart(), and copyWireIdToVisitedShorts().

Comment thread src/odb/src/db/tmg_conn.cpp
Comment thread src/odb/src/db/tmg_conn.cpp
Comment thread src/odb/src/db/tmg_conn.cpp
Comment thread src/odb/src/db/tmg_conn.cpp
Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
@AcKoucher
AcKoucher marked this pull request as ready for review September 30, 2026 15:58
@AcKoucher
AcKoucher requested a review from a team as a code owner September 30, 2026 15:58
@maliberty

Copy link
Copy Markdown
Member

Codex:

  • src/odb/src/db/tmg_conn.cpp:39: bug: When loadWire() produces no points, analyzeNet() now calls clear() without resetting the net’s disconnected flag. Previously this path set setDisconnected(false). dbWire::destroy() clears the ordered flag but leaves the disconnected flag intact, so ordering a formerly disconnected net after its wire is removed leaves it incorrectly marked disconnected. Please restore the empty wire state update and add a regression test.

Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
@AcKoucher

Copy link
Copy Markdown
Contributor Author

Fixed. As discussed, the bug was in the wire destroyer.

Comment thread src/odb/src/db/dbWire.cpp Outdated
net->global_wire_ = 0;
} else {
net->wire_ = 0;
net->flags_.disconnected = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are you killing off disconnected? If so you should remove the APIs and storage too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't realized that it was dead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@maliberty Killing off disconnected would imply more dead code in orderWires that I'll have to also remove here and the PR would get overloaded. I reverted the last commit and did as Codex suggested. I'll remove the flag in a subsequent hopefully removal-only PR.

This reverts commit bf6b494.

Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
@maliberty
maliberty merged commit 9e76d99 into The-OpenROAD-Project:master Oct 3, 2026
20 checks passed
@maliberty
maliberty deleted the odb-refactor-order-wires branch October 3, 2026 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants