backend/arm64/reg_alloc: Update uses on all locations

Trying to optimize just for args is incorrect when inst has zero uses
This commit is contained in:
Merry 2022-08-02 01:02:43 +01:00 committed by merry
parent 2c75ca746b
commit 2ab0e64be4
3 changed files with 15 additions and 10 deletions

View file

@ -192,6 +192,7 @@ EmittedBlockInfo EmitArm64(oaknut::CodeGenerator& code, IR::Block block, const E
break;
}
reg_alloc.UpdateAllUses();
reg_alloc.AssertAllUnlocked();
}

View file

@ -31,14 +31,6 @@ static bool IsValuelessType(IR::Type type) {
}
}
Argument::~Argument() {
if (!IsImmediate()) {
if (auto host_loc = reg_alloc.ValueLocation(value.GetInst())) {
reg_alloc.ValueInfo(*host_loc).UpdateUses();
}
}
}
IR::Type Argument::GetType() const {
return value.GetType();
}
@ -197,6 +189,19 @@ void RegAlloc::DefineAsRegister(IR::Inst* inst, oaknut::Reg reg) {
info.expected_uses += inst->UseCount();
}
void RegAlloc::UpdateAllUses() {
for (auto& gpr : gprs) {
gpr.UpdateUses();
}
for (auto& fpr : fprs) {
fpr.UpdateUses();
}
flags.UpdateUses();
for (auto& spill : spills) {
spill.UpdateUses();
}
}
void RegAlloc::AssertAllUnlocked() const {
const auto is_unlocked = [](const auto& i) { return !i.locked && !i.realized; };
ASSERT(std::all_of(gprs.begin(), gprs.end(), is_unlocked));

View file

@ -46,8 +46,6 @@ struct Argument final {
public:
using copyable_reference = std::reference_wrapper<Argument>;
~Argument();
IR::Type GetType() const;
bool IsImmediate() const;
@ -284,6 +282,7 @@ public:
(rs.Realize(), ...);
}
void UpdateAllUses();
void AssertAllUnlocked() const;
void AssertNoMoreUses() const;