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: compiler generates calls to empty functions #4563

Closed
gopherbot opened this issue Dec 17, 2012 · 9 comments
Closed

cmd/compile: compiler generates calls to empty functions #4563

gopherbot opened this issue Dec 17, 2012 · 9 comments

Comments

@gopherbot
Copy link

by martisch@uos.de:

http://play.golang.org/p/NDxhDNrRC7
empty (assembler) test function is inlined

--- prog list "test" ---
0000 (/Users/martisch/test.go:3) TEXT    test+0(SB),$0-0
0001 (/Users/martisch/test.go:6) RET     ,

--- prog list "main" ---
0002 (/Users/martisch/test.go:8) TEXT    main+0(SB),$0-0
0003 (/Users/martisch/test.go:10) RET     ,


but here:

http://play.golang.org/p/Nyd_WLfObv
empty (assembler) test function gets called and is not inlined

--- prog list "test" ---
0000 (/Users/martisch/test.go:3) TEXT    test+0(SB),$40-0
0001 (/Users/martisch/test.go:7) RET     ,

--- prog list "main" ---
0002 (/Users/martisch/test.go:9) TEXT    main+0(SB),$0-0
0003 (/Users/martisch/test.go:10) CALL    ,test+0(SB)
0004 (/Users/martisch/test.go:11) RET     ,

What is the expected output?
I would assume as a basic optimization any empty function should get inlined or just no
call should be generated.

What do you see instead?
A call to an empty function is generated and the function is not inlined.

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
OS X 10.8.2

Which version are you using?  (run 'go version')
go version devel +111aa291b561 Mon Dec 17 12:01:00 2012 -0800 darwin/amd64
@minux
Copy link
Member

minux commented Dec 18, 2012

Comment 1:

the reason for this is that when inlining happens, it saw function test has a function
call in it,
so the inliner decided to not inline that function.
only in a latter phase did the compiler find out the function call in function test is
dead.
i think fixing this won't bring big perf. improvement so I label it Go1.1Maybe.

Labels changed: added priority-later, go1.1maybe, removed priority-triage, go1.1.

Status changed to Accepted.

@robpike
Copy link
Contributor

robpike commented Mar 7, 2013

Comment 2:

Labels changed: removed go1.1maybe.

@robpike
Copy link
Contributor

robpike commented May 18, 2013

Comment 3:

Labels changed: added go1.2maybe.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 4:

Labels changed: added go1.3, removed go1.2maybe.

@robpike
Copy link
Contributor

robpike commented Aug 20, 2013

Comment 5:

Labels changed: removed go1.3.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 6:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 7:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 8:

Labels changed: added repo-main.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc changed the title cmd/gc: compiler generates calls to empty functions cmd/compile: compiler generates calls to empty functions Jun 8, 2015
@randall77
Copy link
Contributor

This has been fixed for a while.
We now do whole subtree inlining, and dead code elimination.

@golang golang locked and limited conversation to collaborators Aug 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants