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

41322 Commits

Author SHA1 Message Date
Cherry Zhang
e44dfa1f2b [dev.link] cmd/link: escape package path in objByPkg map
The package references recorded in the object file, which are
obtained from the compiler, are escaped. We should also use the
escaped package paths in the linker for resolving package
references.

Change-Id: I42eb12df6ff24330e6dc7bed1dc8224bb3b8a106
Reviewed-on: https://go-review.googlesource.com/c/go/+/200158
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-10 22:06:28 +00:00
Cherry Zhang
0108b54a3d [dev.link] cmd/internal/goobj: replace "". with package prefix in newobj mode
This is the behavior of the old code. Do the same.

Change-Id: I3d393d754dcbdb7e76a577252a94214d2e316651
Reviewed-on: https://go-review.googlesource.com/c/go/+/200159
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-10 22:05:44 +00:00
Cherry Zhang
ffca64dcf3 [dev.link] cmd/internal/obj: support -S flag in newobj mode
When the compiler's -S flag is specified, it dumps the
disassembly. Add this when writing the new style object file.

Change-Id: I4cf85e57d22d0ceea1fda6d3b59fe363573659e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/200100
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-10 22:05:21 +00:00
Cherry Zhang
8a9be4921a [dev.link] cmd/link: use index for deadcode
Switch the deadcode pass to use indices instead of Symbol
structures when using new object file format. Delay loading
symbol relocations and contents fully after the deadcode pass.
The next step is not to create Symbol structures until deadcode
is done.

Method tracking logic hasn't been implemented. Currently, all
methods of a reachable type are live.

Change-Id: Iffcd06ff84e6e52bd9eb24d1220d94234d18ab6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/198199
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-10 22:05:09 +00:00
Than McIntosh
f7659d49be [dev.link] cmd/link/internal/objfile: new 'Sym' type for global symbol index
First change of several to update the loader API to reflect the final
consensus version of the loader API as described in Cherry's doc.

This piece:

 - define new loader.Sym type to encapsulate a global symbol
   index (as opposed to just using 'int')

Change-Id: I6f6483e269f80abfc7d373b2856b2c0d61b9ac24
Reviewed-on: https://go-review.googlesource.com/c/go/+/200417
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-10 19:21:40 +00:00
Cherry Zhang
c455e8878f [dev.link] cmd/link: change some decodetype functions to operate on bytes
Change some decodetype functions to operate on bytes nstead of
Symbol. This is in preparation of implementing live method
tracking in index-based deadcode pass, and reducing/eliminating
sym.Symbol in general.

Change-Id: Ia9809ad7b182884225e1bda577e8dbec0cd216c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/199077
Reviewed-by: Austin Clements <austin@google.com>
2019-10-09 21:05:54 +00:00
Cherry Zhang
65a649c565 [dev.link] cmd/link, cmd/internal/goobj2: adopt new DWARF compilation unit logic with new object file
The dev.link branch was not sync'd with the new DWARF compilation
unit logic change on the master branch, and the new object file
format didn't support this.

This CL adds the new DWARF CU and file table support to the new
object file format. In the old object file, the DWARF file table
is a separate section. For now, we do the same with the new
object file, keeping it as a separate block.

While here, also refactor the loader code so it is easier for the
loader to carry per-object informations.

Change-Id: I4c317941fc0a5831acbc11ce8c2a8b7421471372
Reviewed-on: https://go-review.googlesource.com/c/go/+/198198
Reviewed-by: Austin Clements <austin@google.com>
2019-10-09 21:05:20 +00:00
Cherry Zhang
0d7404c852 [dev.link] cmd/link, cmd/internal/goobj2: mmap object file in -newobj mode
With the old object file format, we use mmap (if supported) to
read object files and back symbol data with mapped read-only
memory.

Do the same with the new object file format. This also
significantly reduces number of syscalls made to read object
files.

Currently we still do mmap in object file level, not archive
level. This is probably ok, as there shouldn't be many archives
that contain more than one object. If this is a problem we can
change that later.

Change-Id: Icae3ef14d8ed6adbee1b5b48d420e2af22fd9604
Reviewed-on: https://go-review.googlesource.com/c/go/+/197797
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-09 21:00:08 +00:00
Cherry Zhang
2495095275 [dev.link] cmd/link: load full symbol contents after deadcode pass
If the new object file format is used, now we load full symbol
contents after the deadcode pass, for reachable symbols only.
We still load some informations early, like relocations and the
contents of type symbols, which are used in the deadcode pass.
If we rewrite deadcode to use index directly, we could delay more
of the loading (to sym.Symbol), and perhaps delay the creation of
sym.Symbol.

TODO: internal linking with host objects doesn't work yet.

Change-Id: I7d4880e8f150e8709ffac277e62191623440e4cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/197258
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-09 16:05:40 +00:00
Cherry Zhang
48151b3f0f [dev.link] cmd/link: add symbols to Textp after deadcode pass
Currently we add all text symbols to ctxt.Textp at load time,
then the deadcode pass filters out unreachable ones. This CL
delays adding symbols to ctxt.Textp to the end of the deadcode
pass, where we only add reachable ones.

Change-Id: Ie83b2958f915c5aaa004b8c5ed1f1bc275f4d1db
Reviewed-on: https://go-review.googlesource.com/c/go/+/197257
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-08 19:15:46 +00:00
Cherry Zhang
fcfbe25dca [dev.link] cmd/link: remove runtime.gcbits special case
Follow-up of Than's comment on CL 196032. For runtime.gcbits
symbols, the compiler already sets the "local" attribute
(cmd/compile/internal/gc/reflect.go:dgcptrmask). No need of the
special handling in the linker.

Change-Id: I7c53a818ed0375083f04655f3565c1c9c45f2401
Reviewed-on: https://go-review.googlesource.com/c/go/+/199642
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-08 19:15:17 +00:00
Cherry Zhang
b0d930577e [dev.link] all: merge branch 'master' into dev.link
Weekly merge.

Change-Id: I98c6121f04f347df2788ac5eaf99afad5da4a039
2019-10-04 16:55:52 -04:00
Cherry Zhang
e63c1df348 [dev.link] cmd/link: move some work after deadcode
This is in preparation of delaying loading symbol content to
after dead code elimination.

Change-Id: Ia4ce82d9a42cc1a76c82f6d0eb9a54b0325ee3ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/197061
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-04 20:43:56 +00:00
David Chase
c450ace12c cmd/compile: remove statement marks from secondary calls
Calls are code-generated in an alternate path that inherits
its positions from values, not from *SSAGenState.  The
default position on *SSAGenState was marked as not-a-statement,
but this was not applied to the value itself, leading to
spurious "is statement" marks in the output (convention:
after code generation in the compiler, everything is either
definitely a statement or definitely not a statement, nothing
is in the undetermined state).

This CL causes a 35 statement regression in ssa/stmtlines_test.
This is down from the earlier 150 because of all the other
CLs preceding this one that deal with the root causes of the
missing lines (repeated lines on nested calls hid missing lines).

This also removes some line repeats from ssa/debug_test.

Change-Id: Ie9a507bd5447e906b35bbd098e3295211df2ae01
Reviewed-on: https://go-review.googlesource.com/c/go/+/188018
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-04 20:41:52 +00:00
David Chase
9a926911fe cmd/compile: attempt to preserve statements when prove removes code
This was a cause of some statements being lost.

Change-Id: I81c95dcf3df6ed8a03b7578a27f9b21d33b3cf39
Reviewed-on: https://go-review.googlesource.com/c/go/+/198484
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-04 20:40:43 +00:00
Jason A. Donenfeld
7e4d87b770 syscall: replace mksyscall_windows.go with wrapper to new x/sys home
We replace the existing file with a thin wrapper around its target so
that we don't break anybody's workflow.

Updates #34388

Change-Id: I0d00371c483cb78f4be18fe987df33c79cd40f05
Reviewed-on: https://go-review.googlesource.com/c/go/+/198977
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-04 20:26:09 +00:00
Dmitri Shuralyov
49988bc2e9 doc: remove docs.html
This page has moved to x/website in https://golang.org/cl/197638.

Updates golang/go#33637
Updates golang/go#29206

Change-Id: I4f5f7822a2bf540a3911470548d38ccc7a66b74c
Reviewed-on: https://go-review.googlesource.com/c/go/+/199117
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Jean de Klerk <deklerk@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-10-04 20:21:01 +00:00
David Chase
e06829b977 cmd/compile: preserve statement marks in branch elimination
This reduces the number of missing-statement lines.

Change-Id: Iefa56c2a253220d17d8b53210c8c6af78ee68756
Reviewed-on: https://go-review.googlesource.com/c/go/+/198483
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-04 20:19:44 +00:00
Jay Conrod
86ea7d5171 cmd/go/internal/modfile: report error for extra text around version
Fixes #34697

Change-Id: Iedfa3d46d558510f3bd1fdf9466cd974793d9ecd
Reviewed-on: https://go-review.googlesource.com/c/go/+/199017
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-10-04 20:18:48 +00:00
Jean de Klerk
60dc159cf7 doc: remove code.html
This is being moved to x/website in https://golang.org/cl/199058.

Updates golang/go#33637
Updates golang/go#29206

Change-Id: I5c58b784fcdd212d7a003cd0f4085059f33a47c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/199057
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-10-04 20:09:41 +00:00
Bryan C. Mills
961837dec2 Revert "cmd/go: add a Latest field to the output of 'go mod download -json'"
This reverts CL 183841.

Fixes #34533

Reason for revert: Introduced a significant performance regression for repos with many incompatible-version tags.

Change-Id: I75d7fd76e6e1a0902b114b00167b38439e0f8221
Reviewed-on: https://go-review.googlesource.com/c/go/+/198699
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-10-04 20:06:56 +00:00
Cuong Manh Le
047141797c cmd/compile: lookup methods of base type for named pointer type
Passed toolstash-check.

Updates #21738
Fixes #21934

Change-Id: I59f0b2c9890146565ff913b04aeeeff7dc7a4499
Reviewed-on: https://go-review.googlesource.com/c/go/+/197561
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-04 18:34:18 +00:00
Brad Fitzpatrick
0fb95e788e crypto/tls: remove NPN support
RELNOTE=yes

Fixes #28362

Change-Id: I43813c0c17bbe6c4cbb4d1f121518c434b3f5aa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/174329
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2019-10-04 18:07:46 +00:00
David Chase
91b55b4fa3 cmd/compile: attempt to preserve statement marks when empty blocks are trimmed.
This was a cause of some statements being lost.

Change-Id: Ia4805c2dafd7a880d485a678a48427de8930d57e
Reviewed-on: https://go-review.googlesource.com/c/go/+/198482
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-04 17:31:51 +00:00
Jordi Martin
3ce29b44bb cmd/go: set expected filename when building a local package with -o is pointing to a folder
In the local package build process, when -o is pointing to an existing folder, the object
the filename is generated from files listed on the command line like when the -o is
not pointing to a folder instead of using the `importPath` that is going to be `command-line-arguments`

Fixes #34535

Change-Id: I09a7609c17a2ccdd83da32f01247c0ef473dea1e
GitHub-Last-Rev: b3224226a3
GitHub-Pull-Request: golang/go#34562
Reviewed-on: https://go-review.googlesource.com/c/go/+/197544
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-10-04 17:30:40 +00:00
Cuong Manh Le
43a4c61e12 cmd/compile: update comment in order.go to refer new methods/functions
Change-Id: I2d6b73ae7447e4bdeffcdac90f7422a9280666e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/198678
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-10-04 17:26:05 +00:00
David Chase
c8e7c53b40 cmd/compile: preserve statement mark in rematerialized values
Statement markers on rematerializable values were getting lost in
register allocation.  This checks for that case (rematerializable
input and using value share line number, but mark is on the input)
and preserves the mark.

