Repository navigation
[VM] Index bytecode debug database source maps by function ordinal - #25278
hamidelmaazouz wants to merge 1 commit into
Conversation
`DebugDatabaseBuilder::addFunctionSourceMap` placed each function source map at the `ordinal` attribute of the function and fell back to 0 when the attribute was absent. Since ordinals moved to `OrdinalAnalysis` the bytecode target no longer sets that attribute, so every function wrote slot 0 and the debug database kept only the map of the last function encoded. The runtime looks function names and locations up in that table by internal ordinal, which made `--trace_execution` and backtraces report the wrong function for ordinal 0 and a bare ordinal for the others. The fallback dates from the introduction of the debug database in 2e711d4. At the time the bytecode pipeline ran `OrdinalAllocationPass` and every function carried the attribute by serialisation, so the default never applied. The move to `OrdinalAnalysis` in aa776b3 (iree-org#23115) dropped that pass from the bytecode pipeline and replaced the other ordinal reads of the target, which dereference the attribute and would have asserted. This one substituted 0 and went unnoticed, since no test covered the contents of the debug database. The encoder already holds the `OrdinalAnalysis`, so it now passes the ordinal to the builder, and the builder no longer reads the attribute. A new lit test, `debug_database.mlir`, checks that each function of a module gets its own entry in `debug_database.functions`. Fixes iree-org#25277 Signed-off-by: Hamid El Maazouz <[email protected]>
|
Hello @hamidelmaazouz 👋 Thank you for submitting a Pull Request to IREE! It looks like this is your first one. We have one ask, and you can also find some general tips below. Action required: acknowledge IREE project policiesIREE is a Linux Foundation project. All participants are expected to follow the LF Projects Code of Conduct. All contributions to IREE must follow our IREE AI Tool Use Policy. In particular:
We kindly ask you to reply to this message and confirm that you understand and accept the cited policies, particularly the AI Tool Use Policy. General guidanceOur general Contributing guide contains information and links to detailed guides on code quality, testing, commit summaries and our CI system. A common point for new PRs: if a DCO signing check fails for you, check out the section on Developer Certificate of Origin. If you have any questions, feel free to leave a comment here, or ask away on IREE Discord. Thank you, |
I understand and accept the cited policies, particularly the AI Tool Use Policy. |
DebugDatabaseBuilder::addFunctionSourceMapplaced each function source map at theordinalattribute of the function and fell back to 0 when the attribute was absent. Since ordinals moved toOrdinalAnalysisthe bytecode target no longer sets that attribute, so every function wrote slot 0 and the debug database kept only the map of the last function encoded. The runtime looks function names and locations up in that table by internal ordinal, which made--trace_executionand backtraces report the wrong function for ordinal 0 and a bare ordinal for the others.The fallback dates from the introduction of the debug database in 2e711d4. At the time the bytecode pipeline ran
OrdinalAllocationPassand every function carried the attribute by serialisation, so the default never applied. The move toOrdinalAnalysisin aa776b3 (#23115) dropped that pass from the bytecode pipeline and replaced the other ordinal reads of the target, which dereference the attribute and would have asserted. This one substituted 0 and went unnoticed, since no test covered the contents of the debug database.The encoder already holds the
OrdinalAnalysis, so it now passes the ordinal to the builder, and the builder no longer reads the attribute. A new lit test,debug_database.mlir, checks that each function of a module gets its own entry indebug_database.functions.The
ordinalattributes remain on the VM ops, and only the C target still sets them throughOrdinalAllocationPass. Moving the C target toOrdinalAnalysisand dropping the attributes would rule out this kind of stale read altogether. That touches EmitC, so it seems better kept to a separate change, and I am happy to open an issue for it if that sounds useful.Thanks for taking a look!
Fixes #25277