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: functions using ellipsis arguments are not inlined #18361

Closed
brtzsnr opened this issue Dec 17, 2016 · 4 comments
Closed

cmd/compile: functions using ellipsis arguments are not inlined #18361

brtzsnr opened this issue Dec 17, 2016 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Performance
Milestone

Comments

@brtzsnr
Copy link
Contributor

brtzsnr commented Dec 17, 2016

I have two functions foo and bar that have identical bodies except that foo uses ellipsis and bar uses arrays. bar is inlined while foo is not. This is a performance bug, not a correctness one.

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

tip:
go version devel +1106512 Fri Dec 16 22:30:12 2016 +0000 linux/amd64

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

Linux / Amd64

What did you do?

https://play.golang.org/p/EP4LSzd9X3

Generated code contains no call to bar, but a call to foo.

TEXT main.main(SB) /home/mosoi/src/trash/a.go
        a.go:35 0x44cfb0        64488b0c25f8ffffff      FS MOVQ FS:0xfffffff8, CX               
        a.go:35 0x44cfb9        483b6110                CMPQ 0x10(CX), SP                       
        a.go:35 0x44cfbd        7668                    JBE 0x44d027                            
        a.go:35 0x44cfbf        4883ec58                SUBQ $0x58, SP                          
        a.go:35 0x44cfc3        48896c2450              MOVQ BP, 0x50(SP)                       
        a.go:35 0x44cfc8        488d6c2450              LEAQ 0x50(SP), BP                       
        a.go:36 0x44cfcd        488b05cc2b0200          MOVQ 0x22bcc(IP), AX                    
        a.go:36 0x44cfd4        4889442420              MOVQ AX, 0x20(SP)                       
        a.go:36 0x44cfd9        0f1005c82b0200          MOVUPS 0x22bc8(IP), X0                  
        a.go:36 0x44cfe0        0f11442428              MOVUPS X0, 0x28(SP)                     
        a.go:36 0x44cfe5        488d442420              LEAQ 0x20(SP), AX                       
        a.go:36 0x44cfea        48890424                MOVQ AX, 0(SP)                          
        a.go:36 0x44cfee        48c744240803000000      MOVQ $0x3, 0x8(SP)                      
        a.go:36 0x44cff7        48c744241003000000      MOVQ $0x3, 0x10(SP)                     
        a.go:36 0x44d000        e85bffffff              CALL main.foo(SB)                       
        a.go:38 0x44d005        488b05b42b0200          MOVQ 0x22bb4(IP), AX                    
        a.go:38 0x44d00c        4889442438              MOVQ AX, 0x38(SP)                       
        a.go:38 0x44d011        0f1005b02b0200          MOVUPS 0x22bb0(IP), X0                  
        a.go:38 0x44d018        0f11442440              MOVUPS X0, 0x40(SP)                     
        a.go:39 0x44d01d        488b6c2450              MOVQ 0x50(SP), BP                       
        a.go:39 0x44d022        4883c458                ADDQ $0x58, SP                          
        a.go:39 0x44d026        c3                      RET                                     
        a.go:35 0x44d027        e88485ffff              CALL runtime.morestack_noctxt(SB)       
        a.go:35 0x44d02c        eb82                    JMP main.main(SB)                       

What did you expect to see?

foo (using ellipsis) and bar (using arrays) inlined

What did you see instead?

Only bar was inlined.

@ALTree
Copy link
Member

ALTree commented Dec 17, 2016

#9337 is also about the inlining of variadic functions (among other things), which currently are only inlined with -l -l -l.

@bradfitz bradfitz changed the title Functions using ellipsis arguments are not inlined cmd/compile: functions using ellipsis arguments are not inlined Dec 17, 2016
@bradfitz bradfitz added this to the Go1.9Maybe milestone Dec 17, 2016
@JayNakrani
Copy link
Contributor

JayNakrani commented Dec 17, 2016

This looks intentional for -l < 3.

@ulikunitz
Copy link
Contributor

The comment in inl.go says that additional -l levels may be buggy.

@davidlazar davidlazar self-assigned this Feb 24, 2017
@bradfitz bradfitz modified the milestones: Go1.10, Go1.9Maybe Jun 29, 2017
@bradfitz bradfitz added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 29, 2017
@bradfitz bradfitz modified the milestones: Go1.10, Go1.11 Nov 28, 2017
@ALTree
Copy link
Member

ALTree commented Mar 13, 2018

Fixed by 09d4455

@ALTree ALTree closed this as completed Mar 13, 2018
@golang golang locked and limited conversation to collaborators Mar 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Performance
Projects
None yet
Development

No branches or pull requests

7 participants