1
0
mirror of https://github.com/golang/go synced 2024-11-23 21:30:08 -07:00
Commit Graph

43031 Commits

Author SHA1 Message Date
Cherry Zhang
6652a6cccc [dev.link] cmd/internal/goobj2: bump up version number
As we now have -go115newobj flag, it is better to use go115 in
the object file as well. And it already diverges from the go114
"new" object file format.

Change-Id: I315edf7524158b5c354393fe9a7ab9f6d7cc9808
Reviewed-on: https://go-review.googlesource.com/c/go/+/225458
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-26 14:40:34 +00:00
Cherry Zhang
c02cd04fe1 [dev.link] cmd/link: fix buglet in setupdynexp
This should restore deterministic order of dynexp, and fix
Solaris build.

Change-Id: Icb796babaa3238bff90fd8255ee9f023f2306c26
Reviewed-on: https://go-review.googlesource.com/c/go/+/225538
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-26 14:23:53 +00:00
Cherry Zhang
ca18c37ee8 [dev.link] cmd/link: define _etext, etc. in the linker on Solaris
On Solaris, in the runtime it defines the external name of
runtime.etext as _etext (runtime/os3_solaris.go:13). In CL 224939
we changed to put external names in the ELF symbol table more
consistently. In this case it will contain _etext but not
runtime.etext.

To be conservative, this CL defines both runtime.etext and _text
in the linker.

Change-Id: I79f196e87b655042be97b0fbbab02d0ebc8db2fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/225537
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-26 14:23:41 +00:00
Cherry Zhang
c4cb6832bb [dev.link] cmd/link: remove lookup function from relocsym
The lookup is only used for DWARF section symbols, for which we
can just link the symbols to the sections.

Change-Id: Id8426fbf59bab2528f57e28e2043e0b405656a9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/225204
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-25 15:21:52 +00:00
Cherry Zhang
4ba39d6a58 [dev.link] cmd/link: pass loader to relocation functions
It is needed in Xcoffadddynrel. And it will be needed once we
move more things to new style (the sym.Symbol parameters will
also need to change).

Change-Id: Ie12683f9b44e21f1e6ea711bf2f4c5c32282e5b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/225203
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-25 15:21:43 +00:00
Cherry Zhang
b1a19f3cc7 [dev.link] cmd/link: convert doxcoff to new style
Change-Id: Ic1e4ed6c14e049b1ba2f7c00f986433ab7ebe932
Reviewed-on: https://go-review.googlesource.com/c/go/+/225202
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-25 15:20:40 +00:00
Than McIntosh
651e950fc9 [dev.link] cmd/link: convert addexport to loader interfaces
Convert the linker's "addexport" function to use loader interfaces
for symbol manipulation instead of *sym.Symbol.

