-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Closed
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
What version of Go are you using (go version)?
$ go version go version devel +c4f87ed Tue Mar 26 02:20:09 2019 +0000 linux/amd64
Does this issue reproduce with the latest release?
Yes
What did you do?
I was playing around with the compiler to see what code it would produce under various situations.
After testing for a while, I found this case, where the code produced is a little weird:
package test
func test1() {
return
}
func test2(k *int) {
if k == nil {
test1()
}
}What did you expect to see?
I expected the test2 function to compile to a simple return.
What did you see instead?
Instead, the following code was generated (notice the weird double jump):
movq "".k+8(SP), AX
pcdata $2, $0
testq AX, AX
jeq test2_pc11
test2_pc10:
pcdata $2, $-2
pcdata $0, $-2
ret
test2_pc11:
pcdata $2, $0
pcdata $0, $1
xchgl AX, AX
jmp test2_pc10Back in version go1.11, the code produced was a bare return, as I was initially expecting.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.