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
marigonzes opened this issue Mar 28, 2019 · 4 comments

Comments

@marigonzes
Copy link

commented Mar 28, 2019

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

This comment has been minimized.

Copy link
Contributor

commented Mar 28, 2019

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

@marigonzes

This comment has been minimized.

Copy link
Author

commented Mar 28, 2019

Bisected to 69c2c56, which makes sense.

@josharian

This comment has been minimized.

Copy link
Contributor

commented Mar 28, 2019

Possibly related: #20354

@marigonzes

This comment has been minimized.

Copy link
Author

commented Jul 29, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.