Edge moves always before jumps, never after; semantics are too subtle otherwise (client needs to handle specially)

This commit is contained in:
Chris Fallin
2021-05-09 02:20:38 -07:00
parent c380b0d979
commit 8d7530d3fa

View File

@@ -3949,22 +3949,25 @@ impl<'a, F: Function> Env<'a, F> {
let (insertion_point, prio) = if to_ins > 1 && from_outs <= 1 { let (insertion_point, prio) = if to_ins > 1 && from_outs <= 1 {
( (
// N.B.: "after" the branch should be interpreted // N.B.: though semantically the edge moves happen
// by the user as happening before the actual // after the branch, we must insert them before
// branching action, but after the branch reads // the branch because otherwise, of course, they
// all necessary inputs. It's necessary to do this // would never execute. This is correct even in
// rather than to place the moves before the // the presence of branches that read register
// branch because the branch may have other // inputs (e.g. conditional branches on some RISCs
// actions than just the control-flow transfer, // that branch on reg zero/not-zero, or any
// and these other actions may require other // indirect branch), but for a very subtle reason:
// inputs (which should be read before the "edge" // all cases of such branches will (or should)
// moves). // have multiple successors, and thus due to
// // critical-edge splitting, their successors will
// Edits will only appear after the last (branch) // have only the single predecessor, and we prefer
// instruction if the block has only a single // to insert at the head of the successor in that
// successor; we do not expect the user to somehow // case (rather than here). We make this a
// duplicate or predicate these. // requirement, in fact: the user of this library
ProgPoint::after(from_last_insn), // shall not read registers in a branch
// instruction of there is only one successor per
// the given CFG information.
ProgPoint::before(from_last_insn),
InsertMovePrio::OutEdgeMoves, InsertMovePrio::OutEdgeMoves,
) )
} else if to_ins <= 1 { } else if to_ins <= 1 {