Skip to content

cmd/compile: missing DWARF location lists for return values #50990

@michael-obermueller

Description

@michael-obermueller

What version of Go are you using (go version)?

$ go version
go version go1.18beta2 windows/amd64

Does this issue reproduce with the latest release?

With Go1.17.6, DWARF entries for return values of optimized functions were not available at all due to related issue #48573

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\...\AppData\Local\go-build
set GOENV=C:\Users\...\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\...\go\pkg\mod
set GONOPROXY=...
set GONOSUMDB=...
set GOOS=windows
set GOPATH=C:\Users\...\go
set GOPRIVATE=...
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\...\sdk\go1.18beta2
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\...\sdk\go1.18beta2\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.18beta2
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\workspaces\test\go.mod
set GOWORK=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\...\AppData\Local\Temp\go-build1425766270=/tmp/go-build -gno-record-gcc-switches
GOROOT/bin/go version: go version go1.18beta2 windows/amd64
GOROOT/bin/go tool compile -V: compile version go1.18beta2

What did you do?

Build an application with the Go 1.18beta2 toolchain using the command go build Main.go (optimized binary):

package main

func main() {
	_, _, _ = testFunc(1,2,3)
}

//go:noinline
func testFunc(a, b, c int) (d int, e int, f int) {
	return c, b, a
}
Disassembly of `main.testFunc`
0000000000459d40 <main.testFunc>:
  459d40:	48 89 c2          mov    %rax,%rdx
  459d43:	48 89 c8          mov    %rcx,%rax
  459d46:	48 89 d1          mov    %rdx,%rcx
  459d49:	c3                   	retq 

What did you expect to see?

DWARF location lists for function return values:

Example for return value `d`
 <2><3f794>: Abbrev Number: 17 (DW_TAG_formal_parameter)
    <3f795>   DW_AT_name        : d
    <3f797>   DW_AT_variable_parameter: 1
    <3f798>   DW_AT_decl_line   : 8
    <3f799>   DW_AT_type        : <0x40055>
    <3f79d>   DW_AT_location    : 0x<loclist addr> (location list)
...
    <loclist addr> ffffffffffffffff 0000000000459d40 (base address)
    <loclist addr> <0000000000459d49> <0000000000459d49> (DW_OP_reg0 (rax))

What did you see instead?

Missing DWARF location lists for all function return values of main.testFunc:

DWARF data of main.testFunc

debug.txt

<1><3f747>: Abbrev Number: 3 (DW_TAG_subprogram)
    <3f748>   DW_AT_name        : main.testFunc
    <3f756>   DW_AT_low_pc      : 0x459d40
    <3f75e>   DW_AT_high_pc     : 0x459d4a
    <3f766>   DW_AT_frame_base  : 1 byte block: 9c 	(DW_OP_call_frame_cfa)
    <3f768>   DW_AT_decl_file   : 0x2
    <3f76c>   DW_AT_external    : 1
 <2><3f76d>: Abbrev Number: 18 (DW_TAG_formal_parameter)
    <3f76e>   DW_AT_name        : a
    <3f770>   DW_AT_variable_parameter: 0
    <3f771>   DW_AT_decl_line   : 8
    <3f772>   DW_AT_type        : <0x40055>
    <3f776>   DW_AT_location    : 0x68d4f (location list)
 <2><3f77a>: Abbrev Number: 18 (DW_TAG_formal_parameter)
    <3f77b>   DW_AT_name        : b
    <3f77d>   DW_AT_variable_parameter: 0
    <3f77e>   DW_AT_decl_line   : 8
    <3f77f>   DW_AT_type        : <0x40055>
    <3f783>   DW_AT_location    : 0x68d82 (location list)
 <2><3f787>: Abbrev Number: 18 (DW_TAG_formal_parameter)
    <3f788>   DW_AT_name        : c
    <3f78a>   DW_AT_variable_parameter: 0
    <3f78b>   DW_AT_decl_line   : 8
    <3f78c>   DW_AT_type        : <0x40055>
    <3f790>   DW_AT_location    : 0x68db5 (location list)
 <2><3f794>: Abbrev Number: 17 (DW_TAG_formal_parameter)
    <3f795>   DW_AT_name        : d
    <3f797>   DW_AT_variable_parameter: 1
    <3f798>   DW_AT_decl_line   : 8
    <3f799>   DW_AT_type        : <0x40055>
    <3f79d>   DW_AT_location    : 0 byte block: 	()
 <2><3f79e>: Abbrev Number: 17 (DW_TAG_formal_parameter)
    <3f79f>   DW_AT_name        : e
    <3f7a1>   DW_AT_variable_parameter: 1
    <3f7a2>   DW_AT_decl_line   : 8
    <3f7a3>   DW_AT_type        : <0x40055>
    <3f7a7>   DW_AT_location    : 0 byte block: 	()
 <2><3f7a8>: Abbrev Number: 17 (DW_TAG_formal_parameter)
    <3f7a9>   DW_AT_name        : f
    <3f7ab>   DW_AT_variable_parameter: 1
    <3f7ac>   DW_AT_decl_line   : 8
    <3f7ad>   DW_AT_type        : <0x40055>
    <3f7b1>   DW_AT_location    : 0 byte block: 	()

I have checked many functions of optimized binaries, for all of them I can see the same problem.
Thanks

Metadata

Metadata

Assignees

Labels

NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Status

Triage Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions