Skip to content

cmd/compile: some case can be inlined before unified ir(go1.19-), but can't be inilned after unified ir(go1.20+)  #63687

@peter-xiao

Description

@peter-xiao

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions