Skip to content

Commit

Permalink
chore: add a debug assert to not allow declaring a block predecessor …
Browse files Browse the repository at this point in the history
…twice
  • Loading branch information
greenhat committed Oct 19, 2023
1 parent 21ed2b3 commit 699e26e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion frontend-wasm/src/ssa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,18 @@ impl SSABuilder {
/// Callers are expected to avoid adding the same predecessor more than once in the case
/// of a jump table.
pub fn declare_block_predecessor(&mut self, block: Block, inst: Inst) {
debug_assert!(!self.is_sealed(block));
debug_assert!(
!self.is_sealed(block),
"you cannot add a predecessor to a sealed block"
);
debug_assert!(
self.ssa_blocks[block]
.predecessors
.as_slice(&self.inst_pool)
.iter()
.all(|&branch| branch != inst),
"you have declared the same predecessor twice!"
);
self.ssa_blocks[block]
.predecessors
.push(inst, &mut self.inst_pool);
Expand Down

0 comments on commit 699e26e

Please sign in to comment.