Skip to content

Commit 830016f

Browse files
committed
fix broken dominance caught by ssacheck
See https://go-review.googlesource.com/c/go/+/483875 for more details. This happens when sccp generates a temporary Value v217 and it attempts to apply rewrite rule on it to see if v217 can be fold to constant value, v227 = Const64 <int32> v117 = Const32 <int32> [3] v217 = Mul32 <int32> v117 v227 In this case, v217 can not match any rules in generic rules, so it left in entry block while its arguments lives other blocks, which breaks the dominance relationship. These temporary values are dead values and will be removed in further deadcode phase but checkFunc catches them because it runs right after every pass. The proposed fix is to invalidate unmatched temporary value immediately.
1 parent e249f44 commit 830016f

File tree

1 file changed

+4
-2
lines changed
  • src/cmd/compile/internal/ssa

1 file changed

+4
-2
lines changed

src/cmd/compile/internal/ssa/sccp.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,10 @@ func computeLattice(f *Func, val *Value, args ...*Value) lattice {
358358
return lattice{constant, constValue}
359359
}
360360
}
361-
// Either we can not match generic rules for given value or it does not satisfy
362-
// additional constraints(e.g. divide by zero)
361+
// Either we can not match generic rules for given value or it does not
362+
// satisfy additional constraints(e.g. divide by zero), in these cases, clean
363+
// up temporary value immediately in case they are not dominated by their args.
364+
constValue.reset(OpInvalid)
363365
return lattice{bottom, nil}
364366
}
365367

0 commit comments

Comments
 (0)