[all-commits] [llvm/llvm-project] d8c143: [mlir][python] Add location source composition to ...
Alisson Azzolini via All-commits
all-commits at lists.llvm.org
Sun Apr 19 01:08:17 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d8c14330dcc17610f634b45d1730b7a6e46d91cd
https://github.com/llvm/llvm-project/commit/d8c14330dcc17610f634b45d1730b7a6e46d91cd
Author: Alisson Azzolini <37222419+aazzolini at users.noreply.github.com>
Date: 2026-04-19 (Sun, 19 Apr 2026)
Changed paths:
M mlir/include/mlir/Bindings/Python/Globals.h
M mlir/lib/Bindings/Python/Globals.cpp
M mlir/lib/Bindings/Python/IRCore.cpp
M mlir/python/mlir/ir.py
M mlir/test/python/ir/auto_location.py
Log Message:
-----------
[mlir][python] Add location source composition to loc_tracebacks() (#192310)
## Summary
Add two new kwargs to `loc_tracebacks()` controlling how the three
location sources (explicit `loc=`, traceback, `Location.current`)
compose:
- **`on_explicit`**: `OnExplicitAction.USE_EXPLICIT` (default) |
`OnExplicitAction.USE_TRACEBACK` — what to do when explicit `loc=` is
passed
- **`current_loc`**: `CurrentLocAction.FALLBACK` (default) |
`CurrentLocAction.NAMELOC_WRAP` — how to compose `Location.current`
NameLoc scopes on top
Both enums are exposed to Python via `nb::enum_<>` bindings, following
the `PassDisplayMode` pattern in `Pass.cpp`.
The two flags are orthogonal and only take effect when
`loc_tracebacks()` is active.
## Use cases
1. **DSL profiling attribution**:
`loc_tracebacks(current_loc=CurrentLocAction.NAMELOC_WRAP,
on_explicit=OnExplicitAction.USE_TRACEBACK)` — push NameLoc scopes for
profiling and have them survive traceback generation
2. **Override explicit locs with tracebacks**:
`loc_tracebacks(on_explicit=OnExplicitAction.USE_TRACEBACK)` — get full
Python stack traces without removing every `loc=` argument
## Test plan
- [x] All 102 existing Python binding tests pass (5 unsupported
unchanged)
- [x] 6 new tests covering: nameloc_wrap, on_explicit default,
on_explicit=use_traceback, DSL profiling combo, orthogonality
(use_explicit + nameloc_wrap), tracebacks-disabled fallback
Co-authored by Claude Code ;)
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply at anthropic.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list