about summary refs log tree commit diff
path: root/src/rustllvm/ExecutionEngineWrapper.cpp
diff options
context:
space:
mode:
authorBjörn Steinbrink <bsteinbr@gmail.com>2015-05-15 15:20:42 +0200
committerBjörn Steinbrink <bsteinbr@gmail.com>2015-05-15 15:30:22 +0200
commiteeeb2cc0dffc016582f020c0a9e6d9f9fc751397 (patch)
tree0218029e9937bf8ad03f8a8071ae2b6dcb1c6d2f /src/rustllvm/ExecutionEngineWrapper.cpp
parent579e31929feff51dcaf8d444648eff8de735f91a (diff)
downloadrust-eeeb2cc0dffc016582f020c0a9e6d9f9fc751397.tar.gz
rust-eeeb2cc0dffc016582f020c0a9e6d9f9fc751397.zip
Allow for better optimizations of iterators for zero-sized types
Using regular pointer arithmetic to iterate collections of zero-sized types
doesn't work, because we'd get the same pointer all the time. Our
current solution is to convert the pointer to an integer, add an offset
and then convert back, but this inhibits certain optimizations.

What we should do instead is to convert the pointer to one that points
to an i8*, and then use a LLVM GEP instructions without the inbounds
flag to perform the pointer arithmetic. This allows to generate pointers
that point outside allocated objects without causing UB (as long as you
don't dereference them), and it wraps around using two's complement,
i.e. it behaves exactly like the wrapping_* operations we're currently
using, with the added benefit of LLVM being able to better optimize the
resulting IR.
Diffstat (limited to 'src/rustllvm/ExecutionEngineWrapper.cpp')
0 files changed, 0 insertions, 0 deletions