mirror of https://github.com/golang/go.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 <mike.munday@ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
382fe3e249
commit
48403b268b
|
|
@ -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)<<uint(r.num)) != 0 {
|
||||
e.s.f.Fatalf("%v is already set (v%d/%v)", r, vid, c)
|
||||
}
|
||||
e.usedRegs |= regMask(1) << uint(r.num)
|
||||
if final {
|
||||
e.finalRegs |= regMask(1) << uint(r.num)
|
||||
|
|
|
|||
Loading…
Reference in New Issue