Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/go/ssa: wrong ssa referrers with ifstmt #25946

Open
nabice opened this Issue Jun 18, 2018 · 2 comments

Comments

Projects
None yet
4 participants
@nabice
Copy link

nabice commented Jun 18, 2018

Please answer these questions before submitting your issue. Thanks!

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

go version go1.10.2 linux/amd64

Does this issue reproduce with the latest release?

yes

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/nabice/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/nabice/go:/home/nabice/skygo/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build010669814=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Package: golang.org/x/tools/go/ssa
ok.Referrers do not contains Ifstmt
https://play.golang.org/p/wkERfEjeSu1

I found it is replaced here:
https://github.com/golang/tools/blob/e10d6c9a84802dced65cb0278773be159bb7ed07/go/ssa/blockopt.go#L89

What did you expect to see?

ok.Referrers contain Ifstmt's cond -- "ok"

What did you see instead?

wrong

@gbbr gbbr changed the title Wrong ssa referrers with ifstmt x/tools/go/ssa: wrong ssa referrers with ifstmt Jun 18, 2018

@gopherbot gopherbot added this to the Unreleased milestone Jun 18, 2018

@josharian

This comment has been minimized.

Copy link
Contributor

josharian commented Jun 18, 2018

@alandonovan

This comment has been minimized.

Copy link
Contributor

alandonovan commented Jun 18, 2018

The jumpThreading optimization simplifies degenerate if statements, effectively entirely eliminating the one below:

   cond = ...
   if cond {
   } else {
   }

leaving only the evaluation of the condition, but not its referrers.

This would be a sound code transformation in a compiler, but because go/ssa strives to stay close to the source code, perhaps it must forego this optimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.