At the moment "addexport" happens after loadlibfull (there are other
chunks of functionality in the way that haven't been converted), so
this implementation contains temporary shim code to copy back the
contents of updated loader.Sym's into the corresponding sym.Symbol.

Change-Id: I867b08e66562a2bed51560fd0be2cb64d344709c
Reviewed-on: https://go-review.googlesource.com/c/go/+/224384
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-25 12:47:41 +00:00
Than McIntosh
dd66786029 [dev.link] cmd/link: add loader.Sym equivalents to ArchSyms
Populate ArchSyms with loader.Sym versions of important symbols,
so as to be able to convert the code that uses ArchSyms to the
new loader interfaces.

Change-Id: If6766f7164642a9dc2e31fcf7f9280a6e95e5d23
Reviewed-on: https://go-review.googlesource.com/c/go/+/224383
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-25 12:47:34 +00:00
Than McIntosh
e14efb6865 [dev.link] cmd/link: move setupdynexp before loadlibfull
Rewrite setupdynexp to work with loader.Sym, and move the call to it
before the body of loadlibfull. After loadlibfull is complete,
construct the old *sym.Symbol version of dynexp, since not all all
clients that access this list are converted to the loader APIs.

Change-Id: I347d24958e2f3e2332fbe33f2eb6ec25cc126bdb
Reviewed-on: https://go-review.googlesource.com/c/go/+/224382
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-25 12:47:14 +00:00
Than McIntosh
3fa98a0436 [dev.link] cmd/link: minor tweaks to PropagateLoaderChangesToSymbols
Update PropagateLoaderChangesToSymbols so that it no longer requires
a sym.Symbols pointer. The intent is to generalize it a little to
allow it to be used in more than just linker Dwarf generation.

Change-Id: I9bddc5d39839eacd9113c945bb59d2873c0b088c
Reviewed-on: https://go-review.googlesource.com/c/go/+/224381
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-03-25 12:22:56 +00:00
Than McIntosh
242b38c171 [dev.link] cmd/link: relocating Errorf() to ErrorReporter
Add an Errorf method to ErrorReporter. The hope is that we can
consolidate error handling/reporting in this helper, and eventually
do away with Link.Errorf and the global Errorf function (which
can be removed once we've eliminated enough uses of *sym.Symbol).

Change-Id: Ie1147020b8409b9c57acfd71c942b287b214afca
Reviewed-on: https://go-review.googlesource.com/c/go/+/224380
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-03-25 12:22:46 +00:00
Cherry Zhang
ea93ddfaeb [dev.link] cmd/link: use Extname in doxcoff
On AIX, when external linking, we need to change the function
names to start with a dot and make function descriptors with the
names without the dot. Currently this is done through symbol
renaming, which is not friendly for switching to the loader.

In this CL we use symbol's external name for this. This allows us
to get rid of symbol renaming.

Change-Id: If72602d17e96f0339fdac2e2321f1edfb292b5f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/224940
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-24 16:43:33 +00:00
Cherry Zhang
ed7a491940 [dev.link] cmd/link: convert mangleTypeSym to new style
Use symbol's Extname, instead of symbol renaming, for the mangled
names.

The old symbol Rename has an interesting logic of "merging"
symbols, when a symbol is renamed to the name of an existing
symbol. It turns out that this is needed for linking against
shared libraries, where the Go object has a reference to a symbol
with the original name, and the shared libary provides a symbol
under the mangled name. Implement this logic with the loader.

Change-Id: Ib95d7a9c93a52f8e02f4a51ac67240d6ebfc1c6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/224939
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-24 16:43:18 +00:00
Jeremy Faller
b328ab1d1e [dev.link] cmd/link: remove global datap, moved to *Link
This change moves datap from global space into the link context. Rather
than having it exist in context, we could have it returned from dodata,
and pass it as a parameter, but it is used in awkward places in the
Arch functions. Easiest for now is just keeping it in the context, until
we more formally move it to slices of loader.Sym.

This is a largely non-functional change.

Change-Id: Ica93bd857c39913ad470a61c63bc8d21704d6308
Reviewed-on: https://go-review.googlesource.com/c/go/+/222664
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-24 16:01:15 +00:00
Jeremy Faller
4d5fdd74ab [dev.link] cmd/link: refactor some of dodata
This is a non-functional change, just moving things around, making
dodata a more approachable piece of code.

Change-Id: I06fa047cbef2313040a31998fa8d242ccb2fedea
Reviewed-on: https://go-review.googlesource.com/c/go/+/222662
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-24 16:00:49 +00:00
Than McIntosh
d44c9a046b [dev.link] cmd/link: set "local" attribute on symbols during preload
Set the "local" attribute on object file loader symbols during preload,
as opposed to the current strategy of only propagating the local attr
when we convert to sym.Symbols.

Change-Id: I18965e2fdaa9a0b9315d95466d17d9f41aa40a45
Reviewed-on: https://go-review.googlesource.com/c/go/+/224379
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-23 15:10:28 +00:00
Than McIntosh
49099d21f5 [dev.link] cmd/link: add loader.Loader apis for symbol dynamic id
Add SymDynid and SetSymDynid methods to the loader. This symbol
property is currently backed by a map.

Change-Id: Iaf86b1d8aaa775fa102fadea30394eb8a670e0e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/224378
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-23 15:10:20 +00:00
Cherry Zhang
5ffa696ade [dev.link] cmd/link: invoke oldlink if old object format is chosen
Now we can choose the old object file format by setting
-gcflags=all=-go115newobj=false -asmflags=all=-go115newobj=false -ldflags=all=-go115newobj=false

Tested that setting all three to default false and it still works.

Change-Id: I9514b62a676916cc383b8afa389489fe7b8fa2bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/224625
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-23 14:42:58 +00:00
Cherry Zhang
6c7d6cefd0 [dev.link] cmd/internal/obj: restore old DWARF symbol handling
When old object file format is used, serialize DWARF symbols in
the old way.

Change-Id: I73a97f10bba367ac29c52f8f3d0f8f3b34a42523
Reviewed-on: https://go-review.googlesource.com/c/go/+/224624
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-23 14:39:03 +00:00
Cherry Zhang
330f53b615 [dev.link] cmd/asm, cmd/compile: add back newobj flag
Add back the newobj flag, renamed to go115newobj, for feature
gating. The flag defaults to true.

This essentially reverts CL 206398 as well as CL 220060.

The old object format isn't working yet. Will fix in followup CLs.

Change-Id: I1ace2a9cbb1a322d2266972670d27bda4e24adbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/224623
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-23 14:38:49 +00:00
Cherry Zhang
54c32590f0 [dev.link] cmd/oldlink: add back the old linker
Basically a "cp -r" from tip's cmd/link (at commit
776a9d0958), and fix up import
paths.

It is not used for now. A flag will be introduced in followup
CLs, which will allow to switch between the old and new linker.

Some adjustments to make it still build:
- Adjust accessor of NoSplit attribute to match the change in
  goobj2 package (cmd/oldlink/internal/loader/loader.go:1206).
- Change sym.Symbol's Len method to Length to match the new
  interface in cmd/internal/dwarf
  (cmd/oldlink/internal/sym/symbol.go:102).
- Add a TODO for deletion (cmd/oldlink/main.go:5).

Change-Id: I76e62f259cb6b494280f5511f75913bc37874746
Reviewed-on: https://go-review.googlesource.com/c/go/+/224622
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-23 14:38:38 +00:00
Cherry Zhang
f652eb72b6 [dev.link] cmd/internal/dwarf: add back some constant prefixes
They are still used by the old linker.

This is for introducing gating for the new object file format and
the new linker.

Change-Id: I97bb6ab4cc2c03f90f199c705d4c127e45ca07f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/224621
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-23 14:38:30 +00:00
Austin Clements
6def07cf1e [dev.link] cmd/link: finish phase CPU profile before running GC
Currently, phase profiling runs GC at the end of a phase before
stopping the CPU profile. Rearrange things so we stop the CPU profile
right when we collect the end time-stamp and before dealing with GCs
and heap profiles.

Change-Id: I9a84b9b17c7db7f8cacf591147de15464298b6af
Reviewed-on: https://go-review.googlesource.com/c/go/+/224620
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-21 13:48:38 +00:00
Austin Clements
fb0c3ee13d [dev.link] cmd/link: improve documentation on -benchmarkprofile
Change-Id: Ib55017f538b6c4ba805e56491b6a59942fad64ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/224618
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-21 13:48:36 +00:00
Austin Clements
105053fa19 [dev.link] cmd/link: record per-phase memory profile
We already have an option to record per-phase CPU profiles. If we're
in "mem" benchmark mode, then it also makes sense to collect a heap
profile of the live heap at the end of a phase. This CL adds that
profile and changes the extensions of the profiles to "cpuprof" and
"memprof" to make the distinction clear.

Change-Id: Ia05b7fa18bccad954a875f7a55d9cff5ad8dfaaf
Reviewed-on: https://go-review.googlesource.com/c/go/+/224617
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-21 13:48:35 +00:00
Than McIntosh
7055f01e12 [dev.link] cmd/link: minor perf tweak for PropagateLoaderChangesToSymbols
When fixing up relocations in PropagateLoaderChangesToSymbols, don't
reallocate the target sym.Symbol relocation slice if it already has
the desired size (this gets rid of some unneeded allocations).

Change-Id: I05287772c18cab861c2df805fa9497103fb00dcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/224420
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-03-20 20:31:35 +00:00
Than McIntosh
0dff5b0b9e [dev.link] cmd/compile, cmd/link: move away from DWARF file renumbering
This patch moves the compiler and linker away from the current scheme
used to generate file references in DWARF subprogram dies.

Up until now the scheme has been to have the compiler emit a special
relocation on a DIE file reference that points to the file symbol in
question. The linker then reads this relocation and updates the addend
to the index of the appropriate file in the line table of the
compilation unit of the DIE (the linker emits the comp unit file
table, so it knows at that point what number use). The drawback of
this scheme is that it requires a lot of relocation processing.

With this patch, we switch to having the compiler emit the file index
directly, and then have the linker use the compiler-generated file
table to emit the line table file section (no renumbering, no
relocations, etc).

Change-Id: Id4fbe67b28a64200a083e3c5ea358dbe091ec917
Reviewed-on: https://go-review.googlesource.com/c/go/+/223318
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-20 16:19:22 +00:00
Than McIntosh
673a02a235 [dev.link] cmd/compile, cmd/link: move DWARF info sym to anonymous aux data
Switch the primary subprogram die DWARF symbol emitted by the compiler
from named+dupOK to anonymous aux. This should help performance wise
by not having to add these symbols to the linker's symbol name lookup
tables.

Change-Id: Idf66662b8bf60b3dee9a55e6cd5137b24a9f5ab6
Reviewed-on: https://go-review.googlesource.com/c/go/+/223669
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-20 16:19:15 +00:00
Than McIntosh
62b0790a79 [dev.link] cmd/compile: refactor aux handling in newobj sym traversal
Generalize symbol traversal code for aux symbols to allow for client
control over whether the walk incldues symbols referenced by
relocations on visited aux syms. This is not needed just yet but will
be required in order to support anonymous aux syms that have
relocations.

Change-Id: I898c1f398213c8d9d777dd3c40524a013b25e348
Reviewed-on: https://go-review.googlesource.com/c/go/+/223668
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-20 16:19:07 +00:00
Jeremy Faller
5d9cdbb840 [dev.link] cmd/link: remove *Link from some arch functions
Change-Id: Ia7f9a999af5285885987b83a877b205b274342a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/222306
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-19 19:25:28 +00:00
Jeremy Faller
bf5dc7af0f [dev.link] cmd/link: eliminate usage of *Link in arch funcs
Change-Id: I10e6b266ff3a1238d1b86a9b39debb13f5a04e55
Reviewed-on: https://go-review.googlesource.com/c/go/+/222159
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-19 19:25:15 +00:00
Than McIntosh
63ffa1595c [dev.link] cmd/link: cleanup of attribute handling code
Minor cleanup of symbol attributes. Specifically:

- if a symbol originally begins life as an object file symbol,
  then is converted to external in cloneToExternal, use the
  previously recorded object file index for the sym to figure
  out if it has read-only data (in the case that there is no
  entry for it in the map in question).

- remove SetAttrShared; only the loader should be populating this
  attribute at symbol creation (it never gets updated later)

- remove unused copyAttributes() method

- comment fixes

Change-Id: Iac7bc6ac310ec89bfe733ddc783970d2a8017478
Reviewed-on: https://go-review.googlesource.com/c/go/+/223667
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-18 22:49:17 +00:00
Cherry Zhang
626c89bfa3 [dev.link] cmd/link: remove AddExtSym
They used to be different at some point, but now AddExtSym and
LookupOrCreateSym are identical. Remove one.

Change-Id: I299444d987e32a7f43915b3c1bbcc5ae906e9b6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/223977
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-18 22:26:24 +00:00
Cherry Zhang
61a0b0d624 [dev.link] cmd/link: use new relocation accessors in DWARF generation
This gives some speedup and reduces some allocations:

(linking cmd/compile)
DwarfGenerateDebugInfo    63.2ms ± 3%    41.7ms ± 3%  -34.04%  (p=0.008 n=5+5)

DwarfGenerateDebugInfo    20.0MB ± 0%    10.1MB ± 0%  -49.62%  (p=0.008 n=5+5)

There are code that modify relocations, which are still using
the earlier loader.Reloc slice for now.

Change-Id: I3359ba305bf82cc882ae3c0f548d6ccfc8add789
Reviewed-on: https://go-review.googlesource.com/c/go/+/223663
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-16 17:33:50 +00:00
Cherry Zhang
8a074fa275 [dev.link] cmd/internal/goobj2, cmd/link: experiment new aux symbol accessors
Following the previous CLs, do the same for aux symbols. This has
some small speedup:

(linking cmd/compile)
Dostkcheck    41.0ms ± 1%    38.6ms ± 1%    -6.00%  (p=0.008 n=5+5)

Change-Id: Id62b2fc9e4ef1be92e60e4c03faec0a953eee94e
Reviewed-on: https://go-review.googlesource.com/c/go/+/222303
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-16 17:33:43 +00:00
Cherry Zhang
8e100a05a5 [dev.link] cmd/internal/goobj2, cmd/link: avoid some repeated offset calculations
When iterating relocations, do the offset calculation just once.
This gives some speedup:

(linking cmd/compile)
Deadcode      52.8ms ± 1%    47.6ms ± 1%  -10.01%  (p=0.008 n=5+5)
Dostkcheck    44.2ms ± 1%    41.0ms ± 1%   -7.29%  (p=0.008 n=5+5)

Change-Id: I09e38bc29afc379a81f99e3ee4ff467bc1b5f8a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/222302
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-16 17:33:34 +00:00
Cherry Zhang
3277db4ccf [dev.link] cmd/internal/goobj2: optimize symbol data access
I wish the compiler inlines the DataOff function and CSEs the
base offset calculation. But it didn't happen. Hand optimize it...

(linking cmd/compile)
Dostkcheck    42.0ms ± 0%    36.1ms ± 2%  -14.07%  (p=0.008 n=5+5)

Change-Id: Iacfbc7243a882158a9a090b7400e216536a311b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/222304
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-16 17:33:24 +00:00
Cherry Zhang
3382411d93 [dev.link] cmd/link: don't set unreachable string variables in addstrdata
If the variable is not reachable, don't bother setting it.

The old behavior was to set it but not mark it reachable, nor the
string data it points to. This was changed in CL 219226, which
changed the variable and the string data to always reachable.
Typically it shouldn't matter much besides some waste of binary
size. But it does matter on AIX (crash in make.bash). I haven't
looked into why.

Fix AIX build.

Change-Id: I546a0c94ad77b10485ceb66e1288a408e2a2a3e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/223380
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-16 14:41:53 +00:00
Cherry Zhang
80702c7c3c [dev.link] cmd/link: use versioned .TOC. symbols on AIX
I thought that only non-static symbols need TOC, but apparently
this is not true. We need to use versioned .TOC. symbols.

Partially fix AIX build. There is still another problem, but this
gets us a bit farther in make.bash.

Change-Id: I40ba4a4dd27da0fc6ab26e4a54ff76bd2930aef1
Reviewed-on: https://go-review.googlesource.com/c/go/+/223379
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-16 13:50:40 +00:00
Cherry Zhang
0e06775eeb [dev.link] cmd/link: don't truncate external relocation type
In CL 222244, we store external relocations in the same format as
Go object files. In Go object file format, the relocation type is
a uint8. However, for external relocations the type may not
always fit in a uint8. Truncating it will result in a bad
relocation. Fix this by storing the external reloc type on the
side. (An alternative is to extend the Go object file format to
use a uint16, but it is not necessary for Go relocations and
will waste some binary size.)

Fix ARM build.

Change-Id: I343e240d38ee0e2cc91e0e7754d03b19b525a014
Reviewed-on: https://go-review.googlesource.com/c/go/+/223338
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-13 19:28:06 +00:00
Cherry Zhang
440852c464 [dev.link] all: merge branch 'master' into dev.link
Clean merge.

Change-Id: I2ae070c60c011779a0f0a1344f5b6d45ef10d8a1
2020-03-13 14:45:05 -04:00
Cherry Zhang
e5f7a8334a [dev.link] cmd/link: convert dope to new style
Also convert a manually managed array to slice.

Change-Id: I7d0dd3d5f569ab237893f589b6022f0f351bca16
Reviewed-on: https://go-review.googlesource.com/c/go/+/223337
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-13 17:26:32 +00:00
Keith Randall
d84cbec890 cmd/compile: convert 386 port to use addressing modes pass
Update #36468

Change-Id: Idfdb845d097994689be450d6e8a57fa9adb57166
Reviewed-on: https://go-review.googlesource.com/c/go/+/222782
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2020-03-13 17:00:54 +00:00
zikaeroh
c3b9042132 cmd/cover: skip function declarations with blank names
Function declarations with blank ("_") names do not introduce a binding,
and therefore cannot be referenced or executed (in fact, they do not
make it into the final compiled binary at all). As such, counters
defined while annotating their bodies will always be zero.

These types of functions are commonly used to create compile-time
checks (e.g., stringer) which are not expected to be executed.

Skip over these functions when annotating a file, preventing the unused
counters from being generated and appearing as uncovered lines in
coverage reports.

Fixes #36264

Change-Id: I6b516cf43c430a6248d68d5f483a3902253fbdab
Reviewed-on: https://go-review.googlesource.com/c/go/+/223117
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-13 14:29:27 +00:00
zikaeroh
c6bcdeafd2 cmd/go: check for 'svn' binary in PATH in TestAccidentalGitCheckout
This test requires subversion to run, but does not check to see if it's
available before running as it does for git.

Call testenv.MustHaveExecPath to check beforehand to allow the test to
be skipped if the svn binary does not exist.

Change-Id: I16ae104621b221fc6e96f6c7dcd71bf406caa0c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/223082
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-13 13:52:49 +00:00
Lynn Boger
9d67a94217 cmd/internal/obj/ppc64: clean up some opcodes
This does some clean up of the ppc64 opcodes to remove names
from the opcode list that don't actually assemble. At one time
names were added to this list to represent opcode "classes" to
organize other opcodes that have the same set of operand
combinations. Since this is not documented, it is confusing as
to which opcodes can be used in an asm file and which can't, and
which opcodes should be supported in the disassembler. It is
clearer for the user if the list of Go opcodes are all opcodes
that can be assembled with names that match the ppc64 opcode
where possible.

I found this when trying to use Go opcode XXLAND in an asm file
which seems like it should map to ppc64 xxland but when used it
gets this error:

go tool asm test_xxland.s
asm: bad r/r, r/r/r or r/r/r/r opcode XXLAND
asm: assembly failed

This change removes the opcodes that are only used for opcode
"classes" and fixes the case statement where they are referenced.
This also fixes XXLAND and XXPERM which are opcodes that should
assemble to their corresponding ppc64 opcode but do not.

Change-Id: I52300db6b22f7f8b3dd3491c3f35a384b943352c
Reviewed-on: https://go-review.googlesource.com/c/go/+/223138
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-13 11:41:22 +00:00
Cherry Zhang
cf5c718cba [dev.link] cmd/link: experiment new reloc accessors in deadcode pass
There is a small speedup:

(linking cmd/compile)

name       old time/op    new time/op    delta
Deadcode     57.1ms ± 1%    53.5ms ± 1%   -6.44%  (p=0.008 n=5+5)

With this, we don't need a slice to read the relocations, reduce
some allocations.

name       old alloc/op   new alloc/op   delta
Deadcode     4.16MB ± 0%    3.84MB ± 0%   -7.85%  (p=0.008 n=5+5)

Change-Id: Icd41c05682ba3f293a8cb9d2fe818e39d7276e5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/222244
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-13 01:19:15 +00:00
Cherry Zhang
c951514da9 [dev.link] cmd/internal/goobj2, cmd/link: experiment another way of accessing relocations
Use a different mechanism to access relocations from the object
files, and use it in the stack bounds check pass. This shows some
speedup.

(linking cmd/compile)
Dostkcheck     76.9ms ± 1%    55.1ms ± 1%  -28.36%  (p=0.008 n=5+5)

Change-Id: I2ac42da515dccd64719fb557ffff6cdc69e4319b
Reviewed-on: https://go-review.googlesource.com/c/go/+/222240
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-13 01:04:29 +00:00
Ian Lance Taylor
85e87f9d81 time: stop referring to timerproc in comment
The timerproc function has been removed.

Fixes #37774

Change-Id: Ice5e1d8fec91cd6ee7f032e0d21e8315a26bc6a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/222783
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
2020-03-13 00:19:08 +00:00
Johan Jansson
1f231d74f6 runtime: emit more specific errors from checkptr
Update error messages for pointer alignment checks and pointer
arithmetic checks so that each type of error has a unique error
message.

Fixes #37488

Change-Id: Ida2c2fa3f041a3307d665879a463f9e8f2c1fd03
Reviewed-on: https://go-review.googlesource.com/c/go/+/223037
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-12 23:45:51 +00:00