Some fixes to allow for call instructions to name args, returns, and clobbers with constraints. (#74)
* Some fixes to allow for call instructions to name args, returns, and clobbers with constraints. - Allow early-pos uses with fixed regs that conflict with clobbers (which happen at late-pos), in addition to the existing logic for conflicts with late-pos defs with fixed regs. This is a pretty subtle issue that was uncovered in #53 for the def case, and the fix here is the mirror of that fix for clobbers. The root cause for all this complexity is that we can't split in the middle of an instruction (because there's no way to insert a move there!) so if a use is live-downward, we can't let it live in preg A at early-pos and preg B != A at late-pos; instead we need to rewrite the constraints and use a fixup move. The earlier change to fix #53 was actually a bit too conservative in that it always applied when such conflicts existed, even if the downward arg was not live. This PR fixes that (it's fine for the early-use and late-def to be fixed to the same reg if the use's liverange ends after early-pos) and adapts the same flexibility to the clobbers case as well. - Reworks the fixups for the def case mentioned above to not shift the def to the Early point. Doing so causes issues when the def is to a reffy vreg: it can then be falsely included in a stackmap if the instruction containing this operand is a safepoint. - Fixes the last-resort split-bundle-into-minimal-pieces logic from #59 to properly limit a minimal bundle piece to end after the early-pos, rather than cover the entire instruction. This was causing artificial overlaps between args that end after early-pos and defs that start at late-pos when one of the vregs hit the fallback split behavior. * Fix fuzzbug: do not merge when a liverange has a fixed-reg def. This can create impossible situations: e.g., if a vreg is constrained to p0 as a late-def, and another, completely different vreg is constrained to p0 as an early-use on the same instruction, and the instruction also has a third vreg (early-use), we do not want to merge the liverange for the third vreg with the first, because it would result in an unsolveable conflict for p0 at the early-point. * Review comments.
This commit is contained in:
@@ -16,7 +16,9 @@ use super::{
|
||||
Env, LiveBundleIndex, LiveRangeIndex, LiveRangeKey, SpillSet, SpillSetIndex, SpillSlotIndex,
|
||||
VRegIndex,
|
||||
};
|
||||
use crate::{ion::data_structures::BlockparamOut, Function, Inst, OperandConstraint, PReg};
|
||||
use crate::{
|
||||
ion::data_structures::BlockparamOut, Function, Inst, OperandConstraint, OperandKind, PReg,
|
||||
};
|
||||
use smallvec::smallvec;
|
||||
|
||||
impl<'a, F: Function> Env<'a, F> {
|
||||
@@ -93,6 +95,17 @@ impl<'a, F: Function> Env<'a, F> {
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid merging if either side has a fixed-reg def: this can
|
||||
// result in an impossible-to-solve allocation problem if
|
||||
// there is a fixed-reg use in the same reg on the same
|
||||
// instruction.
|
||||
if self.bundles[from.index()].cached_fixed_def()
|
||||
|| self.bundles[to.index()].cached_fixed_def()
|
||||
{
|
||||
trace!(" -> one bundle has a fixed def; aborting merge");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for a requirements conflict.
|
||||
if self.bundles[from.index()].cached_stack()
|
||||
|| self.bundles[from.index()].cached_fixed()
|
||||
@@ -258,16 +271,20 @@ impl<'a, F: Function> Env<'a, F> {
|
||||
}
|
||||
|
||||
let mut fixed = false;
|
||||
let mut fixed_def = false;
|
||||
let mut stack = false;
|
||||
for entry in &self.bundles[bundle.index()].ranges {
|
||||
for u in &self.ranges[entry.index.index()].uses {
|
||||
if let OperandConstraint::FixedReg(_) = u.operand.constraint() {
|
||||
fixed = true;
|
||||
if u.operand.kind() == OperandKind::Def {
|
||||
fixed_def = true;
|
||||
}
|
||||
}
|
||||
if let OperandConstraint::Stack = u.operand.constraint() {
|
||||
stack = true;
|
||||
}
|
||||
if fixed && stack {
|
||||
if fixed && stack && fixed_def {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -275,6 +292,9 @@ impl<'a, F: Function> Env<'a, F> {
|
||||
if fixed {
|
||||
self.bundles[bundle.index()].set_cached_fixed();
|
||||
}
|
||||
if fixed_def {
|
||||
self.bundles[bundle.index()].set_cached_fixed_def();
|
||||
}
|
||||
if stack {
|
||||
self.bundles[bundle.index()].set_cached_stack();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user