Skip to content

Conversation

@uenoku
Copy link
Member

@uenoku uenoku commented Sep 11, 2025

This PR adds several enhancement to LongestPath analysis which is critical for fast analysis on large design. Specifically when keepOnlyMaxDelayPaths is enabled the analysis keeps only critical path for each reg/output port.

  • Introduce LongestPathAnalysisOption with collectDebugInfo, lazyComputation, and keepOnlyMaxDelayPaths, replacing traceDebugPoints/incremental.

  • Add path filtering that deduplicates by fan-in and, when enabled, keeps only max-delay paths (with special handling for module inputs); apply in local and global scopes.

  • Rename and clarify APIs: getResults → computeGlobalPaths; getOrComputeResults/getResults → getOrComputePaths/getCachedPaths. getMaxDelay/getAverageMaxDelay now return FailureOr<int64_t> and support per-bit or all-bits queries.

  • Update IncrementalLongestPathAnalysis: defaults to lazyComputation=true and keepOnlyMaxDelayPaths=true; add options-based constructor.

  • Rework OperationAnalyzer to use its own analysis Context (lazy=true, keepOnlyMaxDelayPaths=false)

  • Extend C API: new constructor flags; add getPaths(value, bitPos, elaborate) and collection merge. Extend Python bindings: expose new constructor options; add get_paths and LongestPathCollection.merge; update integration test.

This enables faster on-demand timing analysis, optional memory/time savings via max-delay filtering, and more flexible C/Python entry points.

The PR is a bit too broad(sorry) but it doesn't change results for exiting API.

@uenoku uenoku force-pushed the dev/hidetou/longest-path-improve branch from cd5068f to 6e4f925 Compare September 11, 2025 02:23
… filtering.

Introduce LongestPathAnalysisOption with collectDebugInfo, lazyComputation, and keepOnlyMaxDelayPaths, replacing traceDebugPoints/incremental.

Add path filtering that deduplicates by fan-in and, when enabled, keeps only max-delay paths (with special handling for module inputs); apply in local and global scopes.

Rename and clarify APIs: getResults → computeGlobalPaths; getOrComputeResults/getResults → getOrComputePaths/getCachedPaths. getMaxDelay/getAverageMaxDelay now return FailureOr<int64_t> and support per-bit or all-bits queries.

Update IncrementalLongestPathAnalysis: defaults to lazyComputation=true and keepOnlyMaxDelayPaths=true; add options-based constructor.

Rework OperationAnalyzer to use its own analysis Context (lazy=true, keepOnlyMaxDelayPaths=false) for precise dependency discovery; rename getResults → analyzeOperation; cache by op signature.

Extend C API: new constructor flags; add getPaths(value, bitPos, elaborate) and collection merge. Extend Python bindings: expose new constructor options; add get_paths and LongestPathCollection.merge; update integration test.

Adjust DatapathToComb lowering to use analysis->getMaxDelay(...). Improve visitor concurrency: use getLocalVisitorMutable and wait only when running in parallel.

Breaking changes: C API constructor signature changed; LongestPathAnalysisWithTrace removed. Several C++ methods renamed and now return FailureOr. Python API constructor and new methods added; call sites may need updates.

This enables faster on-demand timing analysis, optional memory/time savings via max-delay filtering, and more flexible C/Python entry points.
@uenoku uenoku force-pushed the dev/hidetou/longest-path-improve branch from 6e4f925 to a738234 Compare September 11, 2025 02:33
Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

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

LGTM! I'm not intimately familiar with the internal logic of the analysis, but the changes look good from what I can tell. Really like all the comments on LongestPathAnalysisOption!

@uenoku uenoku merged commit 5b1840f into llvm:main Sep 12, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants