blob: 1cd5e542d4f22abd89ee480f111065a9ced728a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
//
// Tests for single-use-variable elimination
//
// Check forward movement of values
#[test="simple_fwd_exp"]
fn simple_fwd(a: i32) -> (i32,)
{
let v: i32;
bb0: {
ASSIGN v = a;
ASSIGN retval = (v,);
} RETURN;
}
fn simple_fwd_exp(a: i32) -> (i32,)
{
bb0: {
ASSIGN retval = (a,);
} RETURN;
}
// Reverse (upwards) movement
#[test="simple_rev_exp"]
fn simple_rev(a: i32) -> (i32,)
{
let v: (i32,);
bb0: {
ASSIGN v = (a,);
ASSIGN retval = v;
} RETURN;
}
fn simple_rev_exp(a: i32) -> (i32,)
{
bb0: {
ASSIGN retval = (a,);
} RETURN;
}
// Check that if there's a mutable borrow of the source, that the source isn't propagated forwards
// - NOTE: This relies on the optimiser not being smart enough to move the `retval` construction up
#[test="nomut"]
fn nomut(a: i32) -> (i32,)
{
let v: i32;
let ba: &mut i32;
bb0: {
ASSIGN v = a;
ASSIGN ba = &mut a;
//ASSIGN a* = +0;
ASSIGN retval = (v,);
DROP ba;
} RETURN;
}
|