reg_alloc: Improve performance of HostLocInfo (#112)

This commit changes the type of HostLocInfo::values from std::vector<Inst*> to std::forward_list<Inst*>.
This commit is contained in:
yesfish 2017-10-19 02:41:49 +01:00 committed by Merry
parent 148c01e08f
commit ed4964e892
2 changed files with 5 additions and 5 deletions

View File

@ -5,6 +5,7 @@
*/
#include <algorithm>
#include <vector>
#include <xbyak.h>
@ -99,12 +100,11 @@ void HostLocInfo::WriteLock() {
}
void HostLocInfo::AddValue(IR::Inst* inst) {
values.push_back(inst);
values.push_front(inst);
}
void HostLocInfo::EndOfAllocScope() {
const auto to_erase = std::remove_if(values.begin(), values.end(), [](const auto& inst) { return !inst->HasUses(); });
values.erase(to_erase, values.end());
values.remove_if([](const auto& inst) { return !inst->HasUses(); });
is_being_used = false;
is_scratch = false;

View File

@ -7,7 +7,7 @@
#pragma once
#include <array>
#include <vector>
#include <forward_list>
#include <boost/optional.hpp>
#include <xbyak.h>
@ -40,7 +40,7 @@ public:
void EndOfAllocScope();
private:
std::vector<IR::Inst*> values;
std::forward_list<IR::Inst*> values;
bool is_being_used = false;
bool is_scratch = false;
};