diff --git a/cranelift/frontend/src/frontend.rs b/cranelift/frontend/src/frontend.rs index df87010ee7..bfc0fd2329 100644 --- a/cranelift/frontend/src/frontend.rs +++ b/cranelift/frontend/src/frontend.rs @@ -259,7 +259,7 @@ impl<'a> FunctionBuilder<'a> { self.handle_ssa_side_effects(side_effects); } - /// Effectively calls seal_block on all blocks in the function. + /// Effectively calls seal_block on all unsealed blocks in the function. /// /// It's more efficient to seal `Block`s as soon as possible, during /// translation, but for frontends where this is impractical to do, this diff --git a/cranelift/frontend/src/ssa.rs b/cranelift/frontend/src/ssa.rs index cfb85a0287..4eef234290 100644 --- a/cranelift/frontend/src/ssa.rs +++ b/cranelift/frontend/src/ssa.rs @@ -372,7 +372,7 @@ impl SSABuilder { mem::replace(&mut self.side_effects, SideEffects::new()) } - /// Completes the global value numbering for all `Block`s in `func`. + /// Completes the global value numbering for all unsealed `Block`s in `func`. /// /// It's more efficient to seal `Block`s as soon as possible, during /// translation, but for frontends where this is impractical to do, this @@ -383,7 +383,9 @@ impl SSABuilder { // and creation of new blocks, however such new blocks are sealed on // the fly, so we don't need to account for them here. for block in self.ssa_blocks.keys() { - self.seal_one_block(block, func); + if !self.is_sealed(block) { + self.seal_one_block(block, func); + } } mem::replace(&mut self.side_effects, SideEffects::new()) }