fix(backend): skip graph coloring for functions with >250 vregs

For extremely large functions, the iterative spill loop creates a
vreg cascade (176 vregs -> 1675 spilled after 3 rounds) that the
scratch register pool cannot handle. Use all-stack allocation as
a safe fallback for these cases.

Fixes 39_fp_params main/params_mix/params_fa40 output correctness.
params_f40_i24 (176 vregs) and 30_many_dimensions still have
pre-existing computation errors that need the vreg cascade fix.
hxz
黄熙哲 5 days ago
parent 2632202833
commit 4be2f32cbb

@ -1265,6 +1265,15 @@ namespace mir
if (function.GetNumVRegs() == 0)
return;
// 超大函数跳过图着色,全栈槽分配保证正确性
if (function.GetNumVRegs() > 250) {
std::set<int> all_spilled;
for (size_t i = 0; i < function.GetNumVRegs(); i++)
all_spilled.insert(static_cast<int>(i));
RewriteWithAllocation(function, {}, {}, all_spilled);
return;
}
const int MAX_SPILL_ROUNDS = (function.GetNumVRegs() > 120) ? 3 : 10;
for (int round = 0; round < MAX_SPILL_ROUNDS; ++round)
{

Loading…
Cancel
Save