Skip to content

Commit a1f7c4f

Browse files
committed
Refactor can_split_fragment_before interface
1 parent 98653db commit a1f7c4f

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

crates/codegen/src/regalloc/assign.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,7 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
166166
// This boundary is interesting for splitting if it can non-degenerately split
167167
// the fragment in two.
168168
let split_boundary = boundary.filter(|boundary| {
169-
self.can_split_fragment_before(
170-
fragment,
171-
ProgramPoint::before(boundary.instr()),
172-
)
169+
self.can_split_fragment_before(fragment, boundary.instr())
173170
});
174171
if let Some(split_boundary) = split_boundary {
175172
match earliest_hard_conflict_boundary {
@@ -440,9 +437,7 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
440437
.fragment_instrs(fragment)
441438
.map(|frag_instr| frag_instr.instr())
442439
.take_while(|&frag_instr| frag_instr < instr)
443-
.filter(|&frag_instr| {
444-
self.can_split_fragment_before(fragment, ProgramPoint::before(frag_instr))
445-
})
440+
.filter(|&frag_instr| self.can_split_fragment_before(fragment, frag_instr))
446441
.last();
447442

448443
// We always split *before* the selected instruction, but we want to split *after*
@@ -454,9 +449,7 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
454449
.fragment_instrs(fragment)
455450
.map(|frag_instr| frag_instr.instr())
456451
.filter(|&frag_instr| frag_instr > instr)
457-
.find(|&frag_instr| {
458-
self.can_split_fragment_before(fragment, ProgramPoint::before(frag_instr))
459-
});
452+
.find(|&frag_instr| self.can_split_fragment_before(fragment, frag_instr));
460453

461454
first_instr_above.unwrap_or(instr)
462455
}
@@ -469,9 +462,9 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
469462
self.fragment_hull(fragment)
470463
);
471464

472-
let pos = ProgramPoint::before(instr);
465+
debug_assert!(self.can_split_fragment_before(fragment, instr));
473466

474-
debug_assert!(self.can_split_fragment_before(fragment, pos));
467+
let pos = ProgramPoint::before(instr);
475468

476469
let (split_idx, split_boundary_range) = match self.live_set_fragments[fragment]
477470
.ranges
@@ -842,8 +835,9 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
842835
.flat_map(|range| self.live_ranges[range.live_range].instrs.iter().copied())
843836
}
844837

845-
fn can_split_fragment_before(&self, fragment: LiveSetFragment, point: ProgramPoint) -> bool {
846-
self.fragment_hull(fragment).can_split_before(point)
838+
fn can_split_fragment_before(&self, fragment: LiveSetFragment, instr: Instr) -> bool {
839+
self.fragment_hull(fragment)
840+
.can_split_before(ProgramPoint::before(instr))
847841
}
848842

849843
fn is_fragment_spilled(&self, fragment: LiveSetFragment) -> bool {

0 commit comments

Comments
 (0)