From 18b8fae85cb1c67bafa118a162966f84eda193d1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 8 May 2024 12:55:32 +0200 Subject: [PATCH] LibJS/Bytecode: Remove pointless basic block in SwitchStatement codegen --- Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp index ad0b37bc23d..038cf0e5c7a 100644 --- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -2588,7 +2588,6 @@ Bytecode::CodeGenerationErrorOr> SwitchStatement::genera for (auto& switch_case : m_cases) { auto& case_block = generator.make_block(); - auto& case_entry_block = generator.make_block(); if (switch_case->test()) { generator.switch_to_basic_block(*next_test_block); auto test_value = TRY(switch_case->test()->generate_bytecode(generator)).value(); @@ -2597,17 +2596,12 @@ Bytecode::CodeGenerationErrorOr> SwitchStatement::genera next_test_block = &generator.make_block(); generator.emit( result, - Bytecode::Label { case_entry_block }, + Bytecode::Label { case_block }, Bytecode::Label { *next_test_block }); } else { - entry_block_for_default = &case_entry_block; + entry_block_for_default = &case_block; } - // Initialize the completion value of the switch statement to empty. We can't do this in the case's basic block directly, - // as we must not clobber the possible non-empty completion value of the previous case when falling through. - generator.switch_to_basic_block(case_entry_block); - generator.emit(Bytecode::Label { case_block }); - case_blocks.append(case_block); } generator.switch_to_basic_block(*next_test_block);