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

cmd/compile: output cost while inlining function with Debug['m'] > 1 #36780

Closed
TennyZhuang opened this issue Jan 26, 2020 · 3 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@TennyZhuang
Copy link
Contributor

TennyZhuang commented Jan 26, 2020

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

$ go version
go version go1.13 linux/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="/data/1/zty/.cache/go-build"
GOENV="/data/1/zty/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/data/1/zty/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/lib/golang"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/data/1/zty/rclone/contrib/tidb/go.mod"
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-build691466518=/tmp/go-build -gno-record-gcc-switches"

What did you do?

go build -gcflags=-m=2 .

If a function can not be inline, the error message will output the cost:

"%v: cannot inline %v: function too complex: cost %d exceeds budget %d\n"

But if a function is inlinable, only

%v: can inline %#v as: %#v { %#v }\n"

is output without cost. The behavior is not very consistent, and the cost info is also useful to user who try to optimize his code.

What did you expect to see?

%v: can inline %#v with cost %d as: %#v { %#v }\n"

What did you see instead?

%v: can inline %#v as: %#v { %#v }\n"
@TennyZhuang
Copy link
Contributor Author

If the debug info improvement make sense, I'd like to submit a PR.

@josharian
Copy link
Contributor

Sounds fine to me. Feel free to send a change. Note that we are in the code freeze now, so it won’t be reviewed and/or submitted until Go 1.14 is released.

@gopherbot
Copy link

Change https://golang.org/cl/216778 mentions this issue: cmd/compile: output cost while inlining function with Debug['m'] > 1

@cagedmantis cagedmantis added this to the Backlog milestone Feb 3, 2020
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 3, 2020
@golang golang locked and limited conversation to collaborators Feb 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants