()
| 681 | |
| 682 | #[test] |
| 683 | fn aliases() { |
| 684 | use crate::ir::InstBuilder; |
| 685 | |
| 686 | let mut func = Function::new(); |
| 687 | { |
| 688 | let block0 = func.dfg.make_block(); |
| 689 | let mut pos = FuncCursor::new(&mut func); |
| 690 | pos.insert_block(block0); |
| 691 | |
| 692 | // make some detached values for change_to_alias |
| 693 | let v0 = pos.func.dfg.append_block_param(block0, types::I32); |
| 694 | let v1 = pos.func.dfg.append_block_param(block0, types::I32); |
| 695 | let v2 = pos.func.dfg.append_block_param(block0, types::I32); |
| 696 | pos.func.dfg.detach_block_params(block0); |
| 697 | |
| 698 | // alias to a param--will be printed at beginning of block defining param |
| 699 | let v3 = pos.func.dfg.append_block_param(block0, types::I32); |
| 700 | pos.func.dfg.change_to_alias(v0, v3); |
| 701 | |
| 702 | // alias to an alias--should print attached to alias, not ultimate target |
| 703 | pos.func.dfg.make_value_alias_for_serialization(v0, v2); // v0 <- v2 |
| 704 | |
| 705 | // alias to a result--will be printed after instruction producing result |
| 706 | let _dummy0 = pos.ins().iconst(types::I32, 42); |
| 707 | let v4 = pos.ins().iadd(v0, v0); |
| 708 | pos.func.dfg.change_to_alias(v1, v4); |
| 709 | let _dummy1 = pos.ins().iconst(types::I32, 23); |
| 710 | let _v7 = pos.ins().iadd(v1, v1); |
| 711 | } |
| 712 | assert_eq!( |
| 713 | func.to_string(), |
| 714 | "function u0:0() fast {\nblock0(v3: i32):\n v0 -> v3\n v2 -> v0\n v4 = iconst.i32 42\n v5 = iadd v0, v0\n v1 -> v5\n v6 = iconst.i32 23\n v7 = iadd v1, v1\n}\n" |
| 715 | ); |
| 716 | } |
| 717 | |
| 718 | #[test] |
| 719 | fn cold_blocks() { |
nothing calls this directly
no test coverage detected