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
Open

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

nabice opened this issue Jun 18, 2018 · 2 comments
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@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
Copy link
Contributor

@alandonovan

@alandonovan
Copy link
Contributor

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.

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants