]> git.lizzy.rs Git - rust.git/commit
add back `noalias` to `&mut T` pointer parameters
authorDaniel Micay <danielmicay@gmail.com>
Sun, 4 May 2014 16:11:20 +0000 (12:11 -0400)
committerDaniel Micay <danielmicay@gmail.com>
Sun, 4 May 2014 16:41:14 +0000 (12:41 -0400)
commitf62c753b8f7879607204bcf77491cc81baf9c2dc
tree2753ef1ac6dd653655dd970f4ab36f58aab09012
parent1c9b77643c281a4f7055bc760ffba846744f2b4b
add back `noalias` to `&mut T` pointer parameters

This was removed because these could alias with `&const T` or `@mut T`
and those are now gone from the language. There are still aliasing
issues within local scopes, but this is correct for function parameters.

This also removes the no-op `noalias` marker on proc (not a pointer) and
leaves out the mention of #6750 because real type-based alias analysis
is not within the scope of best effort usage of the `noalias` attribute.

Test case:

    pub fn foo(x: &mut &mut u32) {
        **x = 5;
        **x = 5;
    }

Before:

    define void @_ZN3foo20h0ce94c9671b0150bdaa4v0.0E(i32** nocapture readonly) unnamed_addr #0 {
    entry-block:
      %1 = load i32** %0, align 8
      store i32 5, i32* %1, align 4
      %2 = load i32** %0, align 8
      store i32 5, i32* %2, align 4
      ret void
    }

After:

    define void @_ZN3foo20h0ce94c9671b0150bdaa4v0.0E(i32** noalias nocapture readonly) unnamed_addr #0 {
    entry-block:
      %1 = load i32** %0, align 8
      store i32 5, i32* %1, align 4
      ret void
    }

Closes #12436
src/librustc/middle/trans/base.rs