jameysharp opened PR #8581 from jameysharp:stop-consuming-allocs to bytecodealliance:main:
The
nextandnext_writablemethods onAllocationConsumerare identity functions now, so replace each call with its argument and then clean up the resulting mess.Most of this commit was generated with these commands:
git grep -lF allocs.next cranelift/codegen/src/isa/ | xargs sed -i 's/allocs\.next\(_writable\)\?//'cargo fix -p cranelift-codegen --features all-arch --allow-dirty --allow-stagedgit diff --name-only HEAD | xargs sed -i '/let \([^ ]*\) = \1;/d'cargo fmtI used sed to delete
allocs.nextbut left the following parentheses alone (since matching balanced parentheses is not a regular language). Then I usedcargo fixto remove those parentheses and also add underscores to newly-unusedAllocationConsumerarguments. Next I used sed again to delete trivial assignments likelet x = x, leaving more complicated cases as future work to clean up, and finallycargo fmtto delete blank lines and braces that are no longer necessary.Last, I deleted the newly-unused definitions of
nextandnext_writablethemselves.
jameysharp requested fitzgen for a review on PR #8581.
jameysharp requested wasmtime-compiler-reviewers for a review on PR #8581.
jameysharp updated PR #8581.
lpereira created PR review comment:
Minor, but could these assignments be removed too?
lpereira submitted PR review.
lpereira submitted PR review.
lpereira created PR review comment:
Is any of these functions that take an
AllocationConsumerto pretty print actually using that parameter, or just some of them?
jameysharp submitted PR review.
jameysharp submitted PR review.
jameysharp created PR review comment:
Yes, there are several kinds of assignments that should still be removed, but they're more difficult to do mechanically so I wanted to save them for a separate PR.
let _ri = ri;orlet _ = u.vreg;has the side effect of suppressing warnings that the value on the right-hand side is not used. This is not an idiomatic way to do it, but simply deleting the assignment will introduce warnings, which breaks CI unless we do something about them.let tmp = *tmp;dereferences a borrow of thetmpfield and re-binds the nametmpto a copy of the field. Rust has syntax for doing this directly in the pattern match that bound the nametmpin the first place, which I'd prefer to use.let ri_hi = ri.hi;orlet r = rn;could be deleted as long as all the uses of the left-hand side are replaced by the right-hand side.The changes in this PR are only the ones I could script with
sedand the other tools I was using, and I want to stop at this point so this review is pretty mechanical too.
jameysharp created PR review comment:
Right, none of the
AllocationConsumerarguments are actually necessary, after #8524 landed. I'm deleting all the newly dead code in several steps to make review easier, so this PR deletes all remaining calls toAllocationConsumermethods.There are still some functions where the Rust compiler thinks the
AllocationConsumerargument is used, but that's because it's passed to other functions that don't actually need it either. I intend to delete all those arguments, and all mentions of theAllocationConsumertype, in another PR after this one.
abrown submitted PR review:
Thanks for pushing this forward!
jameysharp merged PR #8581.
Last updated: Dec 13 2025 at 19:03 UTC