// all // // Based on this Sway: // // script; // // fn a(b: bool) -> u64 { // let x = 10; // if b { // x // } else { // 1 // } // } // // fn main() -> u64 { // let mut x = 0; // x = a(true); // x // } // regex: VAR=v\d+ // regex: ID=[[:alpha:]0-9_]+ script { fn a(b: bool) -> u64 { local u64 x entry(b: bool): v0 = get_local ptr u64, x v1 = const u64 10 store v1 to v0 cbr b, block0(), block1() block0(): v2 = get_local ptr u64, x v3 = load v2 br block2(v3) block1(): v4 = const u64 1 br block2(v4) block2(v5: u64): ret u64 v5 } // 'b' is passed to a() and used for the CBR, so check below that the value we pass to a() is // inlined and used for CBR and the two blocks in a() too, and then followed by what's after the // call. // check: fn main fn main() -> u64 { local u64 x entry(): v0 = get_local ptr u64, x v1 = const u64 0 store v1 to v0 // check: $(arg=$VAR) = const bool true v2 = const bool true // not: call v3 = call a(v2) // check: cbr $arg, $(t=$ID)(), $(f=$ID)() // check: $t(): // check: $f(): // check: get_local ptr u64, x v4 = get_local ptr u64, x store v3 to v4 v5 = get_local ptr u64, x v6 = load v5 ret u64 v6 } }