From: Michael Munday Date: Tue, 14 Apr 2020 09:12:32 +0000 (+0100) Subject: cmd/compile: error if register is reused when setting edge state X-Git-Tag: go1.15beta1~548 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=48403b268bd31a220685c28a94259a461b352e3e;p=gostls13.git cmd/compile: error if register is reused when setting edge state When setting the edge state in register allocation we should only be setting each register once. It is not possible for a register to hold multiple values at once. This CL converts the runtime error seen in #38195 into an internal compiler error (ICE). It is better for the compiler to fail than generate an incorrect program. The bug reported in #38195 is now exposed as: ./parserc.go:459:11: internal compiler error: 'yaml_parser_parse_node': R5 is already set (v1074/v1241) [stack trace] Updates #38195. Change-Id: Id95842fd850b95494cbd472b6fd5a55513ecacec Reviewed-on: https://go-review.googlesource.com/c/go/+/228060 Run-TryBot: Michael Munday TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- diff --git a/src/cmd/compile/internal/ssa/regalloc.go b/src/cmd/compile/internal/ssa/regalloc.go index 95e732d744..a2be7bb596 100644 --- a/src/cmd/compile/internal/ssa/regalloc.go +++ b/src/cmd/compile/internal/ssa/regalloc.go @@ -2164,6 +2164,9 @@ func (e *edgeState) set(loc Location, vid ID, c *Value, final bool, pos src.XPos a = append(a, c) e.cache[vid] = a if r, ok := loc.(*Register); ok { + if e.usedRegs&(regMask(1)<