()
| 777 | |
| 778 | #[test] |
| 779 | fn insts_same_block() { |
| 780 | let mut func = Function::new(); |
| 781 | let block0 = func.dfg.make_block(); |
| 782 | |
| 783 | let mut cur = FuncCursor::new(&mut func); |
| 784 | |
| 785 | cur.insert_block(block0); |
| 786 | let v1 = cur.ins().iconst(I32, 1); |
| 787 | let v2 = cur.ins().iadd(v1, v1); |
| 788 | let v3 = cur.ins().iadd(v2, v2); |
| 789 | cur.ins().return_(&[]); |
| 790 | |
| 791 | let cfg = ControlFlowGraph::with_function(cur.func); |
| 792 | let dt = DominatorTree::with_function(cur.func, &cfg); |
| 793 | |
| 794 | let v1_def = cur.func.dfg.value_def(v1).unwrap_inst(); |
| 795 | let v2_def = cur.func.dfg.value_def(v2).unwrap_inst(); |
| 796 | let v3_def = cur.func.dfg.value_def(v3).unwrap_inst(); |
| 797 | |
| 798 | assert!(dt.dominates(v1_def, v2_def, &cur.func.layout)); |
| 799 | assert!(dt.dominates(v2_def, v3_def, &cur.func.layout)); |
| 800 | assert!(dt.dominates(v1_def, v3_def, &cur.func.layout)); |
| 801 | |
| 802 | assert!(!dt.dominates(v2_def, v1_def, &cur.func.layout)); |
| 803 | assert!(!dt.dominates(v3_def, v2_def, &cur.func.layout)); |
| 804 | assert!(!dt.dominates(v3_def, v1_def, &cur.func.layout)); |
| 805 | |
| 806 | assert!(dt.dominates(v2_def, v2_def, &cur.func.layout)); |
| 807 | assert!(dt.dominates(block0, block0, &cur.func.layout)); |
| 808 | |
| 809 | assert!(dt.dominates(block0, v1_def, &cur.func.layout)); |
| 810 | assert!(dt.dominates(block0, v2_def, &cur.func.layout)); |
| 811 | assert!(dt.dominates(block0, v3_def, &cur.func.layout)); |
| 812 | |
| 813 | assert!(!dt.dominates(v1_def, block0, &cur.func.layout)); |
| 814 | assert!(!dt.dominates(v2_def, block0, &cur.func.layout)); |
| 815 | assert!(!dt.dominates(v3_def, block0, &cur.func.layout)); |
| 816 | } |
| 817 | } |
nothing calls this directly
no test coverage detected