aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/dwarfgen
AgeCommit message (Collapse)Author
2021-08-18cmd/compile/internal/dwarfgen: use src.Pos.Rel{Filename,Line,Col} consistentlyMatthew Dempsky
It appears that this code predates golang.org/cl/96535, which added RelCol to support /*line*/ directives. Change-Id: Ib79cebc1be53af706e84e8799eeea81ef8c81c8b Reviewed-on: https://go-review.googlesource.com/c/go/+/343430 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2021-05-24cmd/compile: record regabi status in DW_AT_producerAlessandro Arzilli
Records if regabi was enabled during compilation in the DW_AT_producer attribute of each compile unit. This is useful to debuggers that support the debugCall protocol. Change-Id: I5ad2c48ebf126aeb8bfb459b53a1a5304550036a Reviewed-on: https://go-review.googlesource.com/c/go/+/318050 Trust: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-05-13cmd/compile/internal/dwarfgen: fix DWARF param DIE orderingThan McIntosh
The DWARF standard requires that the DIEs in a subprogram corresponding to input and output parameters appear in declaration order; this patch adds some new code in dwarfgen to enforce this ordering (relying on the existing fn.Dcl ordering is not sufficient). Prior to the register ABI, it was easy to keep vars/decls sorted during DWARF generation since you could always rely on frame offset; with the ABI sorting by frame offset no longer gives you the original declaration order in all cases. Fixes #46055. Change-Id: I0e070cb781d6453caba896e5d3bee7cd5388050d Reviewed-on: https://go-review.googlesource.com/c/go/+/318829 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-05-03cmd/compile: preserve argument order in debug_infoAlessandro Arzilli
When regabi is used sorting by stack offset will not preserve the order of function arguments. Trust that variables are already ordered correctly when creating debug_info entries. Fixes #45720 Change-Id: I1dbdd185975273f70244a23302d34f082347603d Reviewed-on: https://go-review.googlesource.com/c/go/+/315280 Reviewed-by: Than McIntosh <thanm@google.com> Trust: Jeremy Faller <jeremy@golang.org>
2021-04-30cmd/compile: fix abbrev selection for output paramsThan McIntosh
In Cl 302071 we changed the compiler to use a different recipe for selecting the DWARF frame offset for output parameters, to reflect the fact that registerized output params don't have a stack memory location on entry to the function. In the process, however, we switched from using an abbrev pf DW_ABRV_PARAM to an abbrev of DW_ABRV_AUTO, which means that Delve can't recognize them correctly. To fix the problem, switch back to picking the correct abbrev entry, while leaving the new offset recipe intact. Updates #40724. Updates #45720. Change-Id: If721c9255bcd030177806576cde3450563f7a235 Reviewed-on: https://go-review.googlesource.com/c/go/+/315610 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-30cmd/compile: regabi support for DWARF location expressionsThan McIntosh
Revise the code that generates DWARF location expressions for input parameters to get it to work properly with the new register ABI when optimization is turned off. The previously implementation assumed stack locations for all input+output parameters when -N (disable optimization) was in effect. In the new implementation, a register-resident input parameter is given a 2-element location list, the first list element pointing to the ABI register(s) containing the param, and the second element pointing to the stack home once it has been spilled. NB, this change fixes a bunch of the Delve pkg/proc unit tests (maybe about half of the outstanding failures). Still a good number that need to be investigated, however. Updates #40724. Updates #45720. Change-Id: I743bbb9af187bcdebeb8e690fdd6db58094ca415 Reviewed-on: https://go-review.googlesource.com/c/go/+/314431 Trust: Than McIntosh <thanm@google.com> Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
2021-04-16internal/buildcfg: move build configuration out of cmd/internal/objabiRuss Cox
The go/build package needs access to this configuration, so move it into a new package available to the standard library. Change-Id: I868a94148b52350c76116451f4ad9191246adcff Reviewed-on: https://go-review.googlesource.com/c/go/+/310731 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-14cmd/compile: rescue stmt boundaries from OpArgXXXReg and OpSelectN.David Chase
Fixes this failure: go test cmd/compile/internal/ssa -run TestStmtLines -v === RUN TestStmtLines stmtlines_test.go:115: Saw too many (amd64, > 1%) lines without statement marks, total=88263, nostmt=1930 ('-run TestStmtLines -v' lists failing lines) The failure has two causes. One is that the first-line adjuster in code generation was relocating "first lines" to instructions that would either not have any code generated, or would have the statment marker removed by a different believed-good heuristic. The other was that statement boundaries were getting attached to register values (that with the old ABI were loads from the stack, hence real instructions). The register values disappear at code generation. The fixes are to (1) note that certain instructions are not good choices for "first value" and skip them, and (2) in an expandCalls post-pass, look for register valued instructions and under appropriate conditions move their statement marker to a compatible use. Also updates TestStmtLines to always log the score, for easier comparison of minor compiler changes. Updates #40724. Change-Id: I485573ce900e292d7c44574adb7629cdb4695c3f Reviewed-on: https://go-review.googlesource.com/c/go/+/309649 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-18cmd: move experiment flags into objabi.ExperimentAustin Clements
This moves all remaining GOEXPERIMENT flags into the objabi.Experiment struct, drops the "_enabled" from their name, and makes them all bool typed. We also drop DebugFlags.Fieldtrack because the previous CL shifted the one test that used it to use GOEXPERIMENT instead. Change-Id: I3406fe62b1c300bb4caeaffa6ca5ce56a70497fe Reviewed-on: https://go-review.googlesource.com/c/go/+/302389 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-03-16cmd/compile: (fixed) spill output parameters passed in registers as autosDavid Chase
Repair of CL 300749. ALSO: found evidence that stack maps for bodyless methods are wrong. gofmt in test/abi removed never-executed code in types/size.go Updates #44816. Updates #40724. Change-Id: Ifeb5fee60f60e7c7b58ee0457f58a3265d6cf3f6 Reviewed-on: https://go-review.googlesource.com/c/go/+/302071 Trust: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-15Revert "cmd/compile: spill output parameters passed in registers as autos"David Chase
This reverts commit 8ed438c077d82c4b4662c327dbbdb3c64e7547ca, CL 300749. Reason for revert: Looks like it crashes on link-register architectures Change-Id: I0c261df58900008cada3359889d2a87508158447 Reviewed-on: https://go-review.googlesource.com/c/go/+/302053 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-15cmd/compile: spill output parameters passed in registers as autosDavid Chase
ALSO: found evidence that stack maps for bodyless methods are wrong. gofmt in test/abi removed never-executed code in types/size.go Updates #44816. Change-Id: I658c33f049337fb6f1e625f0c55430d25bfa877e Reviewed-on: https://go-review.googlesource.com/c/go/+/300749 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-02-21cmd/compile: fix panic in DWARF-gen handling obfuscated codeThan McIntosh
DWARF generation uses variable source positions (file/line/col) as a way to uniquely identify locals and parameters, as part of the process of matching up post-optimization variables with the corresponding pre-optimization versions (since the DWARF needs to be in terms of the original source constructs). This strategy can run into problems when compiling obfuscated or machine-generated code, where you can in some circumstances wind up with two local variables that appear to have the same name, file, line, and column. This patch changes DWARF generation to skip over such duplicates as opposed to issuing a fatal error (if an obfuscation tool is in use, it is unlikely that a human being will be able to make much sense of DWARF info in any case). Fixes #44378. Change-Id: I198022d184701aa9ec3dce42c005d29b72d2e321 Reviewed-on: https://go-review.googlesource.com/c/go/+/294289 TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com>
2021-02-19cmd/compile: fix buglet in inlined info abstract function dwarf-genThan McIntosh
When generating DWARF inlined info records, it's possible to have a local function whose only callsites are inlined away, meaning that we emit an abstract function DIE but no regular subprogram DIE. When emitting DWARF scope info we need to handle this case (specifically when scoping PCs, check for the case that the func in question has been entirely deleted). Fixes #44344. Change-Id: I9f5bc692f225aa4c5c23f7bd2e50bcf7fe4fc5f3 Reviewed-on: https://go-review.googlesource.com/c/go/+/293309 TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Russ Cox <rsc@golang.org> Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com>
2021-02-19runtime: enable framepointer on all arm64Russ Cox
Frame pointers were already enabled on linux, darwin, ios, but not freebsd, android, openbsd, netbsd. But the space was reserved on all platforms, leading to two different arm64 framepointer conditions in different parts of the code, one of which had no name (framepointer_enabled || GOARCH == "arm64", which might have been "framepointer_space_reserved"). So on the disabled systems, the stack layouts were still set up for frame pointers and the only difference was not actually maintaining the FP register in the generated code. Reduce complexity by just enabling the frame pointer completely on all the arm64 systems. This commit passes on freebsd, android, netbsd. I have not been able to try it on openbsd. This CL is part of a stack adding windows/arm64 support (#36439), intended to land in the Go 1.17 cycle. This CL is, however, not windows/arm64-specific. It is cleanup meant to make the port (and future ports) easier. Change-Id: I83bd23369d24b76db4c6a648fa74f6917819a093 Reviewed-on: https://go-review.googlesource.com/c/go/+/288814 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-01-25[dev.regabi] cmd/compile: backport changes from dev.typeparams (9456804)Matthew Dempsky
This CL backports a bunch of changes that landed on dev.typeparams, but are not dependent on types2 or generics. By backporting, we reduce the divergence between development branches, hopefully improving test coverage and reducing risk of merge conflicts. Updates #43866. Change-Id: I382510855c9b5fac52b17066e44a00bd07fe86f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/286172 Trust: Matthew Dempsky <mdempsky@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-01-21[dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet for dwarfBaokun Lee
Same as CL 284897, but for dwarf. Passes toolstash -cmp. Fixes #43819 Change-Id: Icbe43aa2e3cb96e6a6c318523c643247da8e4c74 Reviewed-on: https://go-review.googlesource.com/c/go/+/284899 Run-TryBot: Baokun Lee <bk@golangcn.org> Trust: Baokun Lee <bk@golangcn.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-19[dev.regabi] cmd/compile: refactor Linksym creationMatthew Dempsky
Currently there's a lot of logic within package types for creating Linksyms. This CL pulls it out into base, where it can be more easily reused by other compiler code that shouldn't need to depend on package types. Package base probably isn't the best place for this, but it's convenient because it's a package that types already depends on. It's also where the Ctxt object lives, which these functions depend upon. Passes toolstash -cmp w/ -gcflags=all=-abiwrap. Change-Id: I50d8b7e4596955205036969eab24d7dab053b363 Reviewed-on: https://go-review.googlesource.com/c/go/+/284231 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Trust: Matthew Dempsky <mdempsky@google.com>
2021-01-14[dev.regabi] cmd/compile: move more PAUTOHEAP to SSA constructionMatthew Dempsky
This CL moves almost all PAUTOHEAP handling code to SSA construction. Instead of changing Names to PAUTOHEAP, escape analysis now only sets n.Esc() to ir.EscHeap, and SSA handles creating the "&x" pseudo-variables and associating them via Heapaddr. This CL also gets rid of n.Stackcopy, which was used to distinguish the heap copy of a parameter used within a function from the stack copy used in the function calling convention. In practice, this is always obvious from context: liveness and function prologue/epilogue want to know about the stack copies, and everywhere else wants the heap copy. Hopefully moving all parameter/result handling into SSA helps with making the register ABI stuff easier. Also, the only remaining uses of PAUTOHEAP are now for closure variables, so I intend to rename it to PCLOSUREVAR or get rid of those altogether too. But this CL is already big and scary enough. Change-Id: Ief5ef6205041b9d0ee445314310c0c5a98187e77 Reviewed-on: https://go-review.googlesource.com/c/go/+/283233 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com>
2021-01-05[dev.regabi] cmd/compile: add Name.Canonical and move ByvalMatthew Dempsky
There's a bunch of code that wants to map closure variables back to their original name, so add a single Name.Canonical method that they can all use. Also, move the Byval flag from being stored on individual closure variables to being stored on the canonical variable. Passes toolstash -cmp. Change-Id: Ia3ef81af5a15783d09f04b4e274ce33df94518e6 Reviewed-on: https://go-review.googlesource.com/c/go/+/281541 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-01-04[dev.regabi] cmd/compile: remove Name.Class_ accessorsMatthew Dempsky
These aren't part of the Node interface anymore, so no need to keep them around. Passes toolstash -cmp. [git-generate] cd src/cmd/compile/internal/ir : Fix one off case that causes trouble for rf. sed -i -e 's/n.SetClass(ir.PAUTO)/n.Class_ = ir.PAUTO/' ../ssa/export_test.go pkgs=$(go list . ../...) rf ' ex '"$(echo $pkgs)"' { var n *Name var c Class n.Class() -> n.Class_ n.SetClass(c) -> n.Class_ = c } rm Name.Class rm Name.SetClass mv Name.Class_ Name.Class ' Change-Id: Ifb304bf4691a8c455456aabd8aa77178d4a49500 Reviewed-on: https://go-review.googlesource.com/c/go/+/281294 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-01-01[dev.regabi] cmd/compile: simplify dwarfgen.declPosMatthew Dempsky
The previous code was way overcomplicating things. To find out if a variable is a closure pseudo-variable, one only needs to check IsClosureVar. Checking Captured and Byval are only meant to be used by closure conversion. Passes toolstash -cmp. Change-Id: I22622cba36ba7f60b3275d17999a8b6bb7c6719a Reviewed-on: https://go-review.googlesource.com/c/go/+/280995 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-01-01[dev.regabi] cmd/compile: remove idempotent Name() calls [generated]Matthew Dempsky
[git-generate] cd src/cmd/compile/internal/ir pkgs=$(grep -l -w Name ../*/*.go | xargs dirname | sort -u | grep -v '/ir$') rf ' ex . '"$(echo $pkgs)"' { var n *Name n.Name() -> n } ' Change-Id: I6bfce6417a6dba833d2f652ae212a32c11bc5ef6 Reviewed-on: https://go-review.googlesource.com/c/go/+/280972 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
2020-12-29[dev.regabi] cmd/compile: rewrite to use linksym helpers [generated]Matthew Dempsky
Passes toolstash -cmp. [git-generate] cd src/cmd/compile/internal/gc pkgs=$(grep -l -w Linksym ../*/*.go | xargs dirname | grep -v '/gc$' | sort -u) rf ' ex . '"$(echo $pkgs)"' { import "cmd/compile/internal/ir" import "cmd/compile/internal/reflectdata" import "cmd/compile/internal/staticdata" import "cmd/compile/internal/types" avoid reflectdata.TypeLinksym avoid reflectdata.TypeLinksymLookup avoid reflectdata.TypeLinksymPrefix avoid staticdata.FuncLinksym var f *ir.Func var n *ir.Name var s string var t *types.Type f.Sym().Linksym() -> f.Linksym() n.Sym().Linksym() -> n.Linksym() reflectdata.TypeSym(t).Linksym() -> reflectdata.TypeLinksym(t) reflectdata.TypeSymPrefix(s, t).Linksym() -> reflectdata.TypeLinksymPrefix(s, t) staticdata.FuncSym(n.Sym()).Linksym() -> staticdata.FuncLinksym(n) types.TypeSymLookup(s).Linksym() -> reflectdata.TypeLinksymLookup(s) } ' Change-Id: I7a3ae1dcd61bcdf4a29f708ff12f7f80c2b280c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/280640 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-12-23[dev.regabi] cmd/compile: split out package dwarfgen [generated]Russ Cox
[git-generate] cd src/cmd/compile/internal/gc rf ' # Inline and remove ngotype. ex { import "cmd/compile/internal/ir" import "cmd/compile/internal/reflectdata" var n ir.Node ngotype(n) -> reflectdata.TypeSym(n.Type()) } rm ngotype mv recordFlags RecordFlags mv recordPackageName RecordPackageName mv RecordFlags RecordPackageName dwarf.go mv debuginfo Info mv genAbstractFunc AbstractFunc mv scope.go scope_test.go dwarf.go dwinl.go cmd/compile/internal/dwarfgen ' Change-Id: I31fa982900dbba2066ca4c7a706af922e5481c70 Reviewed-on: https://go-review.googlesource.com/c/go/+/279477 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>