jinhongyii opened a new pull request, #20073: URL: https://github.com/apache/tvm/pull/20073
## Motivation and context The TVMScript parser already tracks Python AST locations for diagnostics, but TIRx statements and expression results emitted through `IRBuilder` did not retain those locations. After parsing, a direct intrinsic call, an inlined helper body, or a `TilePrimitiveCall` therefore 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 - Add an active source-span stack to `IRBuilder`, with scoped push/pop support. - Make the parser activate the current AST source range while visiting statements and evaluating expressions. - Attach the active span to emitted TIRx statements and to expression results that do not already carry an explicit span. - Normalize nested spans from the same source to the innermost relevant range. - Preserve cross-source inline expansion history as a `SequentialSpan`, ordered from the call site to the expanded definition. - Reuse the same source-coordinate calculation for diagnostics and IR spans so their line and column conventions remain consistent. Source spans remain diagnostic metadata: functions parsed from different source locations keep the same structural hash and remain structurally equal. ## Testing - Verify exact parser source coordinates against diagnostic coordinates. - Verify spans on direct intrinsic calls and `TilePrimitiveCall` nodes. - Verify that inline expansion produces a `SequentialSpan` containing caller and callee ranges. - Verify direct `IRBuilder.with_source_span` behavior. - Verify that source spans do not affect structural identity. - Run changed-files pre-commit checks, including clang-format. Focused result: 9 tests passed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
