Skip to content

Commit

Permalink
go/ir: don't emit split stores before phi nodes
Browse files Browse the repository at this point in the history
Closes: gh-1495
  • Loading branch information
dominikh committed Feb 22, 2024
1 parent f57fec2 commit 102ab03
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion go/ir/lift.go
Expand Up @@ -970,7 +970,24 @@ func liftable(alloc *Alloc, instructions BlockMap[liftInstructions]) bool {
for i := range blocks {
// Update firstUnliftable to be one after lastLiftable. We do this to include the unliftable's preceding
// DebugRefs in the renaming.
blocks[i].firstUnliftable = blocks[i].lastLiftable + 1
if blocks[i].lastLiftable == -1 && !blocks[i].storeInPreds {
// There are no liftable instructions (for this alloc) in this block. Set firstUnliftable to the
// first non-head instruction to avoid inserting the store before phi instructions, which would
// fail validation.
first := -1
instrLoop:
for i, instr := range fn.Blocks[i].Instrs {
switch instr.(type) {
case *Phi, *Sigma:
default:
first = i
break instrLoop
}
}
blocks[i].firstUnliftable = first
} else {
blocks[i].firstUnliftable = blocks[i].lastLiftable + 1
}
}

// If a block is reachable by a (partially) unliftable block, then the entirety of the block is unliftable. In that
Expand Down

0 comments on commit 102ab03

Please sign in to comment.