2023-06-08 02:18:34 -05:00
|
|
|
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
|
2023-02-12 13:37:09 -06:00
|
|
|
// This attempts to modify `x.1` via a pointer derived from `addr_of_mut!(x.0)`.
|
|
|
|
// According to Miri, that is UB. However, T-opsem has not finalized that
|
|
|
|
// decision and as such we cannot rely on it in optimizations. Consequently,
|
|
|
|
// DataflowConstProp must treat the `addr_of_mut!(x.0)` as potentially being
|
|
|
|
// used to modify `x.1` - if it did not, then it might incorrectly assume that it
|
|
|
|
// can infer the value of `x.1` at the end of this function.
|
|
|
|
|
2024-04-20 06:19:34 -05:00
|
|
|
//@ test-mir-pass: DataflowConstProp
|
2022-11-12 07:57:14 -06:00
|
|
|
|
|
|
|
// EMIT_MIR sibling_ptr.main.DataflowConstProp.diff
|
2024-01-08 22:20:27 -06:00
|
|
|
|
2024-01-12 01:22:33 -06:00
|
|
|
// CHECK-LABEL: fn main(
|
2022-11-12 07:57:14 -06:00
|
|
|
fn main() {
|
2024-01-12 01:22:33 -06:00
|
|
|
// CHECK: debug x1 => [[x1:_.*]];
|
2024-01-08 22:20:27 -06:00
|
|
|
|
2022-11-12 07:57:14 -06:00
|
|
|
let mut x: (u8, u8) = (0, 0);
|
|
|
|
unsafe {
|
|
|
|
let p = std::ptr::addr_of_mut!(x.0);
|
|
|
|
*p.add(1) = 1;
|
|
|
|
}
|
2024-01-08 22:20:27 -06:00
|
|
|
|
2024-08-18 17:51:53 -05:00
|
|
|
// CHECK: [[x1]] = copy ({{_.*}}.1: u8);
|
2023-02-12 13:37:09 -06:00
|
|
|
let x1 = x.1; // should not be propagated
|
2022-11-12 07:57:14 -06:00
|
|
|
}
|