Commit afd381f
Declare effects on air.dma_memcpy_nd; migrate FoldExecute to mightHaveEffect (#1575)
* Declare memory effects on air.dma_memcpy_nd
Read on src, Write on dst — mirrors memref.copy's MemReadAt/MemWriteAt
declarations. Without this the op was opaque to side-effect queries:
ExecuteOp::getEffects had to fall back to conservative R+W+Free for
any execute body that contained a DMA (the catch-all sawUnknownOp
branch); FoldExecute's hand-rolled Write check silently skipped DMA
ops; LocalAliasAnalysis::getModRef returned MayMod/MayRef for them.
air.channel.put / air.channel.get are intentionally left out —
modelling them correctly requires a side effect on the channel symbol
(not just the local memref), since put has no Write to memory but is
still observable. That needs a custom Resource and is filed as a
followup.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Migrate FoldExecute side-effect check to upstream helper
Replace the hand-rolled walk over body.without_terminator() with
mlir::mightHaveEffect<MemoryEffects::Write>(op). ExecuteOp::getEffects
already mirrors body effects up; the upstream helper additionally
returns true when the body contains an unknown-effect op, which the
old walk silently skipped (latent unsafety: any effect-bearing op
without MemoryEffectOpInterface declared was treated as no-Write).
execute_3's expectation changes accordingly: its body contains a
dma_memcpy_nd that now reports a Write on dst, so the execute is
conservatively kept. Folding it is only safe if the dst is provably
body-local; that needs escape analysis and is left as a followup.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Use upstream hasEffect in checkOpOperandReadOrWrite
Replace the explicit air.dma_memcpy_nd branch with a generic
mlir::hasEffect<MemoryEffects::{Read,Write}> query. Now that the DMA
op declares MemReadAt<src>/MemWriteAt<dst>, the upstream helper
returns the same answer the dialect-specific switch did, and any
future op that declares effects is picked up automatically.
The air.channel.put/get and linalg branches stay because channels
do not yet declare effects (separate followup) and the linalg path
uses the DPS interface, not memory effects.
Two callers (AIRDependencyScheduleOpt.cpp:1126/1146,
Dependency.cpp:2928) benefit transparently — the return-code contract
is unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 5c2418f commit afd381f
4 files changed
Lines changed: 26 additions & 29 deletions
File tree
- mlir
- include/air/Dialect/AIR
- lib
- Dialect/AIR/IR
- Util
- test/Dialect/AIR
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | | - | |
| 469 | + | |
| 470 | + | |
470 | 471 | | |
471 | 472 | | |
472 | 473 | | |
473 | | - | |
| 474 | + | |
| 475 | + | |
474 | 476 | | |
475 | 477 | | |
476 | 478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2103 | 2103 | | |
2104 | 2104 | | |
2105 | 2105 | | |
2106 | | - | |
2107 | | - | |
2108 | | - | |
2109 | | - | |
2110 | | - | |
2111 | | - | |
2112 | | - | |
2113 | | - | |
2114 | | - | |
2115 | | - | |
2116 | | - | |
2117 | | - | |
2118 | | - | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
2119 | 2110 | | |
2120 | 2111 | | |
2121 | 2112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
824 | 824 | | |
825 | 825 | | |
826 | 826 | | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
837 | 836 | | |
838 | | - | |
839 | | - | |
| 837 | + | |
| 838 | + | |
840 | 839 | | |
841 | 840 | | |
842 | 841 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
294 | 297 | | |
295 | 298 | | |
296 | | - | |
297 | | - | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
298 | 303 | | |
299 | 304 | | |
300 | 305 | | |
| |||
0 commit comments