Cranelift: fix regalloc2 integration bug wrt blockparam branch args. (#4042)
Previously, the block successor accumulation and the blockparam branch arg setup were decoupled. The lowering backend implicitly specified the order of successor edges via its `MachTerminator` enum on the last instruction in the block, while the `Lower` toplevel machine-independent driver set up blockparam branch args in the edge order seen in CLIF. In some cases, these orders did not match -- for example, when the conditional branch depended on an FP condition that was implemented by swapping taken/not-taken edges and inverting the condition code. This PR refactors the successor handling to be centralized in `Lower` rather than flow through the terminator `MachInst`, and adds a successor block and its blockparam args at the same time, ensuring the orders match.
This commit is contained in:
@@ -2119,18 +2119,13 @@ impl MachInst for Inst {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_term<'a>(&'a self) -> MachTerminator<'a> {
|
||||
fn is_term(&self) -> MachTerminator {
|
||||
match self {
|
||||
// Interesting cases.
|
||||
&Self::Ret { .. } | &Self::EpiloguePlaceholder => MachTerminator::Ret,
|
||||
&Self::JmpKnown { dst } => MachTerminator::Uncond(dst),
|
||||
&Self::JmpCond {
|
||||
taken, not_taken, ..
|
||||
} => MachTerminator::Cond(taken, not_taken),
|
||||
&Self::JmpTableSeq {
|
||||
ref targets_for_term,
|
||||
..
|
||||
} => MachTerminator::Indirect(&targets_for_term[..]),
|
||||
&Self::JmpKnown { .. } => MachTerminator::Uncond,
|
||||
&Self::JmpCond { .. } => MachTerminator::Cond,
|
||||
&Self::JmpTableSeq { .. } => MachTerminator::Indirect,
|
||||
// All other cases are boring.
|
||||
_ => MachTerminator::None,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user