summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendiadyoin1 <leon.a@serenityos.org>2022-10-30 12:25:35 +0100
committerAndreas Kling <kling@serenityos.org>2022-11-01 11:21:18 +0100
commit28e2467b487870beee048d65b023cb47b207c3ee (patch)
tree54467bba3fb21261420ac6565101d5690b74f806
parent1ac1a5bd58961e3964aa87c3a88777fe008cd3d3 (diff)
downloadserenity-28e2467b487870beee048d65b023cb47b207c3ee.zip
LibJS: Minor cleanups in MergeBlocks
-rw-r--r--Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp b/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp
index 0d2bb4dac9..e240ad0fa1 100644
--- a/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp
+++ b/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp
@@ -33,13 +33,12 @@ void MergeBlocks::perform(PassPipelineExecutable& executable)
{
InstructionStreamIterator it { entry.key->instruction_stream() };
auto& first_instruction = *it;
- if (first_instruction.is_terminator()) {
- if (first_instruction.type() == Instruction::Type::Jump) {
- auto replacing_block = &static_cast<Op::Jump const&>(first_instruction).true_target()->block();
- if (replacing_block != entry.key)
- blocks_to_replace.set(entry.key, replacing_block);
- continue;
+ if (first_instruction.type() == Instruction::Type::Jump) {
+ auto const* replacing_block = &static_cast<Op::Jump const&>(first_instruction).true_target()->block();
+ if (replacing_block != entry.key) {
+ blocks_to_replace.set(entry.key, replacing_block);
}
+ continue;
}
}
@@ -54,7 +53,7 @@ void MergeBlocks::perform(PassPipelineExecutable& executable)
}
for (auto& entry : blocks_to_replace) {
- auto replacement = entry.value;
+ auto const* replacement = entry.value;
for (;;) {
auto lookup = blocks_to_replace.get(replacement);
if (!lookup.has_value())
@@ -94,20 +93,19 @@ void MergeBlocks::perform(PassPipelineExecutable& executable)
while (!blocks_to_merge.is_empty()) {
auto it = blocks_to_merge.begin();
- auto current_block = *it;
+ auto const* current_block = *it;
blocks_to_merge.remove(it);
Vector<BasicBlock const*> successors { current_block };
for (;;) {
- auto last = successors.last();
+ auto const* last = successors.last();
auto entry = cfg.find(last);
if (entry == cfg.end())
break;
- auto& successor = *entry->value.begin();
+ auto const* successor = *entry->value.begin();
successors.append(successor);
- auto it = blocks_to_merge.find(successor);
- if (it == blocks_to_merge.end())
+
+ if (!blocks_to_merge.remove(successor))
break;
- blocks_to_merge.remove(it);
}
auto blocks_to_merge_copy = blocks_to_merge;