[TVMSCRIPT][TIRx] Preserve parser source spans in IR - #20073
Merged
spectrometerHBH merged 1 commit intoJul 29, 2026
Conversation
Track nested frontend source ranges through IRBuilder and attach them to emitted TIRx statements and expression results. Normalize same-source nesting while retaining cross-source inline expansion history as SequentialSpan. Add exact coordinate, direct-call, inline expansion, tile primitive, and structural identity regression coverage.
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
spectrometerHBH
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and context
The TVMScript parser already tracks Python AST locations for diagnostics, but TIRx statements and expression results emitted through
IRBuilderdid not retain those locations. After parsing, a direct intrinsic call, an inlined helper body, or aTilePrimitiveCalltherefore could not be traced back to the source range that produced it.Inline expansion also needs more than a single flat location. The generated IR should retain both the caller location and the helper-definition location, while ordinary nested AST evaluation within one source should not accumulate redundant enclosing spans.
Changes
IRBuilder, with scoped push/pop support.SequentialSpan, ordered from the call site to the expanded definition.Source spans remain diagnostic metadata: functions parsed from different source locations keep the same structural hash and remain structurally equal.
Testing
TilePrimitiveCallnodes.SequentialSpancontaining caller and callee ranges.IRBuilder.with_source_spanbehavior.Focused result: 9 tests passed.