When combined with other CLs in this series, this CL reduces the
"nostmt" count (a line appears in the assembly, but no statement
marker) for cmd/go from 413 to 277.  The rematerialized input is
usually a LEAQ (on AMD64).

The cause is "complicated"; for example, a NilCheck originally has the
statement mark (a good thing, if the NilCheck  remains) but the
NilCheck is removed and the mark floats to a Block end, then to a
SliceMake.  The SliceMake decomposes and goes dead without preserving
its marker (its component values are elided in other rewrites and may
target inputs with different line numbers), but before deadcode
removes it from the graph it moves the mark to an input, which at that
time happens to be a LocalAddr. This eventually transforms to a LEAQ.

Change-Id: Iff91fc2a934357fb59ec46ac87b4a9b1057d9160
Reviewed-on: https://go-review.googlesource.com/c/go/+/198480
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-04 17:09:10 +00:00
David Chase
33ab6ccba0 cmd/compile: don't attach statement marks to OpPhi
OpPhi nodes tend to disappear or get rearranged,
and cause statement marks to vanish.

Change-Id: I2f5a222903b7fcd0d1a72e8f6d7e156036b23f30
Reviewed-on: https://go-review.googlesource.com/c/go/+/198481
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-04 16:54:10 +00:00
Vojtech Bocek
72dc3a0919 crypto/x509: truncate signed hash before DSA signature verification
According to spec, the hash must be truncated, but crypto/dsa
does not do it. We can't fix it in crypto/dsa, because it would break
verification of previously generated signatures.
In crypto/x509 however, go can't generate DSA certs, only verify them,
so the fix here should be safe.

Fixes #22017

Change-Id: Iee7e20a5d76f45da8901a7ca686063639092949f
GitHub-Last-Rev: 8041cde8d2
GitHub-Pull-Request: golang/go#34630
Reviewed-on: https://go-review.googlesource.com/c/go/+/198138
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2019-10-04 16:27:55 +00:00
Bryan C. Mills
6145a80608 cmd/go: remove the -mod flag from 'go get'
'GOFLAGS=-mod=vendor' currently causes 'go get' to always fail unless
the '-mod' flag is explicitly overwritten. Moreover, as of CL 198319
we plan to set -mod=vendor by default if a vendor directory is
present, so all users with vendor directories will be affected — not
just those who set 'GOFLAGS' explicitly.

Similarly, an explicit '-mod=readonly' argument to 'go get' is
currently ignored as a special case, but the fact that it is ignored
(rather than rejected) can be very surprising.

Rather than adding more special cases, we should remove the '-mod'
flag from 'go get' entirely.

Fixes #30345
Fixes #32502
Updates #33848

Change-Id: Iecd3233ca3ef580ca3a66bd5e6ee8d86d4cbd8a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/198438
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-10-04 15:47:46 +00:00
Cherry Zhang
6051fd0ad9 [dev.link] cmd/link: support new object file format
Parse new object file format in the linker. At least we can link
a hello-world program.

