News for hackers. Stuff that matters.
Re:How copying an int made my code 11 times faster by aleden on Monday February 20, 2017 @01:26AM (#13684838)
> For example, Rust can't tell LLVM about its pointer aliasing guarantees

False.

http://llvm.org/docs/LangRef.html#noalias-and-alias-scope-me...

Re:How copying an int made my code 11 times faster by Rusky on Monday February 20, 2017 @01:48AM (#13684969)
From what I understand, LLVM still doesn't take as much advantage of that information as it could, given Rust input. It's too geared toward the C family of languages. (But as sibling comment says, the problem was partially the Rust compiler's fault.)
Re:How copying an int made my code 11 times faster by gens on Monday February 20, 2017 @09:27AM (#13687465)
C has a pointer aliasing keyword, "restrict".

Also: "Originally implemented for C and C++, the language-agnostic design of LLVM has since spawned a wide variety of front ends: languages with compilers that use LLVM include ActionScript, Ada, C#,[4][5][6] Common Lisp, Crystal, D, Delphi, Fortran, OpenGL Shading Language, Halide, Haskell, Java bytecode, Julia, Lua, Objective-C, Pony,[7] Python, R, Ruby, Rust, CUDA, Scala,[8] and Swift."

Most of these are nothing like C when it comes to pointers and memory layout.

Re:How copying an int made my code 11 times faster by Rusky on Monday February 20, 2017 @03:19PM (#13690527)
Again, from what I understand, `restrict` is not enough to convey everything Rust knows.

Further, those other languages may be nothing like C, but they're even less like Rust. So because of its heritage, even given the information Rust knows, LLVM simply doesn't have the optimization passes to take full advantage of it.

Re:How copying an int made my code 11 times faster by gens on Monday February 20, 2017 @04:41PM (#13691214)
Ok. Like what ?
Re:How copying an int made my code 11 times faster by algesten on Monday February 20, 2017 @01:37AM (#13684905)
The point was that Rust _can_ (more easily) tell LLVM now that MIR has landed.
Re:How copying an int made my code 11 times faster by jplatte on Monday February 20, 2017 @02:40AM (#13685252)
It's not only a MIR issue, it's also an issue of how many optimizations should be allowed when you also need to be able to make some assumptions about your data in unsafe blocks. For example if you simply added the obvious attributes everywhere, interior mutability (Cell, RefCell, UnsafeCell) would most certainly break. The exact rules around unsafe rules are still being discussed (see https://github.com/nikomatsakis/rust-memory-model), so until that is done some of these optimizations are very unlikely to be implemented because they can make a lot of unsafe code illegal.
Re:How copying an int made my code 11 times faster by dbaupp on Monday February 20, 2017 @03:01AM (#13685354)
Note that the compiler already adds "obvious" attributes to function calls, being careful to not emit them for things that contain an `UnsafeCell`. This is why that type exists, as the building block for interior mutability that the compiler understand and can optimise around.