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

marigonzes opened this Issue Mar 28, 2019 · 3 comments


None yet
4 participants
Copy link

marigonzes 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?


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() {

func test2(k *int) {
    if k == nil {

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
        pcdata  $2, $-2
        pcdata  $0, $-2
        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.


This comment has been minimized.

Copy link

randall77 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


This comment has been minimized.

Copy link

marigonzes commented Mar 28, 2019

Bisected to 69c2c56, which makes sense.


This comment has been minimized.

Copy link

josharian commented Mar 28, 2019

Possibly related: #20354

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