Add a basic "loader", which handles symbol references in the
object file.
- mapping between local and global indices
- resolve by-name references
  (TODO: the overwrite logic isn't implemented yet)

Currently we still create sym.Symbol rather early, and, after all
the object files are loaded and indexed references are resolved,
add all symbols to sym.Symbols.

The code here is probably not going in the final version. This
is basically only for debugging purposes -- to make sure the
writer and the reader work as expected.

Change-Id: I895aeea68326fabdb7e5aa1371b8cac7211a09dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/196032
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-04 15:21:40 +00:00
Alberto Donizetti
c1e46af62f test: add testcase for Issue 34520
CL 188317 introduced a compiler crash during dwarf generation which
was reported as Issue #34520. After CL 188217, the issue appears to be
fixed. Add a testcase to avoid future regressions.

Fixes #34520

Change-Id: I73544a9e9baf8dbfb85c19eb6d202beea05affb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/198546
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2019-10-04 15:04:57 +00:00
Duco van Amstel
8c74bfb491 cmd/go: fix listing of ambiguous paths
Passing ambiguous patterns, ending in `.go`, to `go list` results in them
being interpreted as Go files despite potentially being package references.
This can then result in errors on other package references.

The parsing logic is modified to check for a locally present file
corresponding to any pattern ending in `.go`. If no such file is present
the pattern is considered to be a package reference.

We're also adding a variety of non-regression tests that fail with the
original parsing code but passes after applying the fix.

Fixes #32483
Fixes #34653

Change-Id: I073871da0dfc5641a359643f95ac14608fdca09b
GitHub-Last-Rev: 5abc200103
GitHub-Pull-Request: golang/go#34663
Reviewed-on: https://go-review.googlesource.com/c/go/+/198459
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-10-04 13:47:53 +00:00
Josh Bleecher Snyder
a7042249ab os/exec: simplify doc wording for cmd.StdoutPipe and cmd.StderrPipe
The existing text was hard to parse.
Shorten the sentences and simplify the text.

Change-Id: Ic16f486925090ea303c04e70969e5a4b27a60896
Reviewed-on: https://go-review.googlesource.com/c/go/+/198758
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-10-04 00:22:44 +00:00
Cherry Zhang
d79380026c [dev.link] cmd/internal/goobj: support parsing new object file
Add support of parsing new object file format. We use the new
parser if the magic string matches the new one, otherwise use the
old one.

The parsed data are still filled into the current goobj API. In
the future we may consider to change the goobj API to a close
match of the object file data.

Now objdump and nm commands support new object file format.

For a reference to a symbol defined in another package, with the
new object file format we don't know its name. Write it as
pkg.<#nn> for now, where nn is its symbol index.

Change-Id: I06d05b2ca834ba36980da3c5d76aee16c3b0a483
Reviewed-on: https://go-review.googlesource.com/c/go/+/196031
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-03 21:25:48 +00:00
David Chase
adc4d2cc2d cmd/compile: run deadcode before nilcheck for better statement relocation
Nilcheck would move statements from NilCheck values to others that
turned out were already dead, which leads to lost statements.  Better
to eliminate the dead code first.

One "error" is removed from test/prove.go because the code is
actually dead, and the additional deadcode pass removes it before
prove can run.

Change-Id: If75926ca1acbb59c7ab9c8ef14d60a02a0a94f8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/198479
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-03 21:12:13 +00:00
David Chase
08a87938bb cmd/compile: make nilcheck more careful about statement relocations
The earlier code was picking nodes that were "poor choices" and
thus sometimes losing statements altogether.

Change-Id: Ibe5ed800ffbd3c926c0ab1bc10c77d72d3042e45
Reviewed-on: https://go-review.googlesource.com/c/go/+/198478
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-03 21:10:26 +00:00
David Chase
53bd915109 cmd/compile: classify more nodes as "poor choices" for statements
Aggregate-making nodes that are later decomposed
are poor choices for statements, because the decomposition
phase turns them into multiple sub-values, some of which may be
dead.  Better to look elsewhere for a statement mark.

Change-Id: Ibd9584138ab3d1384548686896a28580a2e43f54
Reviewed-on: https://go-review.googlesource.com/c/go/+/198477
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-10-03 21:08:27 +00:00
David Chase
6139019efa cmd/compile: pick position of implicit break statements more carefully
The previous version used the position of the switch statement,
which makes for potentially jumpy stepping and introduces a large
number of statements repeating the line (tricky for inserting
breaks).  It also shared a single OBREAK node and this was not
really a syntax "tree".

This improves both the nostmt test (by 6 lines) and
reduces the total badness score from dwarf-goodness (by about 200).

Change-Id: I1f71b231a26f152bdb6ce9bc8f95828bb222f665
Reviewed-on: https://go-review.googlesource.com/c/go/+/188218
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-03 21:07:45 +00:00
David Chase
f7f85bdc2c cmd/compile: refine statement marking in numberlines
1) An empty block is treated as not-a-statement unless its line differs
from at least one of its predecessors (it might make sense to
rearrange branches in predecessors, but that is a different issue).

2) When iterating forward to choose a "good" place for a statement,
actually check that the chosen place is in fact good.

3) Refactor same line and same file into methods on XPos and Pos.

This reduces the failure rate of ssa/stmtlines_test by 7-ish lines.
(And interacts favorably with later debugging CLs.)

Change-Id: Idb7cca7068f6fc9fbfdbe25bc0da15bcfc7b9d4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/188217
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-03 21:06:11 +00:00
Matthew Dempsky
3ad350820d cmd/compile: change size diagnostic to use benchmark format
Makes it easier to run

    go build -a -gcflags=-d=export std |& grep ^BenchmarkExportSize

and get useful output for feeding into benchstat.

Change-Id: I2b52e8f5ff33b7ccb6c25b18e464513344bd9ad9
Reviewed-on: https://go-review.googlesource.com/c/go/+/198698
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-10-03 20:43:01 +00:00
Meng Zhuo
a1b1ba7daf internal/bytealg: (re)adding mips64x compare implementation
The original CL of mips64x compare function has been reverted due to wrong
implement for little endian.
Original CL: https://go-review.googlesource.com/c/go/+/196837

name                         old time/op    new time/op    delta
BytesCompare/1                 28.9ns ± 4%    22.1ns ± 0%    -23.60%  (p=0.000 n=9+8)
BytesCompare/2                 34.6ns ± 0%    23.1ns ± 0%    -33.25%  (p=0.000 n=8+10)
BytesCompare/4                 54.6ns ± 0%    40.8ns ± 0%    -25.27%  (p=0.000 n=8+8)
BytesCompare/8                 73.9ns ± 0%    49.1ns ± 0%    -33.56%  (p=0.000 n=8+8)
BytesCompare/16                 113ns ± 0%      24ns ± 0%    -79.20%  (p=0.000 n=9+9)
BytesCompare/32                 190ns ± 0%      26ns ± 0%    -86.53%  (p=0.000 n=10+10)
BytesCompare/64                 345ns ± 0%      44ns ± 0%    -87.19%  (p=0.000 n=10+8)
BytesCompare/128                654ns ± 0%      52ns ± 0%    -91.97%  (p=0.000 n=9+8)
BytesCompare/256               1.27µs ± 0%    0.07µs ± 0%    -94.14%  (p=0.001 n=8+9)
BytesCompare/512               2.51µs ± 0%    0.12µs ± 0%    -95.26%  (p=0.000 n=9+10)
BytesCompare/1024              4.99µs ± 0%    0.21µs ± 0%    -95.85%  (p=0.000 n=8+10)
BytesCompare/2048              9.94µs ± 0%    0.38µs ± 0%    -96.14%  (p=0.000 n=8+8)
CompareBytesEqual               105ns ± 0%      64ns ± 0%    -39.43%  (p=0.000 n=10+9)
CompareBytesToNil              34.8ns ± 1%    38.6ns ± 3%    +11.01%  (p=0.000 n=10+10)
CompareBytesEmpty              33.6ns ± 3%    36.6ns ± 0%     +8.77%  (p=0.000 n=10+8)
CompareBytesIdentical          29.7ns ± 0%    40.5ns ± 1%    +36.45%  (p=0.000 n=10+8)
CompareBytesSameLength         69.1ns ± 0%    51.8ns ± 0%    -25.04%  (p=0.000 n=10+9)
CompareBytesDifferentLength    69.8ns ± 0%    52.5ns ± 0%    -24.79%  (p=0.000 n=10+8)
CompareBytesBigUnaligned       5.15ms ± 0%    2.19ms ± 0%    -57.59%  (p=0.000 n=9+9)
CompareBytesBig                5.28ms ± 0%    0.28ms ± 0%    -94.64%  (p=0.000 n=8+8)
CompareBytesBigIdentical       29.7ns ± 0%    36.9ns ± 2%    +24.11%  (p=0.000 n=8+10)

