diff --git a/src/mir/RegAlloc.cpp b/src/mir/RegAlloc.cpp index a3f7a07f..394bc08b 100644 --- a/src/mir/RegAlloc.cpp +++ b/src/mir/RegAlloc.cpp @@ -1265,6 +1265,15 @@ namespace mir if (function.GetNumVRegs() == 0) return; + // 超大函数跳过图着色,全栈槽分配保证正确性 + if (function.GetNumVRegs() > 250) { + std::set all_spilled; + for (size_t i = 0; i < function.GetNumVRegs(); i++) + all_spilled.insert(static_cast(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) {