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: assembly listing (-S flag) reports "<unknown line number>" #16214

Closed
ALTree opened this issue Jun 29, 2016 · 6 comments
Closed

cmd/compile: assembly listing (-S flag) reports "<unknown line number>" #16214

ALTree opened this issue Jun 29, 2016 · 6 comments

Comments

@ALTree
Copy link
Member

ALTree commented Jun 29, 2016

Code:

package foo

func Mod32(x uint32) uint32 {
    return x % 3
}

func Mod64(x uint64) uint64 {
    return x % 3
}

build -gcflags -S, on tip, outputs:

"".Mod32 t=1 size=27 args=0x10 locals=0x0
    [cut]
    0x0000 00000 (/home/alberto/Desktop/rand.go:3)  FUNCDATA    $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
    0x0000 00000 (/home/alberto/Desktop/rand.go:4)  MOVL    "".x+8(FP), AX
    0x0004 00004 (<unknown line number>)    MOVL    $-1431655765, CX
    0x0009 00009 (/home/alberto/Desktop/rand.go:4)  MULL    CX
    0x000b 00011 (/home/alberto/Desktop/rand.go:4)  SHRL    $1, DX
    [cut]

"".Mod64 t=1 size=34 args=0x10 locals=0x0
    [cut]
    0x0000 00000 (/home/alberto/Desktop/rand.go:7)  FUNCDATA    $0, gclocals·23e8278e2b69a3a75fa59b23c49ed6ad(SB)
    0x0000 00000 (/home/alberto/Desktop/rand.go:7)  FUNCDATA    $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
    0x0000 00000 (/home/alberto/Desktop/rand.go:8)  MOVQ    $-6148914691236517205, AX
    0x000a 00010 (/home/alberto/Desktop/rand.go:8)  MOVQ    "".x+8(FP), CX
    0x000f 00015 (/home/alberto/Desktop/rand.go:8)  MULQ    CX
    [cut]

note the <unknown line number> in the Mod32 disassembly. Note that Mod64 is fine.

This is an SSA regression: on go1.6.2, and on tip with -ssa=0, every instruction gets its own line number.

@ALTree ALTree changed the title cmd/compile: assembly listing (-S flags) reports "<unknown line number>" cmd/compile: assembly listing (-S flag) reports "<unknown line number>" Jun 29, 2016
@ALTree
Copy link
Member Author

ALTree commented Jun 29, 2016

gotip build -a -gcflags -S std

and then grepping for "<unknown line number>" returns 1927 matches on tip, and 0 matches on tip with SSA disabled.

@bradfitz
Copy link
Contributor

@bradfitz bradfitz added this to the Go1.7Maybe milestone Jun 29, 2016
@bradfitz
Copy link
Contributor

Go1.7Maybe if the fix is easy and non-invasive?

@cherrymui
Copy link
Member

The large constant in Mod32 is generated by the frontend, the node of which has line number 0. The constant in Mod64 is generated by SSA optimization, where the line number propagates through. In the legacy backend, if we set the line number to 0, it does not change lineno (cmd/compile/internal/gc/subr.go:/setlineno). Maybe we can do the same in pushLine when building SSA?

@cherrymui
Copy link
Member

Mailed http://golang.org/cl/24641. Not really sure about it though.

@gopherbot
Copy link

CL https://golang.org/cl/24641 mentions this issue.

@golang golang locked and limited conversation to collaborators Jul 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants