about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorUlrik Sverdrup <bluss@users.noreply.github.com>2016-09-08 23:48:08 +0200
committerUlrik Sverdrup <bluss@users.noreply.github.com>2016-09-09 02:38:47 +0200
commit765700ba7a3743b9af5cb12092ea1293dbe07068 (patch)
treeb66fd5073367107972f6f1479676d92d201e714e /src/rustllvm/RustWrapper.cpp
parenta5dbf8a0f8843c5466c3866cc2a288c0ef7051d2 (diff)
downloadrust-765700ba7a3743b9af5cb12092ea1293dbe07068.tar.gz
rust-765700ba7a3743b9af5cb12092ea1293dbe07068.zip
Work around pointer aliasing issue in Vec::extend_from_slice, extend_with_element
Due to missing noalias annotations for &mut T in general (issue #31681),
in larger programs extend_from_slice and extend_with_element may both
compile very poorly. What is observed is that the .set_len() calls are
not lifted out of the loop, even for `Vec<u8>`.

Use a local length variable for the Vec length instead, and use a scope
guard to write this value back to self.len when the scope ends or on
panic. Then the alias analysis is easy.

This affects extend_from_slice, extend_with_element, the vec![x; n]
macro, Write impls for Vec<u8>, BufWriter, etc (but may / may not
have triggered since inlining can be enough for the compiler to get it right).
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions