jameysharp opened PR #8581 from jameysharp:stop-consuming-allocs
to bytecodealliance:main
:
The
next
andnext_writable
methods onAllocationConsumer
are 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-staged
git diff --name-only HEAD | xargs sed -i '/let \([^ ]*\) = \1;/d'
cargo fmt
I used sed to delete
allocs.next
but left the following parentheses alone (since matching balanced parentheses is not a regular language). Then I usedcargo fix
to remove those parentheses and also add underscores to newly-unusedAllocationConsumer
arguments. Next I used sed again to delete trivial assignments likelet x = x
, leaving more complicated cases as future work to clean up, and finallycargo fmt
to delete blank lines and braces that are no longer necessary.Last, I deleted the newly-unused definitions of
next
andnext_writable
themselves.
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
AllocationConsumer
to 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 thetmp
field and re-binds the nametmp
to a copy of the field. Rust has syntax for doing this directly in the pattern match that bound the nametmp
in 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
sed
and 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
AllocationConsumer
arguments 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 toAllocationConsumer
methods.There are still some functions where the Rust compiler thinks the
AllocationConsumer
argument 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 theAllocationConsumer
type, in another PR after this one.
abrown submitted PR review:
Thanks for pushing this forward!
jameysharp merged PR #8581.
Last updated: Dec 23 2024 at 12:05 UTC