Use new regalloc.rs version with dense vreg->rreg maps.
This PR updates Cranelift to use the new version of regalloc.rs (bytecodealliance/regalloc.rs#55) that provides dense vreg->rreg maps to the `map_reg()` function for each instruction, rather than the earlier hashmap-based approach. In one test (regex-rs.wasm), this PR results in a 15% reduction in memory allocations (1245MB -> 1060MB) as measured by DHAT on `clif-util wasm` runs.
This commit is contained in:
@@ -25,7 +25,9 @@ use crate::settings;
|
||||
|
||||
use regalloc::Function as RegallocFunction;
|
||||
use regalloc::Set as RegallocSet;
|
||||
use regalloc::{BlockIx, InstIx, Range, RegAllocResult, RegClass, RegUsageCollector};
|
||||
use regalloc::{
|
||||
BlockIx, InstIx, Range, RegAllocResult, RegClass, RegUsageCollector, RegUsageMapper,
|
||||
};
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use alloc::vec::Vec;
|
||||
@@ -647,18 +649,18 @@ impl<I: VCodeInst> RegallocFunction for VCode<I> {
|
||||
insn.get_regs(collector)
|
||||
}
|
||||
|
||||
fn map_regs(
|
||||
insn: &mut I,
|
||||
pre_map: &RegallocMap<VirtualReg, RealReg>,
|
||||
post_map: &RegallocMap<VirtualReg, RealReg>,
|
||||
) {
|
||||
insn.map_regs(pre_map, post_map);
|
||||
fn map_regs(insn: &mut I, mapper: &RegUsageMapper) {
|
||||
insn.map_regs(mapper);
|
||||
}
|
||||
|
||||
fn is_move(&self, insn: &I) -> Option<(Writable<Reg>, Reg)> {
|
||||
insn.is_move()
|
||||
}
|
||||
|
||||
fn get_vreg_count_estimate(&self) -> Option<usize> {
|
||||
Some(self.vreg_types.len())
|
||||
}
|
||||
|
||||
fn get_spillslot_size(&self, regclass: RegClass, vreg: VirtualReg) -> u32 {
|
||||
let ty = self.vreg_type(vreg);
|
||||
self.abi.get_spillslot_size(regclass, ty)
|
||||
|
||||
Reference in New Issue
Block a user