]> git.lizzy.rs Git - rust.git/commit
Avoid unnecessary copies of arguments that are simple bindings
authorBjörn Steinbrink <bsteinbr@gmail.com>
Wed, 11 Oct 2017 18:49:36 +0000 (20:49 +0200)
committerBjörn Steinbrink <bsteinbr@gmail.com>
Thu, 26 Oct 2017 10:54:34 +0000 (12:54 +0200)
commit0473a4f1d8f5e10c1ec97b1f7b4918308e1c1090
tree8e0605f6915f14b6ecbc420c04572fdb05a13bec
parent56dc171a2f2dc2373b1930f71140a354fa84b982
Avoid unnecessary copies of arguments that are simple bindings

Initially MIR differentiated between arguments and locals, which
introduced a need to add extra copies assigning the argument to a
local, even for simple bindings. This differentiation no longer exists,
but we're still creating those copies, bloating the MIR and LLVM IR we
emit.

Additionally, the current approach means that we create debug info for
both the incoming argument (marking it as an argument), and then
immediately shadow it a local that goes by the same name. This can be
confusing when using e.g. "info args" in gdb, or when e.g. a debugger
with a GUI displays the function arguments separately from the local
variables, especially when the binding is mutable, because the argument
doesn't change, while the local variable does.
20 files changed:
src/librustc_mir/build/expr/into.rs
src/librustc_mir/build/mod.rs
src/librustc_trans/builder.rs
src/librustc_trans/mir/analyze.rs
src/librustc_trans/mir/mod.rs
src/test/codegen/adjustments.rs
src/test/codegen/align-struct.rs
src/test/codegen/fastcall-inreg.rs
src/test/codegen/function-arguments.rs
src/test/codegen/move-val-init.rs
src/test/codegen/refs.rs
src/test/codegen/stores.rs
src/test/mir-opt/copy_propagation.rs
src/test/mir-opt/deaggregator_test.rs
src/test/mir-opt/deaggregator_test_enum.rs
src/test/mir-opt/deaggregator_test_enum_2.rs
src/test/mir-opt/deaggregator_test_multiple.rs
src/test/mir-opt/validate_1.rs
src/test/mir-opt/validate_4.rs
src/test/mir-opt/validate_5.rs