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: some case can be inlined before unified ir(go1.19-), but can't be inilned after unified ir(go1.20+) #63687

Open
peter-xiao opened this issue Oct 23, 2023 · 3 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@peter-xiao
Copy link

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

$ go version
devel go1.22-126db88cc8 Fri Oct 20 16:12:52 2023 +0800

Does this issue reproduce with the latest release?

// a.go
package a

type A struct {
}

func (*A) Print() {
}
// b.go
package b

import "./a"

var B *a.A
}
// main.go
package main

import "./b"

func main() {
	b.B.Print()
}

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

go env Output
$ go env

GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/bytedance/Library/Caches/go-build'
GOENV='/Users/bytedance/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/bytedance/gopackage/pkg/mod'
GONOPROXY='.byted.org,.everphoto.cn,git.smartisan.com'
GONOSUMDB='.byted.org,.everphoto.cn,git.smartisan.com'
GOOS='darwin'
GOPATH='/Users/bytedance/gopackage'
GOPRIVATE='.byted.org,.everphoto.cn,git.smartisan.com'
GOPROXY='https://goproxy.byted.org|https://goproxy.cn|direct'
GOROOT='/Users/bytedance/go_google'
GOSUMDB=''
GOTMPDIR=''
GOTOOLCHAIN=''
GOTOOLDIR='/Users/bytedance/go_google/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='devel go1.22-126db88cc8 Fri Oct 20 16:12:52 2023 +0800'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/b1/0fd1b6hs7lz0fm_mh346lybm0000gn/T/go-build831658170=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

go build -gcflags="-m"

What did you expect to see?

./main.go:5:6: can inline main
./main.go:6:11: inlining call to a.(*A).Print

What did you see instead?

./main.go:5:6: can inline main
@gopherbot
Copy link

Change https://go.dev/cl/537035 mentions this issue: cmd/compile: import methods which is exported in another package but not used and make more functions inlined

@seankhliao seankhliao changed the title inline: some case can be inlined before unified ir(go1.19-), but can't be inilned after unified ir(go1.20+) cmd/compile:: some case can be inlined before unified ir(go1.19-), but can't be inilned after unified ir(go1.20+) Oct 23, 2023
@seankhliao seankhliao changed the title cmd/compile:: some case can be inlined before unified ir(go1.19-), but can't be inilned after unified ir(go1.20+) cmd/compile: some case can be inlined before unified ir(go1.19-), but can't be inilned after unified ir(go1.20+) Oct 23, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Oct 23, 2023
@dr2chase
Copy link
Contributor

@mdempsky can you give this a look? I'd swear I had heard about this bug before in some other context, and that perhaps there was something subtle involved in the fix. OTOH, maybe I remember wrong.

@dr2chase dr2chase added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 23, 2023
@peter-xiao
Copy link
Author

Could you please help review the patch?

@mknyszek mknyszek added this to the Backlog milestone Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Development

No branches or pull requests

4 participants