rust/tests/mir-opt/const_prop/address_of_pair.rs

33 lines
879 B
Rust
Raw Normal View History

//@ test-mir-pass: GVN
//@ compile-flags: -Zdump-mir-exclude-alloc-bytes
2023-04-28 11:51:40 -05:00
2023-09-20 16:43:33 -05:00
// EMIT_MIR address_of_pair.fn0.GVN.diff
2023-04-28 11:51:40 -05:00
pub fn fn0() -> bool {
2023-12-02 14:16:25 -06:00
// CHECK-LABEL: fn fn0(
// CHECK: debug pair => [[pair:_.*]];
// CHECK: debug ptr => [[ptr:_.*]];
// CHECK: debug ret => [[ret:_.*]];
// CHECK: (*[[ptr]]) = const true;
// CHECK-NOT: = const false;
// CHECK-NOT: = const true;
2024-08-18 17:51:53 -05:00
// CHECK: [[tmp:_.*]] = copy ([[pair]].1: bool);
2023-12-02 14:16:25 -06:00
// CHECK-NOT: = const false;
// CHECK-NOT: = const true;
// CHECK: [[ret]] = Not(move [[tmp]]);
// CHECK-NOT: = const false;
// CHECK-NOT: = const true;
2024-08-18 17:51:53 -05:00
// CHECK: _0 = copy [[ret]];
2023-04-28 11:51:40 -05:00
let mut pair = (1, false);
let ptr = core::ptr::addr_of_mut!(pair.1);
pair = (1, false);
unsafe {
*ptr = true;
}
let ret = !pair.1;
return ret;
}
pub fn main() {
println!("{}", fn0());
}