Skip to content

Preserve source locations in optimization passes - #4747

Open
rw1nkler wants to merge 2 commits into
google:mainfrom
antmicro:101465-preserve-pos
Open

Preserve source locations in optimization passes#4747
rw1nkler wants to merge 2 commits into
google:mainfrom
antmicro:101465-preserve-pos

Conversation

@rw1nkler

Copy link
Copy Markdown
Contributor

This PR adds a MergeLocs helper that merges and deduplicates source locations across a node's operands.
It's used wherever passes synthesize replacement nodes, since those call sites often dropped the
original location, making it harder to trace optimized IR and generated Verilog back to the source DSLX.
VastNode::PreEmit is also updated to emit one comment per merged location, with line-count tracking
adjusted accordingly. Tests cover MergeLocs and each annotation strategy end to end.

@ericastor ericastor 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.

This is a great step forward, thank you!

Comment thread xls/ir/node_util.cc
for (const SourceLocation& location : operand->loc().locations) {
bool already_present =
absl::c_any_of(loc.locations, [&](const SourceLocation& existing) {
return existing <=> location == std::strong_ordering::equal;

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.

... is there a reason this isn't just absl::c_linear_search(loc.locations, existing)?

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