mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +00:00
LibJS: Minor cleanups in MergeBlocks
This commit is contained in:
parent
1ac1a5bd58
commit
28e2467b48
Notes:
sideshowbarker
2024-07-17 04:56:04 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/28e2467b48 Pull-request: https://github.com/SerenityOS/serenity/pull/15857 Issue: https://github.com/SerenityOS/serenity/issues/15753 Reviewed-by: https://github.com/alimpfard
1 changed files with 11 additions and 13 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue