rust/tests/mir-opt/dataflow-const-prop/aggregate_copy.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.2 KiB
Rust
Raw Normal View History

2024-06-28 08:01:27 -05:00
//! Verify that we manage to propagate the value of aggregate `a` even without directly mentioning
//! the contained scalars.
//@ test-mir-pass: DataflowConstProp
//@ compile-flags: -Zdump-mir-exclude-alloc-bytes
2024-06-28 08:01:27 -05:00
const Foo: (u32, u32) = (5, 3);
fn foo() -> u32 {
// CHECK-LABEL: fn foo(
// CHECK: debug a => [[a:_.*]];
// CHECK: debug b => [[b:_.*]];
// CHECK: debug c => [[c:_.*]];
// CHECK:bb0: {
// CHECK: [[a]] = const Foo;
2024-06-28 08:02:08 -05:00
// CHECK: [[b]] = const (5_u32, 3_u32);
// CHECK: [[c]] = const 3_u32;
// CHECK: {{_.*}} = const 3_u32;
// CHECK: {{_.*}} = const true;
// CHECK: switchInt(const true) -> [0: bb2, otherwise: bb1];
2024-06-28 08:01:27 -05:00
// CHECK:bb1: {
2024-06-28 08:02:08 -05:00
// CHECK: _0 = const 5_u32;
2024-06-28 08:01:27 -05:00
// CHECK: goto -> bb3;
// CHECK:bb2: {
// CHECK: _0 = const 13_u32;
// CHECK: goto -> bb3;
let a = Foo;
// This copies the struct in `a`. We want to ensure that we do track the contents of `a`
// because we need to read `b` later.
let b = a;
let c = b.1;
if c >= 2 { b.0 } else { 13 }
}
fn main() {
// CHECK-LABEL: fn main(
foo();
}
// EMIT_MIR aggregate_copy.foo.DataflowConstProp.diff