Skip to content

Commit

Permalink
LibJS: Don't try to merge blocks not ending in Jumps
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendiadyoin1 authored and alimpfard committed Dec 3, 2022
1 parent 192897c commit 186237a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ void MergeBlocks::perform(PassPipelineExecutable& executable)
if (executable.exported_blocks->contains(*entry.value.begin()))
continue;

if (entry.key->terminator()->type() != Instruction::Type::Jump)
continue;

{
InstructionStreamIterator it { entry.key->instruction_stream() };
auto& first_instruction = *it;
Expand Down Expand Up @@ -95,6 +98,7 @@ void MergeBlocks::perform(PassPipelineExecutable& executable)
auto it = blocks_to_merge.begin();
auto const* current_block = *it;
blocks_to_merge.remove(it);

Vector<BasicBlock const*> successors { current_block };
for (;;) {
auto const* last = successors.last();
Expand Down

0 comments on commit 186237a

Please sign in to comment.