Skip to content

cmd/compile: wrong line number for instruction (go-tip) #42801

@aarzilli

Description

@aarzilli

This only applies to go 1.16 built from tip, specifically:

$ go version
go version devel +d902791b50 Mon Nov 23 05:57:35 2020 +0000 linux/amd64

The following function

func sleepytime() { // <- this is line 9
	time.Sleep(5 * time.Millisecond)
}

Compiled with -gcflags='-N -l' results in:

TEXT main.sleepytime(SB) .../delve/_fixtures/testnextprog.go
  testnextprog.go:9	0x4973c0		64488b0c25f8ffffff	MOVQ FS:0xfffffff8, CX			
  testnextprog.go:9	0x4973c9		483b6110		CMPQ 0x10(CX), SP			
  testnextprog.go:9	0x4973cd		7625			JBE 0x4973f4				
  testnextprog.go:9	0x4973cf		4883ec10		SUBQ $0x10, SP				
  testnextprog.go:9	0x4973d3		48896c2408		MOVQ BP, 0x8(SP)			
  testnextprog.go:9	0x4973d8		488d6c2408		LEAQ 0x8(SP), BP			
  testnextprog.go:11	0x4973dd		48c70424404b4c00	MOVQ $0x4c4b40, 0(SP)			
  testnextprog.go:10	0x4973e5		e8f69ffcff		CALL time.Sleep(SB)			
  testnextprog.go:11	0x4973ea		488b6c2408		MOVQ 0x8(SP), BP			
  testnextprog.go:11	0x4973ef		4883c410		ADDQ $0x10, SP				
  testnextprog.go:11	0x4973f3		c3			RET					
  testnextprog.go:9	0x4973f4		e827b2fcff		CALL runtime.morestack_noctxt(SB)	
  testnextprog.go:9	0x4973f9		ebc5			JMP main.sleepytime(SB)			

Instruction 0x4973dd is passing the argument of time.Sleep but get assigned the wrong line of source code (the closing brace) instead of the correct one (10). The is_stmt flag is also set on it (which would be a good thing if the line number was correct).

cc @dr2chase

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions