From acd29e064cc6a41cc889294aa2c6f81251817c07 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 3 Mar 2024 19:04:55 +0100 Subject: [PATCH] LibJS/Bytecode: Don't replace the entry block in MergeBlocks The entry block must stay in place, although it's okay to merge stuff into it. This fixes 4 test262 tests and brings us to parity with optimization disabled. :^) --- Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp b/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp index 89cdcd28d2..3301614436 100644 --- a/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp @@ -36,7 +36,8 @@ void MergeBlocks::perform(PassPipelineExecutable& executable) if (entry.key->terminator()->type() != Instruction::Type::Jump) continue; - { + // NOTE: We can't replace the first block in a function, as it's the entry block. + if (entry.key != executable.executable.basic_blocks.first()) { InstructionStreamIterator it { entry.key->instruction_stream() }; auto& first_instruction = *it; if (first_instruction.type() == Instruction::Type::Jump) {