Build the final VCode.
(mut self, mut vregs: VRegAllocator<I>)
| 561 | |
| 562 | /// Build the final VCode. |
| 563 | pub fn build(mut self, mut vregs: VRegAllocator<I>) -> VCode<I> { |
| 564 | self.vcode.vreg_types = take(&mut vregs.vreg_types); |
| 565 | |
| 566 | if self.direction == VCodeBuildDirection::Backward { |
| 567 | self.reverse_and_finalize(&vregs); |
| 568 | } |
| 569 | self.collect_operands(&vregs); |
| 570 | |
| 571 | self.compute_preds_from_succs(); |
| 572 | self.vcode.debug_value_labels.sort_unstable(); |
| 573 | |
| 574 | // At this point, nothing in the vcode should mention any |
| 575 | // VReg which has been aliased. All the appropriate rewriting |
| 576 | // should have happened above. Just to be sure, let's |
| 577 | // double-check each field which has vregs. |
| 578 | // Note: can't easily check vcode.insts, resolved in collect_operands. |
| 579 | // Operands are resolved in collect_operands. |
| 580 | vregs.debug_assert_no_vreg_aliases(self.vcode.operands.iter().map(|op| op.vreg())); |
| 581 | // Currently block params are never aliased to another vreg. |
| 582 | vregs.debug_assert_no_vreg_aliases(self.vcode.block_params.iter().copied()); |
| 583 | // Branch block args are resolved in collect_operands. |
| 584 | vregs.debug_assert_no_vreg_aliases(self.vcode.branch_block_args.iter().copied()); |
| 585 | // Debug value labels are resolved in reverse_and_finalize. |
| 586 | vregs.debug_assert_no_vreg_aliases( |
| 587 | self.vcode.debug_value_labels.iter().map(|&(vreg, ..)| vreg), |
| 588 | ); |
| 589 | |
| 590 | self.vcode |
| 591 | } |
| 592 | |
| 593 | /// Add a user stack map for the associated instruction. |
| 594 | pub fn add_user_stack_map( |
no test coverage detected