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: remove unnecessary inline marks #31116

Open
mariecurried opened this issue Mar 28, 2019 · 4 comments
Open

cmd/compile: remove unnecessary inline marks #31116

mariecurried opened this issue Mar 28, 2019 · 4 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. Performance
Milestone

Comments

@mariecurried
Copy link

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_pc10

Back in version go1.11, the code produced was a bare return, as I was initially expecting.

@randall77
Copy link
Contributor

This looks like the added inline mark prevents the removal of the branch.
Inline marks are used to get correct backtraces during panics, even in the presence of inlining.

There's probably a way to remove unnecessary inline marks in cases like this.

@randall77 randall77 changed the title cmd/compile: double jump generated for simple code cmd/compile: remove unnecessary inline marks Mar 28, 2019
@randall77 randall77 added this to the Unplanned milestone Mar 28, 2019
@mariecurried
Copy link
Author

mariecurried commented Mar 28, 2019

Bisected to 69c2c56, which makes sense.

@josharian
Copy link
Contributor

Possibly related: #20354

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 3, 2019
@mariecurried
Copy link
Author

The code mentioned in this issue has been fixed by c46ebec.
Should this remain open as an umbrella issue?

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
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. Performance
Projects
None yet
Development

No branches or pull requests

5 participants