This commit is contained in:
lizzie 2026-01-12 11:00:06 +00:00
parent d12d8417ed
commit 1251317114
2 changed files with 7 additions and 13 deletions

View File

@ -144,7 +144,7 @@ RegAlloc::ArgumentInfo RegAlloc::GetArgumentInfo(IR::Inst* inst) {
}
bool RegAlloc::WasValueDefined(IR::Inst* inst) const {
return defined_insts_count > 0;
return defined_insts.count(inst) > 0;
}
void RegAlloc::PrepareForCall(std::optional<Argument::copyable_reference> arg0, std::optional<Argument::copyable_reference> arg1, std::optional<Argument::copyable_reference> arg2, std::optional<Argument::copyable_reference> arg3) {
@ -192,8 +192,7 @@ void RegAlloc::PrepareForCall(std::optional<Argument::copyable_reference> arg0,
}
void RegAlloc::DefineAsExisting(IR::Inst* inst, Argument& arg) {
++defined_insts_count;
defined_insts.insert(inst);
ASSERT(!ValueLocation(inst));
if (arg.value.IsImmediate()) {
@ -207,8 +206,7 @@ void RegAlloc::DefineAsExisting(IR::Inst* inst, Argument& arg) {
}
void RegAlloc::DefineAsRegister(IR::Inst* inst, oaknut::Reg reg) {
++defined_insts_count;
defined_insts.insert(inst);
ASSERT(!ValueLocation(inst));
auto& info = reg.is_vector() ? fprs[reg.index()] : gprs[reg.index()];
ASSERT(info.IsCompletelyEmpty());
@ -374,8 +372,7 @@ int RegAlloc::RealizeReadImpl(const IR::Value& value) {
template<HostLoc::Kind kind>
int RegAlloc::RealizeWriteImpl(const IR::Inst* value) {
++defined_insts_count;
defined_insts.insert(inst);
ASSERT(!ValueLocation(value));
if constexpr (kind == HostLoc::Kind::Gpr) {
@ -399,8 +396,7 @@ int RegAlloc::RealizeWriteImpl(const IR::Inst* value) {
template<HostLoc::Kind kind>
int RegAlloc::RealizeReadWriteImpl(const IR::Value& read_value, const IR::Inst* write_value) {
++defined_insts_count;
defined_insts.insert(inst);
// TODO: Move elimination
const int write_loc = RealizeWriteImpl<kind>(write_value);
@ -463,8 +459,7 @@ void RegAlloc::SpillFpr(int index) {
}
void RegAlloc::ReadWriteFlags(Argument& read, IR::Inst* write) {
++defined_insts_count;
defined_insts.insert(inst);
const auto current_location = ValueLocation(read.value.GetInst());
ASSERT(current_location);

View File

@ -332,8 +332,7 @@ private:
std::array<HostLocInfo, SpillCount> spills;
mutable std::mt19937 rand_gen;
size_t defined_insts_count = 0;
ankerl::unordered_dense::set<const IR::Inst*> defined_insts;
};
template<typename T>