1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:37:35 +00:00

LibJS: Avoid unnecessary copies in MergeBlocks codegen pass

This commit is contained in:
Ben Wiederhake 2021-12-24 21:38:33 +01:00 committed by Andreas Kling
parent a1aea5b9e0
commit 0c365fdfd3

View file

@ -43,9 +43,9 @@ void MergeBlocks::perform(PassPipelineExecutable& executable)
} }
} }
if (auto cfg_entry = inverted_cfg.get(*entry.value.begin()); cfg_entry.has_value()) { if (auto cfg_iter = inverted_cfg.find(*entry.value.begin()); cfg_iter != inverted_cfg.end()) {
auto& predecssor_entry = *cfg_entry; auto& predecessor_entry = cfg_iter->value;
if (predecssor_entry.size() != 1) if (predecessor_entry.size() != 1)
continue; continue;
} }
@ -99,10 +99,10 @@ void MergeBlocks::perform(PassPipelineExecutable& executable)
Vector<BasicBlock const*> successors { current_block }; Vector<BasicBlock const*> successors { current_block };
for (;;) { for (;;) {
auto last = successors.last(); auto last = successors.last();
auto entry = cfg.get(last); auto entry = cfg.find(last);
if (!entry.has_value()) if (entry == cfg.end())
break; break;
auto& successor = *entry->begin(); auto& successor = *entry->value.begin();
successors.append(successor); successors.append(successor);
auto it = blocks_to_merge.find(successor); auto it = blocks_to_merge.find(successor);
if (it == blocks_to_merge.end()) if (it == blocks_to_merge.end())
@ -112,10 +112,10 @@ void MergeBlocks::perform(PassPipelineExecutable& executable)
auto blocks_to_merge_copy = blocks_to_merge; auto blocks_to_merge_copy = blocks_to_merge;
for (auto& last : blocks_to_merge) { for (auto& last : blocks_to_merge) {
auto entry = cfg.get(last); auto entry = cfg.find(last);
if (!entry.has_value()) if (entry == cfg.end())
continue; continue;
auto successor = *entry->begin(); auto successor = *entry->value.begin();
if (auto it = successors.find(successor); !it.is_end()) { if (auto it = successors.find(successor); !it.is_end()) {
successors.insert(it.index(), last); successors.insert(it.index(), last);
blocks_to_merge_copy.remove(last); blocks_to_merge_copy.remove(last);