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:
Cuong Manh Le 2024-07-16 23:56:56 +07:00
parent 3f9360345c
commit 864aa86448
3 changed files with 31 additions and 1 deletions

View File

@ -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 {

View File

@ -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

View 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 ""
}
}