aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj/dwarf.go
AgeCommit message (Collapse)Author
2025-11-11std,cmd: go fix -any std cmdAlan Donovan
This change mechanically replaces all occurrences of interface{} by 'any' (where deemed safe by the 'any' modernizer) throughout std and cmd, minus their vendor trees. Since this fix is relatively numerous, it gets its own CL. Also, 'go generate go/types'. Change-Id: I14a6b52856c3291c1d27935409bca8d5fd4242a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/719702 Commit-Queue: Alan Donovan <adonovan@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Alan Donovan <adonovan@google.com>
2025-10-21all: eliminate unnecessary type conversionsJes Cok
Found by github.com/mdempsky/unconvert Change-Id: I88ce10390a49ba768a4deaa0df9057c93c1164de GitHub-Last-Rev: 3b0f7e8f74f58340637f33287c238765856b2483 GitHub-Pull-Request: golang/go#75974 Reviewed-on: https://go-review.googlesource.com/c/go/+/712940 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com>
2025-02-22cmd: initial compiler+linker support for DWARF5 .debug_addrThan McIntosh
This patch rolls the main .debug_info DWARF section from version 4 to version 5, and also introduces machinery in the Go compiler and linker for taking advantage of the DWARF5 ".debug_addr" section for subprogram DIE "high" and "low" PC attributes. All functionality is gated by GOEXPERIMENT=dwarf5. For the compiler portion of this patch, we add a new DIE attribute form "DW_FORM_addrx", which accepts as an argument a function (text) symbol. The dwarf "putattr" function is enhanced to handle this format by invoking a new dwarf context method "AddIndirectTextRef". Under the hood, this method invokes the Lsym method WriteDwTxtAddrx, which emits a new objabi.R_DWTXTADDR_* relocation. The size of the relocation is dependent on the number of functions in the package; we pick a size that is just big enough for the largest func index. In the linker portion of this patch, we now switch over to writing out a version number of 5 (instead of 4) in the compile unit header (this is required if we want to use addrx attributes). In the parallel portion of DWARF gen, within each compilation unit we scan subprogram DIEs to look for R_DWTXTADDR_* relocations, and when we find such a reloc, we assign a slot in the .debug_addr section for the func targeted. After the parallel portion is complete, we then walk through all of the compilation units to assign a value to their DW_AT_addr_base attribute, which points to the portion of the single .debug_addr section containing the text addrs for that compilation unit. Note that once this patch is in, programs built with GOEXPERIMENT=dwarf5 will have broken/damaged DWARF info; in particular, since we've changed only the CU and subprogram DIEs and haven't incorported the other changes mandated by DWARF5 (ex: .debug_ranges => .debug_rnglists) a lot of the variable location info will be missing/incorrect. This will obviously change in subsequent patches. Note also that R_DWTXTADDR_* can't be used effectively for lexical scope DIE hi/lo PC attrs, since there isn't a viable way to encode "addrx + constant" in the attribute value (you would need a new entry for each attr endpoint in .debug_addr, which would defeat the point). Updates #26379. Change-Id: I2dfc45c9a8333e7b2a58f8e3b88fc8701fefd006 Reviewed-on: https://go-review.googlesource.com/c/go/+/635337 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-11-07cmd/internal/objabi, cmd/link: introduce SymKind helper methodsRuss Cox
These will be necessary when we start using the new FIPS symbols. Split into a separate CL so that these refactoring changes can be tested separate from any FIPS-specific changes. Passes golang.org/x/tools/cmd/toolstash/buildall. Change-Id: I73e5873fcb677f1f572f0668b4dc6f3951d822bc Reviewed-on: https://go-review.googlesource.com/c/go/+/625996 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Russ Cox <rsc@golang.org>
2024-11-07cmd/internal/obj: replace obj.Addrel func with LSym.AddRel methodRuss Cox
The old API was to do r := obj.AddRel(sym) r.Type = this r.Off = that etc The new API is: sym.AddRel(ctxt, obj.Reloc{Type: this: Off: that, etc}) This new API is more idiomatic and avoids ever having relocations that are only partially constructed. Most importantly, it sets up for sym.AddRel being able to check relocation validity in the future. (Passing ctxt is for use in validity checking.) Passes golang.org/x/tools/cmd/toolstash/buildall. Change-Id: I042ea76e61bb3bf6402f98ca11291a13f4799972 Reviewed-on: https://go-review.googlesource.com/c/go/+/625616 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-09-03cmd: replace many sort.Interface with slices.Sort and SortFuncZxilly
with slices there's no need to implement sort.Interface Change-Id: I59167e78881cb1df89a71e33d738d6aeca7adb71 GitHub-Last-Rev: 507ba84453f7305b6b2bf6317292111c00c93ffe GitHub-Pull-Request: golang/go#68724 Reviewed-on: https://go-review.googlesource.com/c/go/+/602895 Reviewed-by: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2023-09-01cmd/internal/dwarf: replace Sym.Length with Context.SizeMatthew Dempsky
Preparatory refactoring before next CL. Change-Id: I06fb4670b933fddff1a2a70f3cf1eb124cbd86ee Reviewed-on: https://go-review.googlesource.com/c/go/+/524899 Auto-Submit: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-09-01cmd/internal/obj: simplify filename handlingMatthew Dempsky
The old Go object file format used linker symbols like "gofile..foo" to record references to the filename "foo". But the current object file format has a dedicated section for file names, so we don't need these useless prefixes anymore. Also, change DWARF generation to pass around the src.Pos directly, rather than the old file symbols, which it just turned back into a file index before writing out anyway. Finally, directly record the FileIndex into src.PosBase, so that we can skip the map lookups. Change-Id: Ia4a5ebfa95da271f2522e45befdb9f137c16d373 Reviewed-on: https://go-review.googlesource.com/c/go/+/523378 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-08-29cmd/internal/obj: add Func type to replace "curfn any"Matthew Dempsky
This adds a modicum of type safety to these APIs, which are otherwise quite confusing to follow. Change-Id: I268a9a1a99a47dcfef6dc1e9e5be13673af3fb85 Reviewed-on: https://go-review.googlesource.com/c/go/+/523396 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-08-29cmd/internal/{dwarf,obj}: stop substituting "" with pkgprefixMatthew Dempsky
cmd/asm and cmd/compile now always create symbols with the appropriate package prefixes, so cmd/internal/dwarf and cmd/internal/obj can stop worrying about qualifying names itself. Change-Id: I9aee5d759bf0d41a61722c777e7f66fce957e79e Reviewed-on: https://go-review.googlesource.com/c/go/+/523338 Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-29cmd: simplify some handling of package pathsMatthew Dempsky
We have obj.Link.Pkgpath, so we don't need to pass it redundantly in places where we already have an *obj.Link. Also, renaming the parser's "compilingRuntime" field to "allowABI", to match the "AllowAsmABI" name used by objabi.LookupPkgSpecial. Finally, push the handling of GOEXPERIMENT_* flags up to cmd/asm's main entry point, by simply appending them to flags.D. Change-Id: I6ada134522b0cbc90d35bcb145fbe045338fefb7 Reviewed-on: https://go-review.googlesource.com/c/go/+/523297 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-02cmd/link, cmd/internal/obj: use aux symbol for global variable DWARF infoCherry Mui
Currently, for a global variable, its debug info symbol is a named symbol with the variable's name with a special prefix. And the linker looks it up by name. This CL makes the debug info symbol an aux symbol of the variable symbol. Change-Id: I55614d0ef2af9c53eb40144ad80e09339bf3cbee Reviewed-on: https://go-review.googlesource.com/c/go/+/490816 Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2023-01-30cmd/internal/obj: drop Filesym from DwarfAbstractFuncMichael Pratt
PutAbstractFunc doesn't use FnState.Filesym, so it isn't needed, but more importantly it is misleading. DwarfAbstractFunc is frequently used on inlined functions from outside the current compilation unit. For those function, ctxt.fileSymbol returns nil, meaning it probably isn't safe to use if the original compilation unit could also generate an abstract func with the correct file symbol. Change-Id: I0e6c76e41d75ac9ca07e0f775e49d791249e1c5d Reviewed-on: https://go-review.googlesource.com/c/go/+/458198 Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Pratt <mpratt@google.com>
2023-01-30cmd/compile,cmd/link: set DW_AT_decl_line for function declarationsMichael Pratt
DW_AT_decl_line provides the line number of function declarations (the line containing the func keyword). This is the equivalent to CL 429638, but provided via DWARF. Note that the file of declarations (DW_AT_decl_file) is already provided for non-inlined functions. It is omitted for inlined functions because those DWARF subprograms may be generated outside of their source compilation unit, where referencing the file table is difficult. Fixes #57308. Change-Id: I3ad12e1f366c4465c2a588297988a5825ef7efec Reviewed-on: https://go-review.googlesource.com/c/go/+/458195 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2022-10-31cmd/internal/obj: cleanup linkgetlineFromPosMichael Pratt
Make linkgetlineFromPos and getFileIndexAndLine methods on Link, and give the former a more descriptive name. The docs are expanded to make it more clear that these are final file/line visible in programs. In getFileSymbolAndLine use ctxt.InnermostPos instead of ctxt.PosTable direct, which makes it more clear that we want the semantics of InnermostPos. Change-Id: I7c3d344dec60407fa54b191be8a09c117cb87dd0 Reviewed-on: https://go-review.googlesource.com/c/go/+/446301 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-16cmd/compile: set LocalPkg.Path to -p flagMatthew Dempsky
Since CL 391014, cmd/compile now requires the -p flag to be set the build system. This CL changes it to initialize LocalPkg.Path to the provided path, rather than relying on writing out `"".` into object files and expecting cmd/link to substitute them. However, this actually involved a rather long tail of fixes. Many have already been submitted, but a few notable ones that have to land simultaneously with changing LocalPkg: 1. When compiling package runtime, there are really two "runtime" packages: types.LocalPkg (the source package itself) and ir.Pkgs.Runtime (the compiler's internal representation, for synthetic references). Previously, these ended up creating separate link symbols (`"".xxx` and `runtime.xxx`, respectively), but now they both end up as `runtime.xxx`, which causes lsym collisions (notably inittask and funcsyms). 2. test/codegen tests need to be updated to expect symbols to be named `command-line-arguments.xxx` rather than `"".foo`. 3. The issue20014 test case is sensitive to the sort order of field tracking symbols. In particular, the local package now sorts to its natural place in the list, rather than to the front. Thanks to David Chase for helping track down all of the fixes needed for this CL. Updates #51734. Change-Id: Iba3041cf7ad967d18c6e17922fa06ba11798b565 Reviewed-on: https://go-review.googlesource.com/c/go/+/393715 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-09-15cmd/compile: mark wrapper functions with DW_AT_trampolineAlessandro Arzilli
Change DWARF generation to tag wrapper functions with the "DW_AT_trampoline attribute". The intent is that debuggers can pick up on this attr so as to skip through the wrapper to the eventual target. DWARF standard allows for a couple of different possible variants of the trampoline attr; this is the simplest variant (all it tells the debugger is that the function is a wrapper, doesn't include a reference to the wrapper routine). This implementation keys off the WRAPPER LSym attribute, which is set for method wrappers, ABI wrappers, and a selected set of runtime assembly routines (ex: "runtime.call32"). Change-Id: Ib53e1bc56c02b86ca3ac5e7da1a541ec262726cf Reviewed-on: https://go-review.googlesource.com/c/go/+/347352 Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Jeremy Faller <jeremy@golang.org>
2021-03-23cmd/{compile,link}: relocate generation of DWARF for global varsThan McIntosh
Move DWARF generation for global variables from the linker to the compiler. This effectively parallelizes this part of DWARF generation, speeds up the linker minutely, and gives us a slightly more rational implementation (there was really no compelling reason to do DWARF gen for globals in the linker). Change-Id: I0c1c98d3a647258697e90eb91d1d8a9f6f7f376a Reviewed-on: https://go-review.googlesource.com/c/go/+/295011 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-11-12cmd/compile: do not emit an extra debug_line entry for the end of seq addrAlessandro Arzilli
Uses DW_LNS_advance_pc directly, instead of calling putpclcdelta because the latter will create a new debug_line entry for the end of sequence address. Fixes #42484 Change-Id: Ib6355605cac101b9bf37a3b4961ab0cee678a839 Reviewed-on: https://go-review.googlesource.com/c/go/+/268937 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-16cmd/internal/obj: move LSym.Func into LSym.ExtraRuss Cox
This creates space for a different kind of extension field in LSym without making the struct any larger. (There are many LSym, so we care about keeping the struct small.) Change-Id: Ib16edb9e15f54c2a7351c8b875e19684058711e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/243943 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-08-11[dev.link] cmd/internal/obj: combine objfile.go and objfile2.goCherry Zhang
Combine objfile2.go into objfile.go. objfile.go has a lot of code for DWARF generation. Move them to dwarf.go. Change-Id: I2a27c672e9e9b8eea35d5e0a71433dcc80b7afa4 Reviewed-on: https://go-review.googlesource.com/c/go/+/247918 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-08-10[dev.link] use per package filenames to build pclntabJeremy Faller
In order to prevent renumbering of filenames in pclntab generation, use the per-package file list (previously only used for DWARF generation) as file-indices. This is the largest step to eliminate renumbering of filenames in pclntab. Note, this is probably not the final state of the file table within the object file. In this form, the linker loads all filenames for all objects. I'll move to storing the filenames as regular string symbols,and defaulting all string symbols to using the larger hash value to make generation of pcln simplest, and most memory friendly. Change-Id: I23daafa3f4b4535076e23100200ae0e7163aafe0 Reviewed-on: https://go-review.googlesource.com/c/go/+/245485 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2020-06-24[dev.link] cmd/{compile,link}: fix file/line of last instruction in DWARF ↵Than McIntosh
line table The code in the compiler's DWARF line table generation emits line table ops at the end of each function fragment to reset the state machine registers back to an initial state, so that when the line table fragments for each function are stitched together into a compilation unit, each fragment will have a clean starting point. The set-file/set-line ops emitted in this code were being applied to the last row of the line table, however, meaning that they were overwriting the existing values. To avoid this problem, add code to advance the PC past the end of the last instruction in the function, and switch to just using an end-of-sequence operator at the end of each function instead of explicit set-file/set-line ops. Updates #39757. Change-Id: Ieb30f83444fa86fb1f2cd53862d8cc8972bb8763 Reviewed-on: https://go-review.googlesource.com/c/go/+/239286 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: David Chase <drchase@google.com>
2020-06-17[dev.link] cmd/link: rework line table generation to reduce heap memThan McIntosh
Rework the way symbols are handled in DWARF line table generation to eliminate copying the data payload for all SWDWARFLINES syms (emitted by the compiler) into the payload of the ".debug_line" section symbol (generated by the linker). Instead, chain together the SWDWARFLINES symbols into a list, then append that list to the section sym list in dwarfp (this moves us from a single monolithic .debug_line to a .debug_line section sym followed by a list symbols (one per function and an epilog symbol per compilation unit). To enable this work, move the emission of the DW_LNE_set_address op (at the start of each function) from the linker to the compiler. Change-Id: Iec61b44a451f7a386c82a89bf944de482b018789 Reviewed-on: https://go-review.googlesource.com/c/go/+/237427 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-10cmd/compile: walk progs to generate debug_lines dataJeremy Faller
Walking the progs is simpler than using the is_stmt symbol shenanigans. This is a reinstatement of CL 196661, which was rolled back due to tests failing. Unlike that original CL, this change should output the same debug_lines data the original approach wrote. The stats for JUST this CLC, note teh small speedup in compilation, and the lack of difference in binary size. name old time/op new time/op delta Template 229ms ± 4% 218ms ± 1% -4.95% (p=0.000 n=10+8) Unicode 92.6ms ± 9% 88.6ms ±13% ~ (p=0.089 n=10+10) GoTypes 850ms ± 2% 831ms ± 4% -2.23% (p=0.009 n=10+10) Compiler 3.99s ± 1% 3.93s ± 1% -1.29% (p=0.000 n=10+9) SSA 13.7s ± 1% 13.7s ± 1% ~ (p=0.912 n=10+10) Flate 140ms ± 3% 138ms ± 3% -1.90% (p=0.009 n=10+10) GoParser 172ms ± 2% 169ms ± 4% ~ (p=0.095 n=9+10) Reflect 530ms ± 3% 516ms ± 5% ~ (p=0.052 n=10+10) Tar 202ms ± 1% 196ms ± 3% -2.83% (p=0.002 n=9+10) XML 280ms ± 3% 270ms ± 4% -3.48% (p=0.009 n=10+10) LinkCompiler 927ms ± 2% 907ms ± 4% ~ (p=0.052 n=10+10) ExternalLinkCompiler 1.97s ± 2% 1.97s ± 3% ~ (p=0.853 n=10+10) LinkWithoutDebugCompiler 549ms ± 3% 543ms ± 5% ~ (p=0.481 n=10+10) StdCmd 12.0s ± 1% 12.0s ± 1% ~ (p=0.905 n=9+10) name old user-time/op new user-time/op delta Template 372ms ±18% 344ms ±11% ~ (p=0.190 n=10+10) Unicode 264ms ±23% 241ms ±43% ~ (p=0.315 n=8+10) GoTypes 1.56s ±22% 1.68s ± 5% ~ (p=0.237 n=10+8) Compiler 7.41s ± 2% 7.31s ± 3% ~ (p=0.123 n=10+10) SSA 24.5s ± 2% 24.7s ± 1% ~ (p=0.133 n=10+9) Flate 199ms ± 6% 188ms ±28% ~ (p=0.353 n=10+10) GoParser 243ms ±11% 240ms ± 6% ~ (p=0.968 n=10+9) Reflect 929ms ±21% 862ms ±35% ~ (p=0.190 n=10+10) Tar 284ms ± 9% 296ms ±17% ~ (p=0.497 n=9+10) XML 386ms ±21% 398ms ±28% ~ (p=1.000 n=9+10) LinkCompiler 1.13s ± 9% 1.12s ± 8% ~ (p=0.546 n=9+9) ExternalLinkCompiler 2.37s ±15% 2.30s ± 9% ~ (p=0.549 n=10+9) LinkWithoutDebugCompiler 646ms ±10% 642ms ±13% ~ (p=0.853 n=10+10) name old alloc/op new alloc/op delta Template 36.5MB ± 0% 36.5MB ± 0% -0.11% (p=0.000 n=10+9) Unicode 28.5MB ± 0% 28.5MB ± 0% ~ (p=0.190 n=10+10) GoTypes 121MB ± 0% 121MB ± 0% -0.10% (p=0.000 n=9+10) Compiler 549MB ± 0% 549MB ± 0% -0.10% (p=0.000 n=9+10) SSA 1.92GB ± 0% 1.92GB ± 0% -0.13% (p=0.000 n=10+10) Flate 23.0MB ± 0% 23.0MB ± 0% -0.07% (p=0.000 n=10+10) GoParser 27.9MB ± 0% 27.9MB ± 0% -0.09% (p=0.000 n=10+10) Reflect 77.9MB ± 0% 77.8MB ± 0% -0.13% (p=0.000 n=9+10) Tar 34.5MB ± 0% 34.4MB ± 0% -0.09% (p=0.000 n=10+10) XML 44.3MB ± 0% 44.3MB ± 0% -0.08% (p=0.000 n=10+10) LinkCompiler 229MB ± 0% 225MB ± 0% -1.74% (p=0.000 n=10+10) ExternalLinkCompiler 233MB ± 0% 242MB ± 0% +3.81% (p=0.000 n=10+10) LinkWithoutDebugCompiler 156MB ± 0% 152MB ± 0% -2.29% (p=0.000 n=10+9) name old allocs/op new allocs/op delta Template 373k ± 0% 373k ± 0% -0.21% (p=0.000 n=10+10) Unicode 340k ± 0% 340k ± 0% -0.04% (p=0.000 n=10+10) GoTypes 1.33M ± 0% 1.33M ± 0% -0.20% (p=0.000 n=10+9) Compiler 5.39M ± 0% 5.38M ± 0% -0.16% (p=0.000 n=10+10) SSA 18.3M ± 0% 18.2M ± 0% -0.15% (p=0.000 n=10+10) Flate 235k ± 0% 234k ± 0% -0.23% (p=0.000 n=10+7) GoParser 309k ± 0% 308k ± 0% -0.20% (p=0.000 n=10+10) Reflect 970k ± 0% 968k ± 0% -0.30% (p=0.000 n=10+10) Tar 347k ± 0% 347k ± 0% -0.22% (p=0.000 n=10+10) XML 425k ± 0% 424k ± 0% -0.16% (p=0.000 n=10+10) LinkCompiler 602k ± 0% 601k ± 0% -0.03% (p=0.000 n=9+10) ExternalLinkCompiler 1.65M ± 0% 1.65M ± 0% -0.02% (p=0.000 n=10+10) LinkWithoutDebugCompiler 220k ± 0% 220k ± 0% -0.03% (p=0.016 n=10+9) name old object-bytes new object-bytes delta Template 553kB ± 0% 553kB ± 0% -0.01% (p=0.000 n=10+10) Unicode 215kB ± 0% 215kB ± 0% ~ (all equal) GoTypes 2.02MB ± 0% 2.02MB ± 0% -0.00% (p=0.000 n=10+10) Compiler 7.98MB ± 0% 7.98MB ± 0% -0.01% (p=0.000 n=10+10) SSA 27.1MB ± 0% 27.1MB ± 0% -0.00% (p=0.000 n=10+10) Flate 340kB ± 0% 340kB ± 0% -0.01% (p=0.000 n=10+10) GoParser 434kB ± 0% 434kB ± 0% -0.00% (p=0.000 n=10+10) Reflect 1.34MB ± 0% 1.34MB ± 0% -0.01% (p=0.000 n=10+10) Tar 479kB ± 0% 479kB ± 0% -0.00% (p=0.000 n=10+10) XML 618kB ± 0% 618kB ± 0% -0.01% (p=0.000 n=10+10) name old export-bytes new export-bytes delta Template 20.4kB ± 0% 20.4kB ± 0% ~ (all equal) Unicode 8.21kB ± 0% 8.21kB ± 0% ~ (all equal) GoTypes 36.6kB ± 0% 36.6kB ± 0% ~ (all equal) Compiler 116kB ± 0% 116kB ± 0% +0.00% (p=0.000 n=10+10) SSA 141kB ± 0% 141kB ± 0% +0.00% (p=0.000 n=10+10) Flate 5.10kB ± 0% 5.10kB ± 0% ~ (all equal) GoParser 8.92kB ± 0% 8.92kB ± 0% ~ (all equal) Reflect 11.8kB ± 0% 11.8kB ± 0% ~ (all equal) Tar 10.9kB ± 0% 10.9kB ± 0% ~ (all equal) XML 17.4kB ± 0% 17.4kB ± 0% ~ (all equal) name old text-bytes new text-bytes delta HelloSize 742kB ± 0% 742kB ± 0% ~ (all equal) CmdGoSize 10.6MB ± 0% 10.6MB ± 0% ~ (all equal) name old data-bytes new data-bytes delta HelloSize 10.7kB ± 0% 10.7kB ± 0% ~ (all equal) CmdGoSize 312kB ± 0% 312kB ± 0% ~ (all equal) name old bss-bytes new bss-bytes delta HelloSize 122kB ± 0% 122kB ± 0% ~ (all equal) CmdGoSize 146kB ± 0% 146kB ± 0% ~ (all equal) name old exe-bytes new exe-bytes delta HelloSize 1.10MB ± 0% 1.10MB ± 0% ~ (all equal) CmdGoSize 14.9MB ± 0% 14.9MB ± 0% -0.03% (p=0.000 n=10+10) Change-Id: Ie078a42b29353b96654fa1f0f47d600b5a53762d Reviewed-on: https://go-review.googlesource.com/c/go/+/200017 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-03Revert "cmd/compile: walk the progs to generate debug_lines"Bryan C. Mills
This reverts CL 196661. Reason for revert: broke TestGdb* tests on mips64le, ppc64le, and s390x builders. Change-Id: I3b5c97c840819a0d407b943f7cf7e2d97f06042d Reviewed-on: https://go-review.googlesource.com/c/go/+/198697 Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-03cmd/compile: walk the progs to generate debug_linesJeremy Faller
Rather than use the pcln tables, walk progs while generating debug_lines. This code slightly increases the number of is_stmt toggles in the debug information due to a previous bug in how the pcline walking worked. (Previous versions of the line walking code wouldn't return the old_value, instead returning 0. This behavior might lose is_stmt toggles in the line table.) We suspected there would be a speedup with this change, but benchmarking hasn't shown this to be true (but has been noisy enough to not really show any large differences either way). These benchmarks are comparing non-prog walking code with this prog-walking code: name old time/op new time/op delta Template 321ms ± 4% 316ms ± 3% ~ (p=0.165 n=10+10) Unicode 146ms ± 5% 142ms ± 4% ~ (p=0.063 n=10+10) GoTypes 1.06s ± 2% 1.07s ± 2% ~ (p=0.280 n=10+10) Compiler 4.07s ± 1% 4.06s ± 1% ~ (p=0.549 n=10+9) SSA 12.6s ± 2% 12.7s ± 2% +1.27% (p=0.019 n=10+10) Flate 201ms ± 7% 202ms ± 4% ~ (p=0.436 n=10+10) GoParser 248ms ± 4% 250ms ± 2% ~ (p=0.356 n=9+10) Reflect 679ms ± 5% 678ms ± 4% ~ (p=0.971 n=10+10) Tar 281ms ± 2% 283ms ± 3% ~ (p=0.222 n=9+9) XML 381ms ± 3% 384ms ± 5% ~ (p=0.393 n=10+10) LinkCompiler 1.08s ± 2% 1.10s ± 2% +1.89% (p=0.009 n=10+10) ExternalLinkCompiler 2.23s ± 4% 2.23s ± 1% ~ (p=1.000 n=10+8) LinkWithoutDebugCompiler 654ms ± 4% 673ms ± 4% +2.94% (p=0.019 n=10+10) StdCmd 13.6s ± 2% 13.9s ± 1% +2.00% (p=0.000 n=10+10) name old user-time/op new user-time/op delta Template 582ms ±11% 575ms ±14% ~ (p=0.631 n=10+10) Unicode 431ms ±24% 390ms ±38% ~ (p=0.315 n=10+10) GoTypes 2.47s ±11% 2.51s ± 4% ~ (p=0.280 n=10+10) Compiler 9.09s ± 3% 9.04s ± 5% ~ (p=0.684 n=10+10) SSA 25.8s ± 4% 26.0s ± 3% ~ (p=0.529 n=10+10) Flate 318ms ±14% 322ms ±13% ~ (p=0.912 n=10+10) GoParser 386ms ± 6% 386ms ± 5% ~ (p=0.888 n=9+8) Reflect 1.42s ±20% 1.32s ±24% ~ (p=0.393 n=10+10) Tar 476ms ±19% 471ms ±25% ~ (p=1.000 n=10+10) XML 681ms ±25% 745ms ±21% ~ (p=0.143 n=10+10) LinkCompiler 1.75s ±13% 1.86s ±12% ~ (p=0.075 n=10+10) ExternalLinkCompiler 2.98s ±18% 3.41s ±13% +14.48% (p=0.003 n=10+10) LinkWithoutDebugCompiler 1.05s ±12% 1.08s ±16% ~ (p=0.739 n=10+10) name old alloc/op new alloc/op delta Template 36.4MB ± 0% 36.4MB ± 0% -0.11% (p=0.000 n=10+10) Unicode 28.6MB ± 0% 28.5MB ± 0% -0.06% (p=0.029 n=10+10) GoTypes 121MB ± 0% 121MB ± 0% -0.09% (p=0.000 n=9+9) Compiler 548MB ± 0% 547MB ± 0% -0.10% (p=0.000 n=10+10) SSA 1.87GB ± 0% 1.87GB ± 0% -0.13% (p=0.000 n=10+10) Flate 23.0MB ± 0% 22.9MB ± 0% -0.09% (p=0.000 n=9+10) GoParser 27.9MB ± 0% 27.8MB ± 0% -0.12% (p=0.000 n=10+10) Reflect 77.7MB ± 0% 77.6MB ± 0% -0.12% (p=0.000 n=8+10) Tar 34.5MB ± 0% 34.5MB ± 0% -0.07% (p=0.003 n=10+10) XML 44.4MB ± 0% 44.4MB ± 0% -0.07% (p=0.000 n=10+10) LinkCompiler 236MB ± 0% 240MB ± 0% +1.72% (p=0.000 n=10+10) ExternalLinkCompiler 246MB ± 0% 254MB ± 0% +3.02% (p=0.000 n=10+10) LinkWithoutDebugCompiler 159MB ± 0% 164MB ± 0% +3.35% (p=0.000 n=10+10) name old allocs/op new allocs/op delta Template 372k ± 0% 371k ± 0% -0.23% (p=0.000 n=10+10) Unicode 340k ± 0% 340k ± 0% -0.05% (p=0.000 n=10+10) GoTypes 1.33M ± 0% 1.32M ± 0% -0.20% (p=0.000 n=9+10) Compiler 5.37M ± 0% 5.36M ± 0% -0.17% (p=0.000 n=10+10) SSA 17.9M ± 0% 17.9M ± 0% -0.15% (p=0.000 n=10+10) Flate 234k ± 0% 233k ± 0% -0.24% (p=0.000 n=9+10) GoParser 309k ± 0% 309k ± 0% -0.21% (p=0.000 n=10+10) Reflect 969k ± 0% 966k ± 0% -0.30% (p=0.000 n=9+10) Tar 348k ± 0% 347k ± 0% -0.22% (p=0.000 n=10+9) XML 426k ± 0% 425k ± 0% -0.15% (p=0.000 n=9+10) LinkCompiler 638k ± 0% 637k ± 0% -0.07% (p=0.000 n=10+10) ExternalLinkCompiler 1.69M ± 0% 1.69M ± 0% -0.05% (p=0.000 n=10+10) LinkWithoutDebugCompiler 222k ± 0% 221k ± 0% -0.03% (p=0.007 n=10+9) name old object-bytes new object-bytes delta Template 559kB ± 0% 560kB ± 0% +0.23% (p=0.000 n=10+10) Unicode 216kB ± 0% 216kB ± 0% +0.01% (p=0.000 n=10+10) GoTypes 2.03MB ± 0% 2.04MB ± 0% +0.31% (p=0.000 n=10+10) Compiler 8.07MB ± 0% 8.10MB ± 0% +0.35% (p=0.000 n=10+10) SSA 27.1MB ± 0% 27.3MB ± 0% +0.72% (p=0.000 n=10+10) Flate 343kB ± 0% 344kB ± 0% +0.22% (p=0.000 n=10+10) GoParser 441kB ± 0% 442kB ± 0% +0.34% (p=0.000 n=10+10) Reflect 1.36MB ± 0% 1.36MB ± 0% +0.23% (p=0.000 n=10+10) Tar 487kB ± 0% 488kB ± 0% +0.21% (p=0.000 n=10+10) XML 632kB ± 0% 634kB ± 0% +0.35% (p=0.000 n=10+10) name old export-bytes new export-bytes delta Template 18.5kB ± 0% 18.5kB ± 0% ~ (all equal) Unicode 7.92kB ± 0% 7.92kB ± 0% ~ (all equal) GoTypes 35.0kB ± 0% 35.0kB ± 0% ~ (all equal) Compiler 109kB ± 0% 109kB ± 0% +0.00% (p=0.000 n=10+10) SSA 137kB ± 0% 137kB ± 0% +0.00% (p=0.000 n=10+10) Flate 4.89kB ± 0% 4.89kB ± 0% ~ (all equal) GoParser 8.49kB ± 0% 8.49kB ± 0% ~ (all equal) Reflect 11.4kB ± 0% 11.4kB ± 0% ~ (all equal) Tar 10.5kB ± 0% 10.5kB ± 0% ~ (all equal) XML 16.7kB ± 0% 16.7kB ± 0% ~ (all equal) name old text-bytes new text-bytes delta HelloSize 760kB ± 0% 760kB ± 0% ~ (all equal) CmdGoSize 10.8MB ± 0% 10.8MB ± 0% ~ (all equal) name old data-bytes new data-bytes delta HelloSize 10.7kB ± 0% 10.7kB ± 0% ~ (all equal) CmdGoSize 312kB ± 0% 312kB ± 0% ~ (all equal) name old bss-bytes new bss-bytes delta HelloSize 122kB ± 0% 122kB ± 0% ~ (all equal) CmdGoSize 146kB ± 0% 146kB ± 0% ~ (all equal) name old exe-bytes new exe-bytes delta HelloSize 1.13MB ± 0% 1.13MB ± 0% ~ (all equal) CmdGoSize 15.0MB ± 0% 15.1MB ± 0% +0.22% (p=0.000 n=10+10) Change-Id: If6e0982cd1398062a88e6c0c7513e141f9503531 Reviewed-on: https://go-review.googlesource.com/c/go/+/196661 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2019-09-26cmd/link: switch linker over to new debug lines from compilerJeremy Faller
This switches the linker over to using the new debug_lines data generated in the compiler. Change-Id: If8362d6fcea7db60aaebab670ed6f702ab1c4908 Reviewed-on: https://go-review.googlesource.com/c/go/+/191968 Run-TryBot: Jeremy Faller <jeremy@golang.org> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-25cmd/compile: update object file format for DWARF file tableJeremy Faller
In CL 188317, we generate the debug_lines in the compiler, and created a new symbol to hold the line table. Here we modify the object file format to output the file table. Change-Id: Ibee192e80b86ff6af36467a0b1c26ee747dfee37 Reviewed-on: https://go-review.googlesource.com/c/go/+/191167 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-24cmd/compile: generate debug_lines in compilerJeremy Faller
This is mostly a copy-paste jobs from the linker to generate the debug information in the compiler instead of the linker. The new data is inserted into the debug line numbers symbol defined in CL 188238. Generating the debug information BEFORE deadcode results in one subtle difference, and that is that the state machine needs to be reset at the end of every function's debug line table. The reasoning is that generating the table AFTER dead code allows the producer and consumer of the table to agree on the state of the state machine, and since these blocks will (eventually) be concatenated in the linker, we don't KNOW the state of the state machine unless we reset it. So, generateDebugLinesSymbol resets the state machine at the end of every function. Right now, we don't do anything with this line information, or the file table -- we just populate the symbols. Change-Id: If9103eda6cc5f1f7a11e7e1a97184a060a4ad7fb Reviewed-on: https://go-review.googlesource.com/c/go/+/188317 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>