Skip to content

cmd/compile/internal/ssa: occurred the wrong rewrite cycle detection #51639

@orisano

Description

@orisano

What version of Go are you using (go version)?

$ go version
go version go1.18rc1 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/orisano/Library/Caches/go-build"
GOENV="/Users/orisano/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/orisano/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/orisano/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/orisano/sdk/go1.18rc1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/orisano/sdk/go1.18rc1/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18rc1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/orisano/tmp/repro/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/5s/d4b31rld7l7d1169gfk7cfl80000gn/T/go-build2915424394=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

https://go.dev/play/p/sw3yvtCuPYW?v=gotip

I tried to build this program with -gcflags='-d "ssa/opt/debug=2"'

What did you expect to see?

debug logs.

What did you see instead?

$ go build -gcflags='-d "ssa/opt/debug=2"'
# repro
opt: rewriting for f
rewriting v13 = Convert <unsafe.Pointer> v12 v1  ->  v13 = AddPtr <unsafe.Pointer> v7 v8
./a.go:6:56: internal compiler error: 'f': rewrite cycle detected

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new

Note

I investigated the cause of this issue.
it only rewrote rewriting v13 = Convert <unsafe.Pointer> v12 v1 -> v13 = AddPtr <unsafe.Pointer> v7 v8 on the 1st step.
and then calculate the hash of this function, store it to the states.
on the 2nd step, it only proceeded to remove dead values.

if v.Uses == 0 && v.removeable() {
if v.Op != OpInvalid && deadcode == removeDeadValues {
// Reset any values that are now unused, so that we decrement
// the use count of all of its arguments.
// Not quite a deadcode pass, because it does not handle cycles.
// But it should help Uses==1 rules to fire.
v.reset(OpInvalid)
change = true
}
// No point rewriting values which aren't used.
continue
}

it calculated the hash of this function again, got the same result to trigger the rewrite cycle detected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions