summaryrefslogtreecommitdiffstats
path: root/tests/codegen/noalias-flag.rs
blob: a9ec61e286d0da46d05171e01013177b61616396 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// compile-flags: -O -Zmutable-noalias=no

#![crate_type = "lib"]

// `-Zmutable-noalias=no` should disable noalias on mut refs...

// CHECK-LABEL: @test_mut_ref(
// CHECK-NOT: noalias
// CHECK-SAME: %x
#[no_mangle]
pub fn test_mut_ref(x: &mut i32) -> &mut i32 {
    x
}

// ...but not on shared refs

// CHECK-LABEL: @test_ref(
// CHECK-SAME: noalias
// CHECK-SAME: %x
#[no_mangle]
pub fn test_ref(x: &i32) -> &i32 {
    x
}