-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
221 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
tests/mir-opt/dataflow-const-prop/aggregate_copy.foo.DataflowConstProp.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
- // MIR for `foo` before DataflowConstProp | ||
+ // MIR for `foo` after DataflowConstProp | ||
|
||
fn foo() -> u32 { | ||
let mut _0: u32; | ||
let _1: (u32, u32); | ||
let mut _4: bool; | ||
let mut _5: u32; | ||
scope 1 { | ||
debug a => _1; | ||
let _2: (u32, u32); | ||
scope 2 { | ||
debug b => _2; | ||
let _3: u32; | ||
scope 3 { | ||
debug c => _3; | ||
} | ||
} | ||
} | ||
|
||
bb0: { | ||
StorageLive(_1); | ||
_1 = const Foo; | ||
StorageLive(_2); | ||
_2 = _1; | ||
StorageLive(_3); | ||
_3 = (_2.1: u32); | ||
StorageLive(_4); | ||
StorageLive(_5); | ||
_5 = _3; | ||
_4 = Ge(move _5, const 2_u32); | ||
switchInt(move _4) -> [0: bb2, otherwise: bb1]; | ||
} | ||
|
||
bb1: { | ||
StorageDead(_5); | ||
_0 = (_2.0: u32); | ||
goto -> bb3; | ||
} | ||
|
||
bb2: { | ||
StorageDead(_5); | ||
_0 = const 13_u32; | ||
goto -> bb3; | ||
} | ||
|
||
bb3: { | ||
StorageDead(_4); | ||
StorageDead(_3); | ||
StorageDead(_2); | ||
StorageDead(_1); | ||
return; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//! Verify that we manage to propagate the value of aggregate `a` even without directly mentioning | ||
//! the contained scalars. | ||
//@ test-mir-pass: DataflowConstProp | ||
|
||
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; | ||
// CHECK: [[b]] = [[a]]; | ||
// CHECK: [[c]] = ([[b]].1: u32); | ||
// CHECK: switchInt(move {{_.*}}) -> [0: bb2, otherwise: bb1]; | ||
|
||
// CHECK:bb1: { | ||
// CHECK: _0 = ([[b]].0: u32); | ||
// 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 |
55 changes: 55 additions & 0 deletions
55
tests/mir-opt/jump_threading.aggregate_copy.JumpThreading.panic-abort.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
- // MIR for `aggregate_copy` before JumpThreading | ||
+ // MIR for `aggregate_copy` after JumpThreading | ||
|
||
fn aggregate_copy() -> u32 { | ||
let mut _0: u32; | ||
let _1: (u32, u32); | ||
let mut _4: bool; | ||
let mut _5: u32; | ||
scope 1 { | ||
debug a => _1; | ||
let _2: (u32, u32); | ||
scope 2 { | ||
debug b => _2; | ||
let _3: u32; | ||
scope 3 { | ||
debug c => _3; | ||
} | ||
} | ||
} | ||
|
||
bb0: { | ||
StorageLive(_1); | ||
_1 = const aggregate_copy::Foo; | ||
StorageLive(_2); | ||
_2 = _1; | ||
StorageLive(_3); | ||
_3 = (_2.1: u32); | ||
StorageLive(_4); | ||
StorageLive(_5); | ||
_5 = _3; | ||
_4 = Eq(move _5, const 2_u32); | ||
switchInt(move _4) -> [0: bb2, otherwise: bb1]; | ||
} | ||
|
||
bb1: { | ||
StorageDead(_5); | ||
_0 = (_2.0: u32); | ||
goto -> bb3; | ||
} | ||
|
||
bb2: { | ||
StorageDead(_5); | ||
_0 = const 13_u32; | ||
goto -> bb3; | ||
} | ||
|
||
bb3: { | ||
StorageDead(_4); | ||
StorageDead(_3); | ||
StorageDead(_2); | ||
StorageDead(_1); | ||
return; | ||
} | ||
} | ||
|
55 changes: 55 additions & 0 deletions
55
tests/mir-opt/jump_threading.aggregate_copy.JumpThreading.panic-unwind.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
- // MIR for `aggregate_copy` before JumpThreading | ||
+ // MIR for `aggregate_copy` after JumpThreading | ||
|
||
fn aggregate_copy() -> u32 { | ||
let mut _0: u32; | ||
let _1: (u32, u32); | ||
let mut _4: bool; | ||
let mut _5: u32; | ||
scope 1 { | ||
debug a => _1; | ||
let _2: (u32, u32); | ||
scope 2 { | ||
debug b => _2; | ||
let _3: u32; | ||
scope 3 { | ||
debug c => _3; | ||
} | ||
} | ||
} | ||
|
||
bb0: { | ||
StorageLive(_1); | ||
_1 = const aggregate_copy::Foo; | ||
StorageLive(_2); | ||
_2 = _1; | ||
StorageLive(_3); | ||
_3 = (_2.1: u32); | ||
StorageLive(_4); | ||
StorageLive(_5); | ||
_5 = _3; | ||
_4 = Eq(move _5, const 2_u32); | ||
switchInt(move _4) -> [0: bb2, otherwise: bb1]; | ||
} | ||
|
||
bb1: { | ||
StorageDead(_5); | ||
_0 = (_2.0: u32); | ||
goto -> bb3; | ||
} | ||
|
||
bb2: { | ||
StorageDead(_5); | ||
_0 = const 13_u32; | ||
goto -> bb3; | ||
} | ||
|
||
bb3: { | ||
StorageDead(_4); | ||
StorageDead(_3); | ||
StorageDead(_2); | ||
StorageDead(_1); | ||
return; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters