File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -970,7 +970,24 @@ func liftable(alloc *Alloc, instructions BlockMap[liftInstructions]) bool {
970970 for i := range blocks {
971971 // Update firstUnliftable to be one after lastLiftable. We do this to include the unliftable's preceding
972972 // DebugRefs in the renaming.
973- blocks [i ].firstUnliftable = blocks [i ].lastLiftable + 1
973+ if blocks [i ].lastLiftable == - 1 && ! blocks [i ].storeInPreds {
974+ // There are no liftable instructions (for this alloc) in this block. Set firstUnliftable to the
975+ // first non-head instruction to avoid inserting the store before phi instructions, which would
976+ // fail validation.
977+ first := - 1
978+ instrLoop:
979+ for i , instr := range fn .Blocks [i ].Instrs {
980+ switch instr .(type ) {
981+ case * Phi , * Sigma :
982+ default :
983+ first = i
984+ break instrLoop
985+ }
986+ }
987+ blocks [i ].firstUnliftable = first
988+ } else {
989+ blocks [i ].firstUnliftable = blocks [i ].lastLiftable + 1
990+ }
974991 }
975992
976993 // If a block is reachable by a (partially) unliftable block, then the entirety of the block is unliftable. In that
You can’t perform that action at this time.
0 commit comments