mirror of
https://github.com/golang/go
synced 2024-11-23 09:20:05 -07:00
788a227759
We can't delete all the outgoing edges and then add one back in, because then we've lost the argument of any phi at the target. Instead, move the important target to the front of the list and delete the rest. This normally isn't a problem, because there is never normally a phi at the target of a jump table. But this isn't quite true when in race build mode, because there is a phi of the result of a bunch of raceread calls. The reason this happens is that each case is written like this (where e is the runtime.eface we're switching on): if e.type == $type.int32 { m = raceread(e.data, m1) } m2 = phi(m1, m) if e.type == $type.int32 { .. do case .. goto blah } so that if e.type is not $type.int32, it falls through to the default case. This default case will have a memory phi for all the (jumped around and not actually called) raceread calls. If we instead did it like if e.type == $type.int32 { raceread(e.data) .. do case .. goto blah } That would paper over this bug, as it is the only way to construct a jump table whose target is a block with a phi in it. (Yet.) But we'll fix the underlying bug in this CL. Maybe we can do the rewrite mentioned above later. (It is an optimization for -race mode, which isn't particularly important.) Fixes #64606 Change-Id: I6f6e3c90eb1e2638112920ee2e5b6581cef04ea4 Reviewed-on: https://go-review.googlesource.com/c/go/+/548356 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
33 lines
463 B
Go
33 lines
463 B
Go
// build -race
|
|
|
|
//go:build race
|
|
|
|
// Copyright 2023 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package main
|
|
|
|
func main() {
|
|
var o any = uint64(5)
|
|
switch o.(type) {
|
|
case int:
|
|
goto ret
|
|
case int8:
|
|
goto ret
|
|
case int16:
|
|
goto ret
|
|
case int32:
|
|
goto ret
|
|
case int64:
|
|
goto ret
|
|
case float32:
|
|
goto ret
|
|
case float64:
|
|
goto ret
|
|
default:
|
|
goto ret
|
|
}
|
|
ret:
|
|
}
|