mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
cmd/compile: run checkbce after fuseLate pass
So the bounds check which are eliminated during late fuse pass could be detected correctly. Fixes #67329 Change-Id: Id7992fbb8c26e0d43e7db66a0a3a2c0d9ed937a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/598635 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
3f9360345c
commit
864aa86448
@ -16,6 +16,9 @@ func checkbce(f *Func) {
|
||||
}
|
||||
|
||||
for _, b := range f.Blocks {
|
||||
if b.Kind == BlockInvalid {
|
||||
continue
|
||||
}
|
||||
for _, v := range b.Values {
|
||||
if v.Op == OpIsInBounds || v.Op == OpIsSliceInBounds {
|
||||
if f.pass.debug > 0 {
|
||||
|
@ -477,9 +477,9 @@ var passes = [...]pass{
|
||||
{name: "dead auto elim", fn: elimDeadAutosGeneric},
|
||||
{name: "sccp", fn: sccp},
|
||||
{name: "generic deadcode", fn: deadcode, required: true}, // remove dead stores, which otherwise mess up store chain
|
||||
{name: "check bce", fn: checkbce},
|
||||
{name: "branchelim", fn: branchelim},
|
||||
{name: "late fuse", fn: fuseLate},
|
||||
{name: "check bce", fn: checkbce},
|
||||
{name: "dse", fn: dse},
|
||||
{name: "memcombine", fn: memcombine},
|
||||
{name: "writebarrier", fn: writebarrier, required: true}, // expand write barrier ops
|
||||
|
27
test/fixedbugs/issue67329.go
Normal file
27
test/fixedbugs/issue67329.go
Normal file
@ -0,0 +1,27 @@
|
||||
// errorcheck -0 -d=ssa/check_bce/debug=1
|
||||
|
||||
// Copyright 2024 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 x
|
||||
|
||||
func Found(x []string) string {
|
||||
switch len(x) {
|
||||
default:
|
||||
return x[0]
|
||||
case 0, 1:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func NotFound(x []string) string {
|
||||
switch len(x) {
|
||||
default:
|
||||
return x[0]
|
||||
case 0:
|
||||
return ""
|
||||
case 1:
|
||||
return ""
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user