legacy codegen: a call whose tensor result nothing takes leaks the buffer
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
Research direction
Read the AST code generator and compare its handling of unused call results with drop_temps_here in src/hir/flatten.rs; the issue also points to the checker’s Drop handling. Start by reproducing with the discard.vx example using vxc discard.vx --legacy-codegen --action emit-mlir. Done when both dynamic and fixed-shape tensor results that are unused are freed in the emitted MLIR.
Written by the indexing model from the issue text.
Description
With --legacy-codegen, a call whose tensor result nothing takes does not free the result's buffer.
fn make(n : i32) -> Tensor<f32, [?]> {
let t = Tensor<f32>([n]);
return t;
}
fn main() -> i32 {
make(4);
return 0;
}
vxc discard.vx --legacy-codegen --action emit-mlir shows the call in main and no vx.drop or memref.dealloc of its result:
%0 = call @make(%c4_i32) : (i32) -> memref<?xf32>
The default code generator drops the result after the statement: the flat path drops each fresh tensor of a statement that nothing took (drop_temps_here in src/hir/flatten.rs). The AST code generator has no such step, and the checker writes a Drop only for a named owner.
The same holds for a result of fixed shape over 4096 bytes. After #3496, its caller makes the result's buffer on the heap, and the AST code generator does not free it when nothing takes the result. Before that change, the buffer was on the stack.
Found while working on #3496.
- Dominant language
- Rust
- Stars
- 35
- Forks
- 5
- Avg merge
- 12h 26m
- Merged PRs (30d)
- 799
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vx-lang/Vx
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
bug testing
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
`pub struct` gives "Expected 'fn' after 'pub'": the error should say that a struct needs no `pub`Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
bug devex
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
longbridge/gpui-kit#4031 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
neuralmagic/crucible#465 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
compiler P3
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
HerringtonDarkholme/hd-lang#2162 ·
Maintainers usually reply within 1 day
-
embedded SQL: pin correlated-guard behaviour when a closed variable is reassigned inside a branchOpenpriority: low
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
jonathanong/no-mistakes#3627 ·
Maintainers usually reply within 1 day