tqchen opened a new pull request, #18874:
URL: https://github.com/apache/tvm/pull/18874
## Summary
Rename `LetStmtNode`/`LetStmt` to `BindNode`/`Bind` and remove the `body`
field.
The variable defined by `Bind(var, value)` is now visible in all subsequent
statements within the same enclosing scope, rather than being scoped to a
nested body.
This flattens deeply nested let-chains into sequential `SeqStmt([Bind(...),
Bind(...), ...])`,
making the IR easier to read, transform, and analyze.
## Key Changes
- **New `BindNode`**: `{var, value}` — no body field. Variable scope is the
enclosing
statement's body (For, IfThenElse, AllocBuffer, etc.)
- **ScopeStack pattern**: Passes that need scope-aware cleanup (ConvertSSA,
CSE,
tir_visitor_with_path) use `ScopeStack` instead of manual save/restore or
RAII wrappers
- **All passes migrated**: 89 files updated across codegen backends, TIR
transforms,
S-TIR transforms, analyses, TVMScript printer/parser/ir_builder
- **LetStmt aliases removed**: No backward-compat aliases remain
## Design
Since TIR enforces SSA (each var bound exactly once), most passes simply
insert into
a global `var_map_` on encountering `Bind` — no scope cleanup needed. For
the few passes
that do need scoped cleanup, `ScopeStack` provides clean RAII-based scope
management:
body-carrying statements push a new scope, `Bind` adds to the current scope,
and cleanup
happens automatically when the scope exits.
## Test plan
- [x] C++ cpptest: 235 passed
- [x] all-platform-minimal-test: 75 passed
- [x] tir-base: 269 passed
- [x] tir-analysis: 24 passed
- [x] test_tir_transform_convert_ssa: 13 passed
- [x] test_tir_transform_common_subexpr_elim: 8 passed
- [x] test_tir_transform_lower_tvm_builtin: 8 passed
- [x] test_tir_transform_simplify: 76 passed
- [x] test_tvmscript_roundtrip: 143 passed
- [x] test_target_codegen_llvm: 1 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]