name                         old speed      new speed      delta
CompareBytesBigUnaligned      204MB/s ± 0%   480MB/s ± 0%   +135.77%  (p=0.000 n=9+9)
CompareBytesBig               198MB/s ± 0%  3704MB/s ± 0%  +1765.97%  (p=0.000 n=8+8)
CompareBytesBigIdentical     35.3TB/s ± 0%  28.4TB/s ± 2%    -19.44%  (p=0.000 n=8+10)

Fixes #34549

Change-Id: I2ef29f13cdd4229745ac2d018bb53c76f2ff1209
Reviewed-on: https://go-review.googlesource.com/c/go/+/197557
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-03 20:32:21 +00:00
Meng Zhuo
2bf7a92571 cmd/asm: add VLD[1-4]R vector instructions on arm64
This change adds VLD1R, VLD2R, VLD3R, VLD4R

Change-Id: Ie19e9ae02fdfc94b9344acde8c9938849efb0bf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/181697
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-10-03 20:31:11 +00:00
Cherry Zhang
2c484c0356 [dev.link] cmd/internal/obj: write object file in new format
If -newobj is set, write object file in new format, which uses
indices for symbol references instead of symbol names. The file
format is described at the beginning of
cmd/internal/goobj2/objfile.go.

A new package, cmd/internal/goobj2, is introduced for reading and
writing new object files. (The package name is temporary.) It is
written in a way that trys to make the encoding as regular as
possible, and the reader and writer as symmetric as possible.

This is incomplete, and currently nothing will consume the new
object file.

Change-Id: Ifefedbf6456d760d15a9f40a28af6486c93100fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/196030
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-03 18:49:41 +00:00
Bryan C. Mills
5fe3b49a05 Revert "cmd/compile: walk the progs to generate debug_lines"
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-03 18:18:14 +00:00
Matthew Dempsky
c33d45a898 cmd/compile: don't statically copy string-typed variables
During package initialization, the compiler tries to optimize:

    var A = "foo"
    var B = A

into

    var A = "foo"
    var B = "foo"

so that we can statically initialize both A and B and skip emitting
dynamic initialization code to assign "B = A".

However, this isn't safe in the presence of cmd/link's -X flag, which
might overwrite an initialized string-typed variable at link time. In
particular, if cmd/link changes A's static initialization, it won't
know it also needs to change B's static initialization.

To address this, this CL disables this optimization for string-typed
variables.

Fixes #34675.

Change-Id: I1c18f3b855f6d7114aeb39f96aaaf1b452b88236
Reviewed-on: https://go-review.googlesource.com/c/go/+/198657
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-03 18:08:32 +00:00
Jason A. Donenfeld
6b85fa8051 runtime: iterate ms via allm linked list to avoid race
It's pointless to reach all ms via allgs, and doing so introduces a
race, since the m member of a g can change underneath it. Instead
iterate directly through the allm linked list.

Updates: #31528
Updates: #34130

Change-Id: I34b88402b44339b0a5b4cd76eafd0ce6e43e2be1
Reviewed-on: https://go-review.googlesource.com/c/go/+/198417
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-03 15:55:39 +00:00
Cherry Zhang
a09cd8ccb3 [dev.link] cmd/compile: fix data race on LSym.Pkg
LSym may be created concurrently. Reading/writing LSym.Pkg may
cause data race (see
https://build.golang.org/log/f0351c5cc7bf4c92e3aa5e78e294c2d009ebf118).
Fix this by setting LSym.Pkg only when holding the lock.

Change-Id: Ib3160ecf47c4ca530b09369e0e8284db6597cfd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/198492
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-03 14:14:43 +00:00
Jeremy Faller
9e6a84f2b1 cmd/compile: walk the progs to generate debug_lines
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-10-03 14:09:40 +00:00
Tobias Klauser
64785bf96c cmd/go/internal/modfetch: update TestCodeRepo for gopkg.in/yaml.v2 again
Update the expected data to fix the longtest builder.

Updates #28856

Change-Id: I7fb6ee72e8469d974561b4b4057f40142f5b3654
Reviewed-on: https://go-review.googlesource.com/c/go/+/198557
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-10-03 12:52:41 +00:00