rust/src/libstd
bors dbc57584bd auto merge of #6724 : thestinger/rust/swap_fast, r=thestinger
Passing higher alignment values gives the optimization passes more freedom since it can copy in larger chunks. This change results in rustc outputting the same post-optimization IR as clang for swaps and most copies excluding the lack of information about padding.

Code snippet:

```rust
#[inline(never)]
fn swap<T>(x: &mut T, y: &mut T) {
    util::swap(x, y);
}
```

Original IR (for `int`):

```llvm
define internal fastcc void @_ZN9swap_283417_a71830ca3ed2d65d3_00E(i64*, i64*) #1 {
static_allocas:
  %2 = icmp eq i64* %0, %1
  br i1 %2, label %_ZN4util9swap_283717_a71830ca3ed2d65d3_00E.exit, label %3

; <label>:3                                       ; preds = %static_allocas
  %4 = load i64* %0, align 1
  %5 = load i64* %1, align 1
  store i64 %5, i64* %0, align 1
  store i64 %4, i64* %1, align 1
  br label %_ZN4util9swap_283717_a71830ca3ed2d65d3_00E.exit

_ZN4util9swap_283717_a71830ca3ed2d65d3_00E.exit:  ; preds = %3, %static_allocas
  ret void
}
```

After #6710:

```llvm
define internal fastcc void @_ZN9swap_283017_a71830ca3ed2d65d3_00E(i64* nocapture, i64* nocapture) #1 {
static_allocas:
  %2 = load i64* %0, align 1
  %3 = load i64* %1, align 1
  store i64 %3, i64* %0, align 1
  store i64 %2, i64* %1, align 1
  ret void
}
```

After this change:

```llvm
define internal fastcc void @_ZN9swap_283017_a71830ca3ed2d65d3_00E(i64* nocapture, i64* nocapture) #1 {
static_allocas:
  %2 = load i64* %0, align 8
  %3 = load i64* %1, align 8
  store i64 %3, i64* %0, align 8
  store i64 %2, i64* %1, align 8
  ret void
}
```

Another example:

```rust
#[inline(never)]
fn set<T>(x: &mut T, y: T) {
    *x = y;
}
```

Before, with `(int, int)` (align 1):

```llvm
define internal fastcc void @_ZN8set_282517_8fa972e3f9e451983_00E({ i64, i64 }* nocapture, { i64, i64 }* nocapture) #1 {
static_allocas:
  %2 = bitcast { i64, i64 }* %1 to i8*
  %3 = bitcast { i64, i64 }* %0 to i8*
  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* %2, i64 16, i32 1, i1 false)
  ret void
}
```

After, with `(int, int)` (align 8):

```llvm
define internal fastcc void @_ZN8set_282617_8fa972e3f9e451983_00E({ i64, i64 }* nocapture, { i64, i64 }* nocapture) #1 {
static_allocas:
  %2 = bitcast { i64, i64 }* %1 to i8*
  %3 = bitcast { i64, i64 }* %0 to i8*
  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* %2, i64 16, i32 8, i1 false)
  ret void
}
```
2013-05-27 15:56:08 -07:00
..
num Get rid of no-longer-needed #[doc(hidden)] attributes. 2013-05-27 13:29:48 -04:00
rand libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
rt cleanup warnings from libstd 2013-05-23 17:48:16 -07:00
str cleanup warnings from libstd 2013-05-23 17:48:16 -07:00
task Get rid of no-longer-needed #[doc(hidden)] attributes. 2013-05-27 13:29:48 -04:00
unstable add memset32/memset64 2013-05-26 10:26:03 -04:00
at_vec.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
bool.rs Fix docs to use std instead of core. 2013-05-27 08:19:57 -05:00
cast.rs fix casts on 32-bit 2013-05-27 18:14:00 -04:00
cell.rs use deriving for DeepClone 2013-05-24 01:16:15 -04:00
char.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
cleanup.rs make arm register definition consistent with rt 2013-05-24 10:42:09 +08:00
clone.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
cmp.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
comm.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
condition.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
container.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
core.rc Remove usage of the #[merge] hack with int modules 2013-05-24 15:31:34 -05:00
either.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
from_str.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
gc.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
hash.rs cleanup warnings from libstd 2013-05-23 17:48:16 -07:00
hashmap.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
io.rs Remove unnecessary allocations flagged by lint 2013-05-28 03:14:44 +09:00
iter.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
iterator.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
kinds.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
libc.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
local_data.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
logging.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
macros.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
managed.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
nil.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
old_iter.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
ops.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
option.rs use deriving for DeepClone 2013-05-24 01:16:15 -04:00
os.rs Refactor core::run in order to address many of the issues 2013-05-27 13:50:33 +01:00
owned.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
path.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
pipes.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
prelude.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
ptr.rs fix casts on 32-bit 2013-05-27 18:14:00 -04:00
rand.rs cleanup warnings from libstd 2013-05-23 17:48:16 -07:00
reflect.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
repr.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
result.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
run.rs Rename unwrap_input/unwrap_output as suggested by 2013-05-27 13:50:33 +01:00
stackwalk.rs Get rid of no-longer-needed #[doc(hidden)] attributes. 2013-05-27 13:29:48 -04:00
str.rs cleanup warnings from libstd 2013-05-23 17:48:16 -07:00
sys.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
to_bytes.rs core: remove iter_bytes helper functions 2013-05-23 17:48:16 -07:00
to_str.rs Remove unnecessary allocations flagged by lint 2013-05-28 03:14:44 +09:00
trie.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
tuple.rs libstd: Rename libcore to libstd and libstd to libextra; update makefiles. 2013-05-22 21:57:05 -07:00
unicode.rs Get rid of no-longer-needed #[doc(hidden)] attributes. 2013-05-27 13:29:48 -04:00
util.rs optimize util::swap, &mut pointers never alias 2013-05-23 23:00:16 -04:00
vec.rs cleanup warnings from libstd 2013-05-23 17:48:16 -07:00