Could the compiler automatically re-use Box
allocations as an optimization?
#93707
Labels
A-box
Area: Our favorite opsem complication
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
A-mir-opt
Area: MIR optimizations
C-optimization
Category: An issue highlighting optimization opportunities or PRs implementing such
I-slow
Issue: Problems and improvements with respect to performance of generated code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code: https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=f7612dfa44bc15ef44bd7d759dce1b87
Given that
i32
andf32
have the same layout (at least on my target) I was hoping that the compiler would be able to -- as an optimization -- avoid the dealloc+alloc dance here.But it looks like, right now at least, it doesn't re-use it even when the optimizer puts the
__rust_dealloc
+__rust_alloc
right next to each other with matching layout arguments. Obviously this wouldn't be guaranteed, but hopefully in a bunch of simple cases it could just work.cc #93653, about APIs to do this manually
The text was updated successfully, but these errors were encountered: