MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / verify

Function verify

cranelift/codegen/src/ir/layout.rs:827–860  ·  view source on GitHub ↗
(layout: &mut Layout, blocks: &[(Block, &[Inst])])

Source from the content-addressed store, hash-verified

825 }
826
827 fn verify(layout: &mut Layout, blocks: &[(Block, &[Inst])]) {
828 // Check that blocks are inserted and instructions belong the right places.
829 // Check forward linkage with iterators.
830 // Check that layout sequence numbers are strictly monotonic.
831 {
832 let mut block_iter = layout.blocks();
833 for &(block, insts) in blocks {
834 assert!(layout.is_block_inserted(block));
835 assert_eq!(block_iter.next(), Some(block));
836
837 let mut seq = 0;
838 let mut inst_iter = layout.block_insts(block);
839 for &inst in insts {
840 assert_eq!(layout.inst_block(inst), Some(block));
841 assert_eq!(inst_iter.next(), Some(inst));
842 assert!(layout.insts[inst].seq > seq);
843 seq = layout.insts[inst].seq;
844 }
845 assert_eq!(inst_iter.next(), None);
846 }
847 assert_eq!(block_iter.next(), None);
848 }
849
850 // Check backwards linkage with a cursor.
851 let mut cur = LayoutCursor::new(layout);
852 for &(block, insts) in blocks.into_iter().rev() {
853 assert_eq!(cur.prev_block(), Some(block));
854 for &inst in insts.into_iter().rev() {
855 assert_eq!(cur.prev_inst(), Some(inst));
856 }
857 assert_eq!(cur.prev_inst(), None);
858 }
859 assert_eq!(cur.prev_block(), None);
860 }
861
862 #[test]
863 fn append_block() {

Callers 5

append_blockFunction · 0.70
insert_blockFunction · 0.70
insert_block_afterFunction · 0.70
append_instFunction · 0.70
insert_instFunction · 0.70

Calls 4

blocksMethod · 0.80
block_instsMethod · 0.80
newFunction · 0.50
into_iterMethod · 0.45

Tested by 5

append_blockFunction · 0.56
insert_blockFunction · 0.56
insert_block_afterFunction · 0.56
append_instFunction · 0.56
insert_instFunction · 0.56