From ed4964e8924abfec65d429edcdbb89eb83a17016 Mon Sep 17 00:00:00 2001 From: yesfish Date: Thu, 19 Oct 2017 02:41:49 +0100 Subject: [PATCH] reg_alloc: Improve performance of HostLocInfo (#112) This commit changes the type of HostLocInfo::values from std::vector to std::forward_list. --- src/backend_x64/reg_alloc.cpp | 6 +++--- src/backend_x64/reg_alloc.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend_x64/reg_alloc.cpp b/src/backend_x64/reg_alloc.cpp index 20eb147d..c5720790 100644 --- a/src/backend_x64/reg_alloc.cpp +++ b/src/backend_x64/reg_alloc.cpp @@ -5,6 +5,7 @@ */ #include +#include #include @@ -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; diff --git a/src/backend_x64/reg_alloc.h b/src/backend_x64/reg_alloc.h index 6a54819f..bf0a37f1 100644 --- a/src/backend_x64/reg_alloc.h +++ b/src/backend_x64/reg_alloc.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include #include @@ -40,7 +40,7 @@ public: void EndOfAllocScope(); private: - std::vector values; + std::forward_list values; bool is_being_used = false; bool is_scratch = false; };