Repository navigation
Add debug symbols that point into the stmt outputs (simplified alternative to #9611) - #9712
Draft
mcourteaux wants to merge 3 commits into
Draft
mcourteaux wants to merge 3 commits into
mcourteaux wants to merge 3 commits into
Conversation
CodeGen_C printed a Let or LetStmt by substituting a variable named after the id of the value into the body, which rebuilds the body once for every let around it. It now remembers the id in a scope, where the Variable looks it up, so the IR that is printed is the IR that was passed in. A let of a handle and a For loop bind their own name, which hides a let of the same name around them, as the substitution did. The output is the same, except where an expression is simplified while it is printed (e.g. the lowering of lerp): the simplifier orders the operands of commutative operators by the names of variables, which are no longer the ids. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011FRemhS639vq75urwV44oe
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## mcourteaux/stmt-html-from-irprinter-alt #9712 +/- ##
===========================================================================
+ Coverage 73.50% 73.62% +0.11%
===========================================================================
Files 266 266
Lines 82513 83009 +496
Branches 20460 20589 +129
===========================================================================
+ Hits 60652 61113 +461
- Misses 15391 15399 +8
- Partials 6470 6497 +27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mcourteaux
force-pushed
the
mcourteaux/llvm-debug-symbols-alt
branch
from
November 22, 2026 18:52
b7c8f13 to
c745296
Compare
The html output is written by HTMLStmtPrinter, a subclass of IRPrinter, through new hooks: begin_style()/end_style() for styled text, and begin_node()/end_node() around each Expr and Stmt. It shows the IR exactly as the stmt output prints it, which replaces the separate html printer. IRPrinter is simplified along the way: the colors of the styles come from a table, Modules and LoweredFuncs are printed by member functions that operator<< uses, the binary operators share a helper, and chained ifs are printed recursively. Colored output ends some styles by resetting only the color where it reset all attributes; plain output is unchanged. The variables of the loops over GPU threads (.thread_id_x, .thread_id_y and .thread_id_z) are red, green and blue, in colored output and in the html. The assembly is linked to the loops and produce/consume blocks by the names of their basic blocks. It is written as plain text into a <script type='text/plain'>, which the page splits into lines and renders as they come into view. The cost model is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011FRemhS639vq75urwV44oe
The debug_symbols and debug_symbols_conceptual target features emit debug info (DWARF, or CodeView on Windows) that maps the generated code to the lines of the stmt or conceptual_stmt output, for ahead-of-time and JIT compiled code. IRPrinter can record where it prints each IR node (print_with_source_map), which is what the debug info points into. Lowering always copies the IR nodes that the stmt uses in more than one place, so that each is printed in one place only. The html outputs link the IR to its assembly through this debug info, instead of through the names of basic blocks: by line, and within a line by the IR node each instruction was generated for. - Hovering IR or assembly shows what it is linked to. Double-clicking keeps that shown and goes there; double-clicking it again, or Escape, lets go of it. A click on a variable still highlights it everywhere. - Anywhere on a line links the line. On an operator, a keyword or a name, the node is linked too: that expression with all that is nested in it. - The line is marked faintly and the node strongly, in yellow while hovered and orange once selected. With rainbow parentheses on, the selected assembly is colored by the node each instruction was generated for. The assembly of the selected node itself has a bar in front of it. - The backgrounds that mark lines are chosen per color scheme, by calculation: far enough from the background of the pane to be seen, in the color on which the text colors keep the most contrast. Parallel and GPU loops are shown by a line along them, with a faint shade. - The toolbar says what is linked, and has an option to scroll smoothly when going there, which is on by default. See doc/DebugSymbols.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011FRemhS639vq75urwV44oe
mcourteaux
force-pushed
the
mcourteaux/llvm-debug-symbols-alt
branch
from
November 22, 2026 19:37
c745296 to
be10264
Compare
This branch has not been deployed
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.
Stacked on #9711, which is stacked on #9710. Draft: this is a simplified alternative to #9611, for comparing the two side by side.
What this does
debug_symbolsanddebug_symbols_conceptualtarget features emit debug info (DWARF, or CodeView on Windows) that maps the generated code to the lines of thestmtorconceptual_stmtoutput, for ahead-of-time and JIT compiled code.IRPrintercan record where it prints each IR node (print_with_source_map), which is what the debug info points into.In the page
See
doc/DebugSymbols.md.What is different from #9611
for_html_outputs. Lowering always copies the IR nodes that the stmt uses in more than one place, so that each is printed in one place only. The parameter is gone fromPipeline::compile_to_module,AbstractGenerator::build_module,lower()and the Python binding.IRPrinter. OneIRPrinterRecordholds the locations of the nodes and where the functions start. The location of a node holds that of the node it is printed within, instead of a stack of them, and nothing is recorded when no record is set.StmtSourceMaploses the fields nothing reads.codegen().Performance
Lowering time of the generators in
apps/, withtools/benchmark_apps_generators.py(-e stmt, wall clock, mean of 3 runs, host target), main against this PR. Two of the 72 generators fail to build or run on both, and are left out.Screenshots
Taken with headless Chrome, of a small tiled and vectorized pipeline.
An operator double-clicked: the
<=of a bounds check. The expression under it has a line around it, the assembly of all of it is marked strongly, and that of the rest of the line faintly. The bar is in front of the instructions of the<=itself:The same with rainbow parentheses on: each instruction has the color of the operator it was generated for, which the IR shows in that color.
In the classic dark color scheme:
The conceptual stmt, with a store selected in a parallel loop and the line before it hovered:
Tests
correctness_debug_symbolschecks that the html links assembly to lines of IR that exist, and to more IR nodes than lines. It andcorrectness_stmt_to_htmlpass. The other correctness tests passed before the page got its node-level links and its new interaction; I have not rerun them since, as lowering and code generation did not change.🤖 Generated with Claude Code
https://claude.ai/code/session_011FRemhS639vq75urwV44oe