package ssa
+import "cmd/internal/src"
+
// trim removes blocks with no code in them.
// These blocks were inserted to remove critical edges.
func trim(f *Func) {
continue
}
+ bPos := b.Pos
+ bIsStmt := bPos.IsStmt() == src.PosIsStmt
+
// Splice b out of the graph. NOTE: `mergePhi` depends on the
// order, in which the predecessors edges are merged here.
p, i := b.Preds[0].b, b.Preds[0].i
s.Preds = append(s.Preds, Edge{p, i})
}
+ // Attempt to preserve a statement boundary
+ if bIsStmt {
+ sawStmt := false
+ for _, v := range s.Values {
+ if isPoorStatementOp(v.Op) {
+ continue
+ }
+ if v.Pos.SameFileAndLine(bPos) {
+ v.Pos = v.Pos.WithIsStmt()
+ }
+ sawStmt = true
+ break
+ }
+ if !sawStmt && s.Pos.SameFileAndLine(bPos) {
+ s.Pos = s.Pos.WithIsStmt()
+ }
+ }
// If `s` had more than one predecessor, update its phi-ops to
// account for the merge.
if ns > 1 {
if v.Op == OpPhi {
mergePhi(v, j, b)
}
+
}
// Remove the phi-ops from `b` if they were merged into the
// phi-ops of `s`.