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

12313 Commits

Author SHA1 Message Date
Heschi Kreinick
726a2d04ea cmd/link: support DWARF compression on Darwin
We want to compress DWARF even on macOS, but the native toolchain isn't
going to understand it. Add a flag that can be used to disable
compression, then add Darwin to the whitelist used during internal
linking.

Unlike GNU ld, the Darwin linker doesn't have a handy linker flag to do
compression. But since we're already doing surgery to put the DWARF in
the output executable in the first place, compressing it at the same
time isn't unduly difficult. This does have the slightly odd effect of
compressing some Apple proprietary debug sections, which absolutely
nothing will understand. Leaving them uncompressed didn't make much
sense, though, since I doubt they're useful without (say) __debug_info.

Updates #11799

Change-Id: Ie00b0215c630a798c59d009a641e2d13f0e7ea01
Reviewed-on: https://go-review.googlesource.com/120155
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-06-22 19:16:14 +00:00
Brad Fitzpatrick
7d50abf039 cmd/dist: skip non-std tests on js/wasm
After the std tests, most of the rest of the tests aren't applicable
to js/wasm. (anything with -cpu=>1, cgo, etc)

Skip them all for now. We can incrementally re-enable them over time
as the js/wasm port is fleshed out. But let's get the builder column
black again so we can enable trybots and keep it black.

Updates #26014
Updates #26015
Updates #18892

Change-Id: I8992ed3888f598fa42273ce8646a32d62ce45b1d
Reviewed-on: https://go-review.googlesource.com/120575
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-06-22 17:58:10 +00:00
Matthew Dempsky
f422bea498 cmd/compile: fix compile failure for lazily resolved shadowed types
If expanding an inline function body required lazily expanding a
package-scoped type whose identifier was shadowed within the function
body, the lazy expansion would instead overwrite the local symbol
definition instead of the package-scoped symbol. This was due to
importsym using s.Def instead of s.PkgDef.

Unfortunately, this is yet another consequence of the current awkward
scope handling code.

Passes toolstash-check.

Fixes #25984.

Change-Id: Ia7033e1749a883e6e979c854d4b12b0b28083dd8
Reviewed-on: https://go-review.googlesource.com/120456
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-22 17:57:09 +00:00
Cherry Zhang
78a579316b cmd/compile: convert uint32 to int32 in ARM constant folding rules
MOVWconst's AuxInt is Int32. SSA check complains if the AuxInt
does not fit in int32. Convert uint32 to int32 to make it happy.

The generated code is unchanged. MOVW only cares low 32 bits.

Passes "toolstash -cmp" std cmd for ARM.

Fixes #25993.

Change-Id: I2b6532c9c285ea6d89652505fb7c553f85a98864
Reviewed-on: https://go-review.googlesource.com/120335
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-06-22 16:25:32 +00:00
Ian Lance Taylor
00eac8921e os, net: avoid races between dup, set-blocking-mode, and closing
Fixes #24481
Fixes #24483

Change-Id: Id7da498425a440c91582aa5480c253ae7a9c932c
Reviewed-on: https://go-review.googlesource.com/119955
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-22 14:27:22 +00:00
Matthew Dempsky
011ea87921 cmd/compile: fix recursive inimport handling
expandDecl can be called recursively, so it's not an appropriate place
to clean inimport. Instead, move this up to resolve, along with an
appropriate recursion check.

Passes toolstash-check.

Change-Id: I138d37b057dcc6525c780b4b3fbaa5e97f99655b
Reviewed-on: https://go-review.googlesource.com/120455
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-21 23:57:55 +00:00
Ian Lance Taylor
1507502ff2 cmd/go: re-enable a couple of tests of gccgo
Updates #22472

Change-Id: I526d131f2ef8e0200f7a5634c75b31e0ee083f93
Reviewed-on: https://go-review.googlesource.com/120375
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-21 19:35:27 +00:00
Wei Xiao
0a7ac93c27 cmd/compile: improve atomic add intrinsics with ARMv8.1 new instruction
ARMv8.1 has added new instruction (LDADDAL) for atomic memory operations. This
CL improves existing atomic add intrinsics with the new instruction. Since the
new instruction is only guaranteed to be present after ARMv8.1, we guard its
usage with a conditional on CPU feature.

Performance result on ARMv8.1 machine:
name        old time/op  new time/op  delta
Xadd-224    1.05µs ± 6%  0.02µs ± 4%  -98.06%  (p=0.000 n=10+8)
Xadd64-224  1.05µs ± 3%  0.02µs ±13%  -98.10%  (p=0.000 n=9+10)
[Geo mean]  1.05µs       0.02µs       -98.08%

Performance result on ARMv8.0 machine:
name        old time/op  new time/op  delta
Xadd-46      538ns ± 1%   541ns ± 1%  +0.62%  (p=0.000 n=9+9)
Xadd64-46    505ns ± 1%   508ns ± 0%  +0.48%  (p=0.003 n=9+8)
[Geo mean]   521ns        524ns       +0.55%

Change-Id: If4b5d8d0e2d6f84fe1492a4f5de0789910ad0ee9
Reviewed-on: https://go-review.googlesource.com/81877
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-06-21 14:52:43 +00:00
Agniva De Sarker
f3f7bd5558 cmd/go/internal: add a note about GOCACHE=off
Fixes #25928

Change-Id: I1401ecc54af26eeeee648bb8eeb5d2d3566fa60c
Reviewed-on: https://go-review.googlesource.com/119695
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-20 20:29:55 +00:00
Agniva De Sarker
e4a50ce97a cmd/go: remove inadvertent comment for vgo
This change was introduced while adding the dark copy
of golang.org/x/vgo in CL 118095.

While the comment made sense in a separate vgo repo, when it is
merged with the main repo, this should not remain.

Found while running mkalldocs.sh in CL 119695.

Change-Id: I112a4629c415032bd29e165ac1c27a0f3cabeede
Reviewed-on: https://go-review.googlesource.com/119938
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-20 14:45:17 +00:00
Heschi Kreinick
83515df3f3 cmd/link: enable DWARF compression on Windows
Simple follow-on to CL 118276. Everything worked except that the
compressed sections need to be aligned at PEFILEALIGN.

Fixes #25927
Updates #11799

Change-Id: Iec871defe30e3e66055d64a5ae77d5a7aca355f5
Reviewed-on: https://go-review.googlesource.com/119816
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-06-19 22:13:43 +00:00
David Chase
c6e455bb11 cmd/compile: conditional on -race, disable inline of go:norace
Adds the appropriate check to inl.go.
Includes tests of both -race+go:norace and plain go:norace.

Fixes #24651.

Change-Id: Id806342430c20baf4679a985d12eea3b677092e0
Reviewed-on: https://go-review.googlesource.com/119195
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-06-19 20:59:10 +00:00
Robert Griesemer
707ca18d97 cmd/compile: more accurate position for select case error message
Fixes #25958.

Change-Id: I1f4808a70c20334ecfc4eb1789f5389d94dcf00e
Reviewed-on: https://go-review.googlesource.com/119755
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-19 17:52:23 +00:00
Carlos Eduardo Seo
1caa06299c runtime: implement procyield properly for ppc64x
The procyield() function should yield the processor as in other
architectures. On ppc64x, this is achieved by setting the Program
Priority Register to 'low priority' prior to the spin loop, and
setting it back to 'medium-low priority' afterwards.

benchmark                          old ns/op     new ns/op     delta
BenchmarkMakeChan/Byte-8           87.7          86.6          -1.25%
BenchmarkMakeChan/Int-8            107           106           -0.93%
BenchmarkMakeChan/Ptr-8            201           204           +1.49%
BenchmarkMakeChan/Struct/0-8       78.2          79.7          +1.92%
BenchmarkMakeChan/Struct/32-8      196           200           +2.04%
BenchmarkMakeChan/Struct/40-8      236           230           -2.54%
BenchmarkChanNonblocking-8         8.64          8.85          +2.43%
BenchmarkChanUncontended-8         5577          5598          +0.38%
BenchmarkChanContended-8           66106         51529         -22.05%
BenchmarkChanSync-8                451           441           -2.22%
BenchmarkChanSyncWork-8            9155          9170          +0.16%
BenchmarkChanProdCons0-8           1585          1083          -31.67%
BenchmarkChanProdCons10-8          1094          838           -23.40%
BenchmarkChanProdCons100-8         831           657           -20.94%
BenchmarkChanProdConsWork0-8       1471          941           -36.03%
BenchmarkChanProdConsWork10-8      1033          721           -30.20%
BenchmarkChanProdConsWork100-8     730           511           -30.00%
BenchmarkChanCreation-8            135           128           -5.19%
BenchmarkChanSem-8                 602           463           -23.09%
BenchmarkChanPopular-8             3017466       2188441       -27.47%

Fixes #25625

Change-Id: Iacb1c888d3c066902152b8367500348fb631c5f9
Reviewed-on: https://go-review.googlesource.com/115376
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-19 16:39:52 +00:00
Robert Griesemer
f125052ad5 cmd/compile: fix exporting of 'for' loops
The existing code for encoding 'for' loops in exported, inlineable
functions incorrectly assumed that the 'Right' field points to an
'expression' node. Adjusted the code to be able to handle any kind
of node. Made matching changes for the binary and indexed exporter.

This only shows up together with other pending compiler changes that
enable exporting of such functions which contain for loops.

No tests yet because we can't test this w/o those pending compiler
changes. Once those changes are in, this code will be tested implicitly.
However, the changes were tested manually together with the patches
described in the issue.

Fixes #25222.

Change-Id: I54babb87e5d665d2c1ef6116c1de1b8c50b1138e
Reviewed-on: https://go-review.googlesource.com/119595
Reviewed-by: David Chase <drchase@google.com>
2018-06-19 16:35:58 +00:00
Hiroshi Ioka
741dad28cb cmd/cgo: avoid name confliction for C functions
Use more cryptic names for local variables inside C function wrappers.

Fixes #23356

Change-Id: Ia6a0218f27a13be14f589b1a0facc9683d22ff56
Reviewed-on: https://go-review.googlesource.com/86495
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-18 18:28:02 +00:00
Rob Pike
b7d9e6e149 cmd/cover: fix off-by-one in test error message
Drive-by after previous CL.

Change-Id: I87db65b65745a0d76500cce06ac276b0d7928404
Reviewed-on: https://go-review.googlesource.com/119395
Reviewed-by: Ralph Corderoy <ralph@inputplus.co.uk>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-18 11:53:40 +00:00
Brad Fitzpatrick
9a91713090 cmd/dist: don't test Examples for js/wasm
Fixes #25913

Change-Id: I4701ec94fa4b07211a8beed85c02ee5aa4fe3eb3
Reviewed-on: https://go-review.googlesource.com/119377
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
2018-06-17 20:45:54 +00:00
Yury Smolsky
b459e00454 cmd/compile: add more color choices to ssa.html
It is possible to highlight up to 12 SSA values
and outlinte up to 11 SSA blocks.

Change-Id: Ifefb813ba07ee8856681552b77199f409e03d74d
Reviewed-on: https://go-review.googlesource.com/119318
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2018-06-16 13:35:45 +00:00
Keith Randall
5b5473c6bf runtime: move semaphore ops from system calls to libc calls on Darwin
This CL removes the last of the direct system calls in the runtime package.
This is the last CL for 1.11.

Use libcCall instead of asmcgocall in a few places I accidentally used
the wrong one.

For 1.12, we need to think about whether/how the syscall package
should be moved over to libc.

Update #17490

Change-Id: I4f0bd9cd6023f662f2e29588266fdfae5233898f
Reviewed-on: https://go-review.googlesource.com/118736
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-16 00:58:37 +00:00
Heschi Kreinick
594eae5ad0 cmd/link: compress DWARF sections in ELF binaries
Forked from CL 111895.

The trickiest part of this is that the binary layout code (blk,
elfshbits, and various other things) assumes a constant offset between
symbols' and sections' file locations and their virtual addresses.
Compression, of course, breaks this constant offset. But we need to
assign virtual addresses to everything before compression in order to
resolve relocations before compression. As a result, compression needs
to re-compute the "address" of the DWARF sections and symbols based on
their compressed size. Luckily, these are at the end of the file, so
this doesn't perturb any other sections or symbols. (And there is, of
course, a surprising amount of code that assumes the DWARF segment
comes last, so what's one more place?)

Relevant benchmarks:
name        old time/op     new time/op     delta
StdCmd          10.3s ± 2%      10.8s ± 1%   +5.43%  (p=0.000 n=30+30)

name        old text-bytes  new text-bytes  delta
HelloSize       746kB ± 0%      746kB ± 0%     ~     (all equal)
CmdGoSize      8.41MB ± 0%     8.41MB ± 0%     ~     (all equal)
[Geo mean]     2.50MB          2.50MB        +0.00%

name        old data-bytes  new data-bytes  delta
HelloSize      10.6kB ± 0%     10.6kB ± 0%     ~     (all equal)
CmdGoSize       252kB ± 0%      252kB ± 0%     ~     (all equal)
[Geo mean]     51.5kB          51.5kB        +0.00%

name        old bss-bytes   new bss-bytes   delta
HelloSize       125kB ± 0%      125kB ± 0%     ~     (all equal)
CmdGoSize       145kB ± 0%      145kB ± 0%     ~     (all equal)
[Geo mean]      135kB           135kB        +0.00%

name        old exe-bytes   new exe-bytes   delta
HelloSize      1.60MB ± 0%     1.05MB ± 0%  -34.39%  (p=0.000 n=30+30)
CmdGoSize      16.5MB ± 0%     11.3MB ± 0%  -31.76%  (p=0.000 n=30+30)
[Geo mean]     5.14MB          3.44MB       -33.08%

Fixes #11799.
Updates #6853.

Change-Id: I64197afe4c01a237523a943088051ee056331c6f
Reviewed-on: https://go-review.googlesource.com/118276
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-15 20:01:53 +00:00
Heschi Kreinick
b397f633ca cmd/link: compress debug sections in external linking mode
Forked from CL 111895.

For #11799.

Change-Id: Ie1346ac2c9122de494823b9058df3a0971e9dfe1
Reviewed-on: https://go-review.googlesource.com/118277
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-06-15 19:28:14 +00:00
Brad Fitzpatrick
3b0b3a0223 cmd/link: add buildid to wasm modules
Add Go buildids into a custom wasm section ("go.buildid", arbitrarily)
early in the wasm module, right after the magic & version.

Fixes #25910

Change-Id: If3f7cb267bf8c7beb6fa8d8b7a4829419720bbd8
Reviewed-on: https://go-review.googlesource.com/119175
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2018-06-15 19:25:02 +00:00
Russ Cox
5756895877 cmd/go: add dark copy of golang.org/x/vgo
This CL corresponds to golang.org/cl/118096 (7fbc8df48a7)
in the vgo repo.

It copies the bulk of the code from vgo back into the main repo,
but completely disabled - vgo.Init is a no-op and vgo.Enabled
returns false unconditionally.

The point of this CL is to make the two trees easier to diff and
to make future syncs smaller.

Change-Id: Ic34fd5ddd8272a70c5a3b3437b5169e967d0ed03
Reviewed-on: https://go-review.googlesource.com/118095
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-06-15 18:57:58 +00:00
Misty De Meo
1a92cdbfc1 ld/macho: add all missing load commands
The ld/macho code currently understands a subset of the mach-o load
commands. I've encountered one of these in the wild in a Go-produced
binary, which tripped up the Go linker because its switch statement
expects its list of load commands to be exhaustive; the rest I've
added for the sake of completion.

The ruby-macho library is a good non-Darwin header resource for these:
https://github.com/homebrew/ruby-macho

Fixes #25908

Change-Id: Ib54c065d27e87d8726a9870df05a2bae24828b98
GitHub-Last-Rev: 655e3f488a
GitHub-Pull-Request: golang/go#25906
Reviewed-on: https://go-review.googlesource.com/119115
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-15 18:18:40 +00:00
Richard Musiol
4eb1c84752 cmd/link: fix name section of WebAssembly binary
Chrome and Node.js were not showing the names of WebAssembly
functions any more. This was due to the name section containing
names also for import functions, which is redundant.

Change-Id: I2f2b2d0b5bd7a59b34f108d2fd7b6ba2eb26f9c9
Reviewed-on: https://go-review.googlesource.com/118976
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-15 02:09:44 +00:00
Austin Clements
8998c55ec0 cmd/link: separate virtual address layout from file layout
Currently these two forms of layout are done in a single pass. This
makes it difficult to compress DWARF sections because that must be
done after relocations are applied, which must happen after virtual
address layout, but we can't layout the file until we've compressed
the DWARF sections.

Fix this by separating the two layout steps. In the process, we can
also unify the copy-pasted code in Link.address to compute file
offsets, which currently has some unnecessary variation.

Unlike the current file offset computation, which depends on virtual
addresses, the new computation only uses file offsets and sizes. This
will let us compress the file representation of a segment and create
the file layout based on its on-disk size rather than its original
in-memory size.

Tested by comparing the test binary for the "strings" package on all
supported GOOS/GOARCH combinations. All binaries are identical
(except, of course, their build IDs).

This is a second attempt at CL 111682.

For #11799.
Fixes #25863.

Change-Id: If09f28771bb4d78dd392fd58b8d7c9d5f22b0b9e
Reviewed-on: https://go-review.googlesource.com/118716
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-15 02:01:04 +00:00
Richard Musiol
c12399fffb all: enable vet/all for js/wasm and fix vet issues
This commit enables vet/all for the js/wasm architecture. It got
skipped initially because the codebase did not fully compile yet
for js/wasm, which made vet/all fail.

startTimer and stopTimer are not needed in the syscall package.
Removed their assembly code since their Go stubs were already gone.

Change-Id: Icaeb6d903876e51ceb1edff7631f715a98c28696
Reviewed-on: https://go-review.googlesource.com/118657
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-15 00:05:22 +00:00
Richard Musiol
e083dc6307 runtime, sycall/js: add support for callbacks from JavaScript
This commit adds support for JavaScript callbacks back into
WebAssembly. This is experimental API, just like the rest of the
syscall/js package. The time package now also uses this mechanism
to properly support timers without resorting to a busy loop.

JavaScript code can call into the same entry point multiple times.
The new RUN register is used to keep track of the program's
run state. Possible values are: starting, running, paused and exited.
If no goroutine is ready any more, the scheduler can put the
program into the "paused" state and the WebAssembly code will
stop running. When a callback occurs, the JavaScript code puts
the callback data into a queue and then calls into WebAssembly
to allow the Go code to continue running.

Updates #18892
Updates #25506

Change-Id: Ib8701cfa0536d10d69bd541c85b0e2a754eb54fb
Reviewed-on: https://go-review.googlesource.com/114197
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-14 21:50:53 +00:00
Rob Pike
5fdacfa89f cmd/cover: remove use of diff in cover_test.go
It's non-portable, and the test isn't hard to write without diff.
It still produces helpful output in case of trouble:

--- FAIL: TestCoverHTML (0.75s)
    cover_test.go:325: line 4 differs: got:
        	case &lt;-ch:<span class="cov0" title="0"></span>
        want:
        	case &lt;-ch:<span class="cov0" xitle="0"></span>

This makes the test operating-system independent.

Change-Id: Iff35f00cb76ba89bc1b93db01c6f994e74341f4a
Reviewed-on: https://go-review.googlesource.com/118795
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-14 21:41:38 +00:00
Daniel Martí
26727b84d9 cmd/vet: simplify side effects func call logic
Instead of first looking for values of unnamed signature type, first
treat the types and builtins. All the remaining cases will be what we're
after.

Change-Id: I328e22ae0be1cccaeb45ed4ddaa360233d447e7e
Reviewed-on: https://go-review.googlesource.com/117835
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-14 21:37:12 +00:00
David Chase
c359d759a7 cmd/compile: ensure that operand of ORETURN is not double-walked
Inlining of switch statements into a RETURNed expression
can sometimes lead to the switch being walked twice, which
results in a miscompiled switch statement. The bug depends
on:

1) multiple results
2) named results
3) a return statement whose expression includes a call to a
function containing a switch statement that is inlined.

It may also be significant that the default case of that
switch is a panic(), though that's not proven.

Rearranged the walk case for ORETURN so that double walks are
not possible.  Added a test, because this is so fiddly.
Added a check against double walks, verified that it fires
w/o other fix.

Fixes #25776.

Change-Id: I2d594351fa082632512ef989af67eb887059729b
Reviewed-on: https://go-review.googlesource.com/118318
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-06-14 20:08:10 +00:00
Tobias Klauser
90559ab9f2 cmd/go: follow convention for generated code comment
Follow the convertion (https://golang.org/s/generatedcode) for generated
code in alldocs.go

Change-Id: I03985de20363ba8e09a5a624a931090ec8d196e6
Reviewed-on: https://go-review.googlesource.com/118816
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-14 15:12:11 +00:00
Akhil Indurti
d7f874fef6 cmd/go: document convention to signify generated code.
This change updates the go tool's documentation under the section
"Generate Go files by processing source" to mention the convention that
generated source files should have a line of text that matches the
following regular expression:

    ^// Code generated .* DO NOT EDIT\.$

Previously, the canonical documentation for this convention
(https://golang.org/s/generatedcode) referenced Rob Pike's comment at
https://golang.org/issue/13560#issuecomment-288457920. This change
merely moves that information to a more visible place.

Updates #25433.

Change-Id: I804d95d307d1dc68cb28da3750ebe9090178c474
Reviewed-on: https://go-review.googlesource.com/118756
Reviewed-by: Rob Pike <r@golang.org>
2018-06-14 01:47:46 +00:00
Ian Lance Taylor
3a7cbfaa40 cmd/cgo: add import path to hash
This avoids name conflicts when two identical packages use cgo.
This can happen in practice when the same package is vendored multiple
times in a single build.

Fixes #23555

Change-Id: I9f0ec6db9165dcf9cdf3d314c668fee8ada18f9c
Reviewed-on: https://go-review.googlesource.com/118739
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-13 23:36:03 +00:00
Emmanuel T Odeke
7bc99ffa05 cmd/compile: make case insensitive suggestions aware of package
Ensure that compiler error suggestions after case insensitive
field lookups don't mistakenly reported unexported fields if
those fields aren't in the local package being processed.

Fixes #25727

Change-Id: Icae84388c2a82c8cb539f3d43ad348f50a644caa
Reviewed-on: https://go-review.googlesource.com/117755
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-13 23:12:54 +00:00
Sabin Mihai Rapan
67d276c57c cgo: update documentation on calling C variadic functions
The current implementation does not support calling C variadic
functions (as discussed in #975). Document that.

Fixes #23537

Change-Id: If4c684a3d135f3c2782a720374dc4c07ea66dcbb
Reviewed-on: https://go-review.googlesource.com/90415
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-13 22:35:42 +00:00
Yury Smolsky
5eb98b3c30 cmd/compile: use expandable columns in ssa.html
Display just a few columns in ssa.html, other
columns can be expanded by clicking on collapsed column.

Use sans serif font for the text, slightly smaller font size
for non program text.

Fixes #25286

Change-Id: I1094695135401602d90b97b69e42f6dda05871a2
Reviewed-on: https://go-review.googlesource.com/117275
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-06-13 21:02:54 +00:00
Austin Clements
a1b85ee754 Revert "cmd/link: separate virtual address layout from file layout"
This reverts commit bd83774593.

Reason for revert: This broke ELF layout on arm, arm64, mips*, mips64*, ppc64*, and s390x.

Change-Id: I56a27b76e6f4b22ce39a99790af9116f8687eee9
Reviewed-on: https://go-review.googlesource.com/118675
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-13 17:55:32 +00:00
Tobias Klauser
16caec5892 cmd/dist, go/types: add support for GOARCH=riscv64
This is needed in addition to CL 110066 in order to be able to generate
Go type definitions for linux/riscv64 in the golang.org/x/sys/unix
package.

Change-Id: I4a27e6424aaea63283b55bd4f73b958b41f29d72
Reviewed-on: https://go-review.googlesource.com/118618
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-13 13:52:15 +00:00
Russ Cox
ee2e8ecb19 cmd/go: fix go list usage line
CL 108156 added -cgo and -export,
but in the usage line it added -cgo and -list.
CL 117015 correctly added -export to the usage line.
All that remains is to remove -list.

Change-Id: I8cc5cfc78bc6b52080ae1b861f92620a8f18b53f
Reviewed-on: https://go-review.googlesource.com/118375
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-13 13:45:21 +00:00
Austin Clements
bd83774593 cmd/link: separate virtual address layout from file layout
Currently these two forms of layout are done in a single pass. This
makes it difficult to compress DWARF sections because that must be
done after relocations are applied, which must happen after virtual
address layout, but we can't layout the file until we've compressed
the DWARF sections.

Fix this by separating the two layout steps. In the process, we can
also unify the copy-pasted code in Link.address to compute file
offsets. Currently, each instance of this is slightly different, but
there's no reason for it to be. For example, we don't perform
PEFILEALIGN alignment on Segrodata or Selreltodata even when HeadType
== Hwindows, but it turns out it doesn't matter whether you do or
don't because these segments simply don't exist on Windows. Hence, in
the unified code path, we do this alignment for all segments.
Likewise, there are two ways of computing Fileoff:
  seg.Vaddr - prev.Vaddr + prev.Fileoff
and
  prev.Fileoff + uint64(Rnd(int64(prev.Filelen), int64(*FlagRound)))
At the moment, these always have the same value, but the latter will
continue to work after we start compressing sections on disk.

Tested by comparing test binaries for all packages in std before and
after this change for GOOS={linux,windows,darwin,plan9}. All binaries
are identical.

For #11799.

Change-Id: If09f28771bb4d78dd392fd58b8d7c9d5f22b0b9f
Reviewed-on: https://go-review.googlesource.com/111682
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-12 20:37:02 +00:00
Russ Cox
f7142206e9 cmd/go: use build cache for tests when GOCACHE is unset
Before this CL, if you had GOCACHE=/some/dir, then the cmd/go tests used it.
But if you were relying on the implicit behavior that GOCACHE being empty
meant an appropriate system-specific cache directory, then the cmd/go tests
ran with no cache at all, which makes them about 4X slower.

During all.bash GOCACHE is set to a fresh temporary directory and is therefore
already getting proper caching; this CL mainly helps people running 'go test cmd/go'
by hand.

Change-Id: I7c322ca79b877c1d0a3b448b95d5354fbfcba7f8
Reviewed-on: https://go-review.googlesource.com/118320
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-12 20:31:40 +00:00
Cherry Zhang
44b826bb28 cmd/compile: use a different register for updated value in AtomicAnd8/Or8 on ARM64
ARM64 manual says it is "constrained unpredictable" if the src
and dst registers of STLXRB are same, although it doesn't seem
to cause any problem on real hardwares so far. Fix by allocating
a different register to hold the updated value for
AtomicAnd8/Or8. We do this by making the ops returns <val,mem>
like AtomicAdd, although val will not be used elsewhere.

Fixes #25823.

Change-Id: I735b9822f99877b3c7aee67a65e62b7278dc40df
Reviewed-on: https://go-review.googlesource.com/117976
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Wei Xiao <Wei.Xiao@arm.com>
2018-06-12 20:22:50 +00:00
Robert Griesemer
48987baa09 cmd/compile: correct alias cycle detection
The original fix (https://go-review.googlesource.com/c/go/+/35831)
for this issue was incorrect as it reported cycles in cases where
it shouldn't.

Instead, use a different approach: A type cycle containing aliases
is only a cycle if there are no type definitions. As soon as there
is a type definition, alias expansion terminates and there is no
cycle.

Approach: Split sprint_depchain into two non-recursive and more
easily understandable functions (cycleFor and cycleTrace),
and use those instead for cycle reporting. Analyze the cycle
returned by cycleFor before issueing an alias cycle error.

Also: Removed original fix (main.go) which introduced a separate
crash (#23823).

Fixes #18640.
Fixes #23823.
Fixes #24939.

Change-Id: Ic3707a9dec40a71dc928a3e49b4868c5fac3d3b7
Reviewed-on: https://go-review.googlesource.com/118078
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-06-12 18:55:39 +00:00
Elias Naur
021c39d7a3 runtime: use libc for signal functions on iOS
Also:
 - Add extra SystemStack space for darwin/arm64 just
like for darwin/arm.
 - Removed redundant stack alignment; the arm64 hardware enforces
 the 16 byte alignment.
 - Save and restore the g registers at library initialization.
 - Zero g registers since libpreinit can call libc functions
 that in turn use asmcgocall. asmcgocall requires an initialized g.
 - Change asmcgocall to work even if no g is set. The change mimics
 amd64.

Change-Id: I1b8c63b07cfec23b909c0d215b50dc229f8adbc8
Reviewed-on: https://go-review.googlesource.com/117176
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-06-12 17:05:46 +00:00
Russ Cox
c006036075 cmd/vet: use vet-specific export data to record detected printf wrappers
This CL takes advantage of the ability to record vet-specific export data,
added in CL 108558, to save information about observed printf wrappers.
Then calls to those wrappers from other packages can be format-checked.
This found a few real mistakes using previously-unrecognized printf
wrappers in cmd/compile. It will no doubt find real mistakes in external code.

Change-Id: I9c29c92d89bbdc984571a174a96e6054585e9cd4
Reviewed-on: https://go-review.googlesource.com/108559
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-06-12 01:51:04 +00:00
Brad Fitzpatrick
1352de3829 cmd/go/internal/cfg: note the copy of this code in x/tools/cmd/godoc
Updates #23445

Change-Id: I4b09073e53b1cf04de698b711fb5fb0d08bc02df
Reviewed-on: https://go-review.googlesource.com/118077
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-12 01:39:57 +00:00
Russ Cox
2630085afe cmd/go: add support for vet-specific export data
This CL makes it possible for vet to write down notes about one package
and then access those notes later, when analyzing other code importing
that package. This is much like what the compiler does with its own export
data for type-checking, so we call it "vet-export" data or vetx data.

The next CL in the stack makes vet actually use this functionality.

Change-Id: Ic70043ab407dfbfdb3f30eaea7c0e3c8197009cf
Reviewed-on: https://go-review.googlesource.com/108558
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-06-12 01:28:04 +00:00
Ian Lance Taylor
f861f66d1d cmd/link: treat cgo exported symbols as C symbols
Fixes #25827

Change-Id: I6736c3ac061ca32aac2eb68b01ba53a179d68cf4
Reviewed-on: https://go-review.googlesource.com/118076
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2018-06-12 01:25:11 +00:00
Michael Fraenkel
d0d47bb94f cmd/doc: continue to search when package import fails
Keep searching for a package that is both findable and importable. The
current code would always guarantee that a package was findable but
exited if it was not importable.

Fixes #25478

Change-Id: I237b7dfafb930cae02538c4a2e4d5ce0c1058478
Reviewed-on: https://go-review.googlesource.com/114295
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-11 22:09:14 +00:00
David du Colombier
92f8acd192 cmd/nm: fix TestGoExec on Plan 9
CL 115975 changed TestGoExec to check symbol types.
However, this test is failing on Plan 9, because
there is no read-only data segment symbol on Plan 9.

This change fixes TestGoExec to replace the check
of read-only data segment symbol (R) by data segment
symbol (D) on Plan 9.

Fixes #25820.

Change-Id: I7164cd9056fa1dfcd1dc1b0f87653290c14c85fa
Reviewed-on: https://go-review.googlesource.com/118035
Run-TryBot: David du Colombier <0intro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-11 20:58:09 +00:00
Paul Jolly
131d7e0d0e cmd/go: set DepOnly on package when calling go list -deps
Currently .DepOnly is set when go list -test is invoked to help
distinguish those packages that matched the command line spec from those
which are dependencies (of test packages). This is also useful when
calling go list -deps for the same reason.

Change-Id: Ifc0e68dad0fd01355928793ef803691dee5f4f29
Reviewed-on: https://go-review.googlesource.com/112755
Run-TryBot: Paul Jolly <paul@myitcv.org.uk>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2018-06-11 18:46:47 +00:00
Russ Cox
b111f3cc67 cmd/vet: add support for vet-specific export data
An upcoming change to cmd/go will enable this functionality, which
allows vet to write down information about one package for use by
later invocation of vet that analyze code importing that package.

We've intended to do this for a long time, but the build caching was
necessary to have a decent way to manage the vet-specific export data.

This is also an experiment in building scalable whole-program analyses.
In the long term we'd like to allow other analyses to be invoked this way.

Change-Id: I34e4b70445786b2e8707ff6a0c00947bf1491511
Reviewed-on: https://go-review.googlesource.com/117099
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-06-11 18:23:40 +00:00
Lynn Boger
9e9ff565cd runtime/race: implement race detector for ppc64le
This adds the support to enable the race detector for ppc64le.

Added runtime/race_ppc64le.s to manage the calls from Go to the
LLVM tsan functions, mostly converting from the Go ABI to the
PPC64 ABI expected by Clang generated code.

Changed racewalk.go to call racefuncenterfp instead of racefuncenter
on ppc64le to allow the caller pc to be obtained in the asm code
before calling the tsan version.

Changed the set up code for racecallbackthunk so it doesn't use
the autogenerated save and restore of the link register since that
sequence uses registers inconsistent with the normal ppc64 ABI.

Made various changes to recognize that race is supported for
ppc64le.

Ensured that tls_g is updated and accessible from race_linux_ppc64le.s
so that the race ctx can be obtained and passed to tsan functions.

This enables the race tests for ppc64le in cmd/dist/test.go and
increases the timeout when running the benchmarks with the -race
option to avoid timing out.

Updates #24354, #23731

Change-Id: Ib97dc7ac313e6313c836dc7d2fb698f9d8fba3ef
Reviewed-on: https://go-review.googlesource.com/107935
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-11 17:45:36 +00:00
Yury Smolsky
1de0dcfc7b cmd/compile: fix wording in README
"Syntax analysis" sounds more familiar and fits the
item before, which says "lexical analysis".
If there was specific intention to the original wording,
I, as a reader, would like to see it instead of this
confusing wording.

Change-Id: Id32dbf75300a86b21cb9f35e54526184fe5df6cb
Reviewed-on: https://go-review.googlesource.com/117696
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-11 17:29:30 +00:00
Yury Smolsky
e411bd706d cmd/compile: add doc comment to the parseFiles function
Change-Id: Ifa14557ba834865602c207297ccf0c63e93feb4c
Reviewed-on: https://go-review.googlesource.com/117695
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-11 17:27:48 +00:00
Michael Munday
7ba0c6235f crypto, internal/cpu: fix s390x AES feature detection and update SHA implementations
Hardware AES support in Go on s390x currently requires ECB, CBC
and CTR modes be available. It also requires that either the
GHASH or GCM facilities are available. The existing checks missed
some of these constraints.

While we're here simplify the cpu package on s390x, moving masking
code out of assembly and into Go code. Also, update SHA-{1,256,512}
implementations to use the cpu package since that is now trivial.

Finally I also added a test for internal/cpu on s390x which loads
/proc/cpuinfo and checks it against the flags set by internal/cpu.

Updates #25822 for changes to vet whitelist.

Change-Id: Iac4183f571643209e027f730989c60a811c928eb
Reviewed-on: https://go-review.googlesource.com/114397
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-11 11:41:31 +00:00
Alex Brainman
d67db88146 cmd/link: split pe .text section into .text and .rdata
Fixes #24725

Change-Id: I2864b88315ab15be036e8940d0a5884d876698d6
Reviewed-on: https://go-review.googlesource.com/115975
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-09 07:34:45 +00:00
Ian Lance Taylor
77d5c62815 cmd/go: add Solaris assembler syntax for gccgo buildid file
The Solaris assembler uses a different syntax for section directives.

Fixes https://gcc.gnu.org/PR85429.

Change-Id: I1e54dffee3290046dbb68ba4e90ab795c6b72571
Reviewed-on: https://go-review.googlesource.com/109140
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-08 22:44:03 +00:00
Iskander Sharipov
289ab30457 cmd/link: fix duplicated "unresolved inter-package jump" errors
This is extension to https://golang.org/cl/113955 that handled
duplicated "unresolved relocation" errors.

For platforms with trampoline support, additional error is generated
per each undefined symbol. This breaks TestUndefinedRelocErrors test
on these platforms.

Proposed fix:

	1. Changes error text to be identical to normal undefined reloc.
	   If relocation is undefined, jump to it will be unresolved
	   as well.

	2. Introduces a map that can be used by all sites that
	   handle this kind of errors which makes it easier
	   to report such errors exactly once.

Errors on ppc64 before this change (note first 4 lines):

	main.defined1: unresolved inter-package jump to main.undefined()
	main.defined1: unresolved inter-package jump to main.undefined()
	main.defined2: unresolved inter-package jump to main.undefined()
	main.defined2: unresolved inter-package jump to main.undefined()
	main.defined1: relocation target main.undefined not defined
	main.defined2: relocation target main.undefined not defined
	runtime.main_main·f: function main is undeclared in the main package

After this change:

	main.defined1: relocation target main.undefined not defined
	main.defined2: relocation target main.undefined not defined
	runtime.main_main·f: function main is undeclared in the main package

Because of (1), errors output is the same on all platforms now.

Fixes #25753

Change-Id: Ic3084202a6fc5d4a6d2d0a93344f012b37fe58ed
Reviewed-on: https://go-review.googlesource.com/116676
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-08 21:32:33 +00:00
David du Colombier
abeac0912a cmd/cover: fix TestCoverHTML on Plan 9
CL 116975 added TestCoverHTML. However, this test is failing
on Plan 9, because the GNU diff tool is called "ape/diff"
instead of "diff" on Plan 9.

This change replaces the "diff" command by the "ape/diff"
command on Plan 9.

Fixes #25795.

Change-Id: I15b49868cd09f3f977aa13fffdfc430c882bf757
Reviewed-on: https://go-review.googlesource.com/117415
Run-TryBot: David du Colombier <0intro@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-08 09:35:10 +00:00
Keith Randall
29e5a81e28 cmd/compile: mark BS{F,R}L as clobbering flags
Turns out it doesn't currently matter, as these ops are always issued
together with a BTSL which does clobber flags. So I can't write a test
that currently fails. But better to be future-proof.

BS{F,R}Q generates flags, so it doesn't need to be marked as clobbering.

Change-Id: I70daea154023fd435fac696bf3a384803c647cd3
Reviewed-on: https://go-review.googlesource.com/117375
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-08 04:22:01 +00:00
David Symonds
1425412f38 cmd/cover: fix test on Solaris
Solaris diff doesn't know about -d (a.k.a. --minimal).

Change-Id: I86146b4b93e3d0bdea52a0fde59afca20b5bab51
Reviewed-on: https://go-review.googlesource.com/117335
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-08 02:11:51 +00:00
David Symonds
aadaec5045 cmd/cover: fix sorting of profile segment boundaries, again
This is a refinement of CL 114855, which fixed the empty clause case,
but broke some other cases where segment boundaries can coincide
for other reasons.

Fixes #25767.

Change-Id: I2a387c83f9d651c8358f3e11b03f6167af0eb8bf
Reviewed-on: https://go-review.googlesource.com/116976
Run-TryBot: David Symonds <dsymonds@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2018-06-07 22:47:53 +00:00
David Symonds
19f3794c00 cmd/cover: add test for HTML output
This adds a case for what was fixed in 4fe688c to prevent regression;
a follow-on change will address #25767.

Change-Id: Iced8cc10e2993ef7caf7e9c59ffbc7147d78ddd7
Reviewed-on: https://go-review.googlesource.com/116975
Run-TryBot: David Symonds <dsymonds@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-07 21:52:22 +00:00
David Symonds
17f54231e8 cmd/go: don't refuse to update a present package only because of its source configuration
If a package is checked out in the right place, but uses, for instance,
an unusual Git remote configuration, don't refuse to update just because
cmd/go can't parse it. In most cases, `git pull -ff-only` (or the
equivalent in other VCSes) works just fine.

Updates #25432.

Change-Id: I1952a0e6e03f185f34029b186e1756c9549689e1
Reviewed-on: https://go-review.googlesource.com/113456
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2018-06-07 21:50:50 +00:00
Bryan C. Mills
8cf579abf7 cmd/go: restore "go list" exit code for missing binary packages
Prior to CL 108156, "go list" exited with code 0 if there were missing binary packages.
Restore that behavior to fix the failing TestBinaryOnlyPackages.

Fixes golang/go#25784.

Change-Id: Iaeca6bcc840f5ac8f2a016cef131f5c59a8261a8
Reviewed-on: https://go-review.googlesource.com/117036
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-07 18:43:49 +00:00
Brad Fitzpatrick
0e1517c0b3 cmd/go: skip TestBinaryOnlyPackages until it's fixed
Updates #25784

Change-Id: I638eab82b026d3df89da532b5cc3f5c06b02d6c8
Reviewed-on: https://go-review.googlesource.com/117075
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-07 15:47:29 +00:00
Russ Cox
35778aa497 cmd/go: final edits for add go list -cgo and -export
These got lost because I violated the cardinal rule of Gerrit
which is never click the Submit button in the web UI.

Change-Id: I8ccdfb5d8691960f244941036d33fb5a5a3f0c9a
Reviewed-on: https://go-review.googlesource.com/117015
Reviewed-by: Russ Cox <rsc@golang.org>
2018-06-07 14:31:33 +00:00
Agniva De Sarker
156bbe283c cmd/go/internal: add wasm magic header
This is needed when we are re-building to the wasm target.

Fixes #25774

Change-Id: I5dc47bd7e56c8570b8d2485273ef0d10f2feac6f
Reviewed-on: https://go-review.googlesource.com/116915
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-07 14:27:48 +00:00
Russ Cox
baf399b02e cmd/go: add go list -cgo and -export
We want package analysis tools to be able to ask cmd/go for
cgo-translated files and for the names of files holding export
type information, instead of reinventing that logic themselves.
Allow them to do so, with the new list -cgo and -export flags.

Change-Id: I860df530d8dcc130f1f328413381b5664cc81c3b
Reviewed-on: https://go-review.googlesource.com/108156
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-06-07 14:25:31 +00:00
David Chase
c08b01ecb4 cmd/compile: fix panic-okay-to-inline change; adjust tests
This line of the inlining tuning experiment
https://go-review.googlesource.com/c/go/+/109918/1/src/cmd/compile/internal/gc/inl.go#347
was incorrectly rewritten in a later patch to use the call
cost, not the panic cost, and thus the inlining of panic
didn't occur when it should.  I discovered this when I
realized that tests should have failed, but didn't.

Fix is to make the correct change, and also to modify the
tests that this causes to fail.  One test now asserts the
new normal, the other calls "ppanic" instead which is
designed to behave like panic but not be inlined.

Change-Id: I423bb7f08bd66a70d999826dd9b87027abf34cdf
Reviewed-on: https://go-review.googlesource.com/116656
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-06-06 20:35:23 +00:00
Richard Musiol
88dc4aee7c cmd/compile: fix OffPtr with negative offset on wasm
The wasm archtecture was missing a rule to handle OffPtr with a
negative offset. This commit makes it so OffPtr always gets lowered
to I64AddConst.

Fixes #25741

Change-Id: I1d48e2954e3ff31deb8cba9a9bf0cab7c4bab71a
Reviewed-on: https://go-review.googlesource.com/116595
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
2018-06-06 14:40:25 +00:00
Dennis Kuhnert
ebb8a1f8e6 cmd/go: output coverage report even if there are no test files
When using test -cover or -coverprofile the output for "no test files"
is the same format as for "no tests to run".

Fixes #24570

Change-Id: If05609411676d42d94c1feac4bc839974fae2cc1
Reviewed-on: https://go-review.googlesource.com/115095
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-06 01:10:20 +00:00
Robert Griesemer
d159d6108c cmd/compile: terminate compilation if type-checking fails
There is no benefit in continuing compilation if there
are type-checking errors. This will increase robustness
of the compiler in the presence of errors.

Fixes #22909.

Change-Id: I1c70c667e5927646ba3d0f370e33705165620f12
Reviewed-on: https://go-review.googlesource.com/116335
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-06 00:15:51 +00:00
Robert Griesemer
409a943f69 cmd/compile: avoid nil pointer deref in debugging output
Found while tracking down another issue.

Change-Id: If06eee72ce3e3f45dc00b3b68670e1e4d99c87a7
Reviewed-on: https://go-review.googlesource.com/116455
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-05 23:43:08 +00:00
Robert Griesemer
9be4f312bf cmd/compile: revert internal parameter rename (from ".anonX" to "") before export
In the old binary export format, parameter names for parameter lists
which contained only types where never written, so this problem didn't
come up.

Fixes #25101.

Change-Id: Ia8b817f7f467570b05f88d584e86b6ef4acdccc6
Reviewed-on: https://go-review.googlesource.com/116376
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-06-05 20:22:07 +00:00
isharipo
2c01b7d632 cmd/link: fix duplicated "undefined reloc" errors
For given program with 2 undefined relocations (main and undefined):

	package main
	func undefined()
	func defined() int {
		undefined()
		undefined()
		return 0
	}
	var x = defined()

"go tool link" produces these errors:

	main.defined: relocation target main.undefined not defined
	main.defined: relocation target main.undefined not defined
	runtime.main_main·f: relocation target main.main not defined
	main.defined: undefined: "main.undefined"
	main.defined: undefined: "main.undefined"
	runtime.main_main·f: undefined: "main.main"

After this CL is applied:

	main.defined: relocation target main.undefined not defined
	runtime.main_main·f: function main is undeclared in the main package

Fixes #10978
Improved error message for main proposed in #24809.

Change-Id: I4ba8547b1e143bbebeb4d6e29ea05d932124f037
Reviewed-on: https://go-review.googlesource.com/113955
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-05 16:49:07 +00:00
Robert Griesemer
4a2bec9726 cmd/compile: fix printing of array types in error messages
Fixes #23094.

Change-Id: I9aa36046488baa5f55cf2099e10cfb39ecd17b06
Reviewed-on: https://go-review.googlesource.com/116256
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-05 00:43:22 +00:00
Russ Cox
446d76e62d cmd/go: fix 'go get' compatibility for direct download of vgo-aware module
CL 109340 added “minimal module-awareness for legacy operation.”
One part of that is reinterpreting imports inside code trees with go.mod files
as using semantic import versioning, and converting them back to
legacy import paths by stripping the major version element
(for example, interpreting import "x.com/foo/v2/bar" as import "x.com/foo/bar").
This rewrite was not being applied during "go get", with the effect that once
you had the target code downloaded already, everything was fine,
but it didn't download and build successfully the first time.

Fixes #25687.

Change-Id: I3e122efdc8fd9a0a4e66f5aa3e6a99f90c7df779
Reviewed-on: https://go-review.googlesource.com/115797
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-06-04 14:18:39 +00:00
Iskander Sharipov
41dd2ebcee cmd/asm/internal/asm: add extra AVX-512 tests
These tests were meant to be included into https://golang.org/cl/113315,
but were lost somewhere in the middle.

This CL adds hand-written AVX-512 tests that complement
auto-generated test suite.

It's worth including it, because:

	- It covers every new Z-case explicitly
	- Does checks every opcode suffix encoding

Change-Id: Id6da5f58773e07bef3d532fc3ca5db391d380ebf
Reviewed-on: https://go-review.googlesource.com/115858
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-06-04 04:07:13 +00:00
Keith Randall
06b326054d cmd/compile: include callee args section when checking frame too large
The stack frame includes the callee args section. At the point where
we were checking the frame size, that part of the frame had not been
computed yet. Move the check later so we can include the callee args size.

Fixes #20780
Update #25507

Change-Id: Iab97cb89b3a24f8ca19b9123ef2a111d6850c3fe
Reviewed-on: https://go-review.googlesource.com/115195
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2018-06-02 18:00:44 +00:00
Tim Cooper
161874da2a all: update comment URLs from HTTP to HTTPS, where possible
Each URL was manually verified to ensure it did not serve up incorrect
content.

Change-Id: I4dc846227af95a73ee9a3074d0c379ff0fa955df
Reviewed-on: https://go-review.googlesource.com/115798
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2018-06-01 21:52:00 +00:00
Martin Möhrmann
b280edb89e cmd/compile: fix comment to reference runtime.countrunes
Updates #24923

Change-Id: Ie5a1b54b023381b58df618080f3d742a50d46d8b
Reviewed-on: https://go-review.googlesource.com/115836
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-01 19:18:43 +00:00
Ben Shi
3d6e4ec0a8 cmd/internal/obj/arm64: fix two issues in the assembler
There are two issues in the arm64 assembler.

1. "CMPW $0x22220000, RSP" is encoded to 5b44a4d2ff031b6b, which
   is the combination of "MOVD $0x22220000, Rtmp" and
   "NEGSW Rtmp, ZR".
   The right encoding should be a combination of
   "MOVD $0x22220000, Rtmp" and "CMPW Rtmp, RSP".

2. "AND $0x22220000, R2, RSP" is encoded to 5b44a4d25f601b00,
   which is the combination of "MOVD $0x22220000, Rtmp" and
   an illegal instruction.
   The right behavior should be an error report of
   "illegal combination", since "AND Rtmp, RSP, RSP" is invalid
   in armv8.

This CL fixes the above 2 issues and adds more test cases.

fixes #25557

Change-Id: Ia510be26b58a229f5dfe8a5fa0b35569b2d566e7
Reviewed-on: https://go-review.googlesource.com/114796
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-06-01 15:24:42 +00:00
Hana Kim
424c215739 cmd/pprof: fix help message formatting error
Pprof usage message includes "%" symbols. Misuse of Fprintf caused
the message to be interpreted as a format string and corrupted the usage
message.

Change-Id: I4732b491e2368cff9fdbfe070c125228d6f506fd
Reviewed-on: https://go-review.googlesource.com/115595
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-31 17:29:10 +00:00
Austin Clements
33cd4fba38 Revert "cmd/compile: ignore g register in liveness analysis"
This reverts commit ea200340702cf3ccfac7c5db1f11bb65c80971c7 now
that CL 114695 fixed the root cause of #25504.

Change-Id: If437fc832983bd8793bde28ce0e2e64436a0596c
Reviewed-on: https://go-review.googlesource.com/114087
Reviewed-by: David Chase <drchase@google.com>
2018-05-31 14:50:57 +00:00
Alberto Donizetti
bfdf74be12 Revert "testing: only compute b.N once when passed -count > 1"
This reverts golang.org/cl/110775

Reason for revert: this is causing huge slow-dows on every run after
the 1st, on various benchmarks, on multiple architectures (see Issue
25622 for details). It's just a nice-to-have little optimization, and
we're near the 1st go1.11 beta release, so I'm reverting it.

Fixes #25622

Change-Id: I758ade4af4abf764abd8336d404396992d11a0c6
Reviewed-on: https://go-review.googlesource.com/115535
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2018-05-31 14:22:44 +00:00
Yury Smolsky
fffb3a5c20 testing: make indentation consistent in sub-tests
Instead of mixed usage of spaces and tabs for indentation,
just use 4 spaces instead of one tab.

This test:

func TestX(t *testing.T) {
	t.Error("1\nnew line")
	t.Error("2")
	t.Error("3")
	t.Run("Y", func(t *testing.T) {
		t.Error("2")
		t.Error("2b\nnew line")
		t.Run("Z", func(t *testing.T) {
			t.Error("3\nnew line")
		})
	})
	t.Error("4")
}

produces following output:

--- FAIL: TestX (0.00s)
    indent_test.go:6: 1
	new line
    indent_test.go:7: 2
    indent_test.go:8: 3
    --- FAIL: TestX/Y (0.00s)
	indent_test.go:10: 2
	indent_test.go:11: 2b
	    new line
	--- FAIL: TestX/Y/Z (0.00s)
	    indent_test.go:13: 3
		new line
    indent_test.go:16: 4
FAIL

Fixes #25369

Change-Id: Ib3b5da45ab3ee670c6e8a23172e7cbefb94c5e60
Reviewed-on: https://go-review.googlesource.com/113177
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
2018-05-31 07:20:38 +00:00
Ian Lance Taylor
cc6e568c81 cmd/go: accept more safe CFLAGS/LDFLAGS
Fixes #23749
Fixes #24703
Fixes #24858

Change-Id: Ib32d8efee294004c70fdd602087df2da0867f099
Reviewed-on: https://go-review.googlesource.com/115415
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-30 22:38:09 +00:00
Russ Cox
d4e21288e4 cmd/go: add minimal module-awareness for legacy operation
We want authors to be able to publish code that works with both
the current standard go command and the planned new go command
support for modules. If authors have tagged their code v2 or later,
semantic import versioning means the import paths must include a
v2 path element after the path prefix naming the module.
One option for making this convention compatible with original go get
is to move code into a v2 subdirectory of the root.
That makes sense for some authors, but many authors would prefer
not to move all the code into a v2 subdirectory for a transition and
then move it back up once we everyone has a module-aware go command.

Instead, this CL teaches the old (non-module-aware) go command
a tiny amount about modules and their import paths, to expand
the options for authors who want to publish compatible packages.
If an author has a v2 of a package, say my/thing/v2/sub/pkg,
in the my/thing repo's sub/pkg subdirectory (no v2 in the file system path),
then old go get continues to import that package as my/thing/sub/pkg.
But when go get is processing code in any module (code in a tree with
a go.mod file) and encounters a path like my/thing/v2/sub/pkg,
it will check to see if my/thing/go.mod says "module my/thing/v2".
If so, the go command will read the import my/thing/v2/sub/pkg
as if it said my/thing/sub/pkg, which is the correct "old" import path
for the package in question.

This CL will be back-ported to Go 1.10 and Go 1.9 as well.

Once users have updated to the latest Go point releases containing
this new logic, authors will be able to update to using modules
within their own repos, including using semantic import paths
with vN path elements, and old go get will still be able to consume
those repositories.

This CL also makes "go get" ignore meta go-import lines using
the new "mod" VCS type. This allows a package to specify both
a "mod" type and a "git" type, to present more efficient module
access to module-aware go but still present a Git repo to the old
"go get".

Fixes #24751.
Fixes #25069.

Change-Id: I378955613a0d63834d4f50f121f4db7e4d87dc0a
Reviewed-on: https://go-review.googlesource.com/109340
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-05-30 18:03:08 +00:00
David Chase
31e1c30f55 cmd/compile: do not allow regalloc to LoadReg G register
On architectures where G is stored in a register, it is
possible for a variable to allocated to it, and subsequently
that variable may be spilled and reloaded, for example
because of an intervening call.  If such an allocation
reaches a join point and it is the primary predecessor,
it becomes the target of a reload, which is only usually
right.

Fix: guard all the LoadReg ops, and spill value in the G
register (if any) before merges (in the same way that 387
FP registers are freed between blocks).

Includes test.

Fixes #25504.

Change-Id: I0482a53e20970c7315bf09c0e407ae5bba2fe05d
Reviewed-on: https://go-review.googlesource.com/114695
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-30 16:39:21 +00:00
Hana Kim
d5bc3b96c6 cmd/vendor/.../pprof: sync at rev 1ddc9e2
This includes changes in pprof to support
 - the new -diff_base flag
 - fix for a bug in handling of legacy Go heap profiles

Update #25096

Change-Id: I826ac9244f31cc2c4415388c44a0cbe77303e460
Reviewed-on: https://go-review.googlesource.com/115295
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-30 16:31:37 +00:00
Tobias Klauser
fb0d6e4bd1 cmd/dist: remove external linking check for macOS 10.6
This was missed in CL 115236.

Updates #23122

Change-Id: I5a64bd02d356c21c0e5d02dafafb3721f8dd8e06
Reviewed-on: https://go-review.googlesource.com/115276
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-30 16:31:27 +00:00
Tobias Klauser
f5cf72d43e cmd/link/internal/ld: drop duplicate copyright comment
The copyright message already appears at the top of macho.go. Drop the
duplicate further down in the file.

Change-Id: Ib0a69f568c4ef656bab14176223936cd2fe078d1
Reviewed-on: https://go-review.googlesource.com/115235
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-30 13:41:41 +00:00
Tobias Klauser
679004f484 cmd/dist: remove support for macOS 10.9 and earlier
Updates #23122

Change-Id: I14cfb83f3f78cdbe5880bd29209388ad12b9ee89
Reviewed-on: https://go-review.googlesource.com/115236
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-30 13:40:41 +00:00
Keith Randall
6c6e22e5a9 runtime: implement time.now using libc
Change-Id: Ibdd9202d9711ea8aab2446c9950ddb8e1f6bf4e0
Reviewed-on: https://go-review.googlesource.com/114799
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-29 22:32:30 +00:00
Tim Cooper
555eb70db2 all: regenerate stringer files
Change-Id: I34838320047792c4719837591e848b87ccb7f5ab
Reviewed-on: https://go-review.googlesource.com/115058
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-29 20:35:41 +00:00
Keith Randall
db9341a024 cmd/compile: update WBLoads during deadcode
When we deadcode-remove a block which is a write barrier test,
remove that block from the list of write barrier test blocks.

Fixes #25516

Change-Id: I1efe732d5476003eab4ad6bf67d0340d7874ff0c
Reviewed-on: https://go-review.googlesource.com/115037
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-29 17:45:36 +00:00
Daniel Martí
b65934f237 cmd/go: whitelist -v as a compiler and linker flag
It's harmless, and can be useful to see what's happening under the hood.

Fixes #24593.

Change-Id: Iacff378471e86c33aa048161cd65c504709fb339
Reviewed-on: https://go-review.googlesource.com/115075
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-29 17:14:17 +00:00
Daniel Martí
07d384b9de cmd/vet: avoid false positives with non-comments
vet's buildtag check looks for malformed build tag comments. Since these
can appear in Go files as well as non-Go files (such as assembly files),
it must read the file line by line instead of using go/token or go/ast
directly.

However, this method runs into false positives if there are any lines in
the code that look like comments, but are not. For example:

	$ cat f.go
	package main
	const foo = `
	//+build ignore
	`
	$ go vet f.go
	./f.go:3: +build comment must appear before package clause and be followed by a blank line

This bug has been popping up more frequently since vet started being run
with go test, so it is important to make the check as precise as
possible.

To avoid the false positive, when checking a Go file, cross-check that a
line that looks like a comment actually corresponds to a comment in the
go/ast syntax tree. Since vet already obtains the syntax trees for all
the Go files, it checks, this change means very little extra work for
the check.

While at it, add a badf helper function to simplify the code that
reports warnings in the buildtag check.

Fixes #13533.

Change-Id: I484a16da01363b409ec418c313634171bf85250b
Reviewed-on: https://go-review.googlesource.com/111415
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-29 17:01:58 +00:00
Keith Randall
d15d055054 cmd/compile: reject large argument areas
Extend stack frame limit of 1GB to include large argument/return areas.
Argument/return areas are part of the parent frame, not the frame itself,
so they need to be handled separately.

Fixes #25507.

Change-Id: I309298a58faee3e7c1dac80bd2f1166c82460087
Reviewed-on: https://go-review.googlesource.com/115036
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-29 16:58:05 +00:00
Ian Lance Taylor
ab922e1012 cmd/cgo: use standard generated code comment
Change cgo to follow https://golang.org/s/generatedcode.

For the C code we continue to use /* */ comments, so they don't follow
the format exactly. It doesn't really matter since the format is only
for Go code anyhow. This CL changes the C code to be similar for
consistency.

Fixes #25623

Change-Id: Idcfee53ec4069924d173ab8cedeb7bcfb7312863
Reviewed-on: https://go-review.googlesource.com/115035
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2018-05-29 14:44:59 +00:00
Josh Bleecher Snyder
33cfcf6afa cmd/compile: fix trivial typos in comments
Change-Id: I04880d87e317a1140ec12da6ec5e788991719760
Reviewed-on: https://go-review.googlesource.com/114936
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-29 02:39:52 +00:00
Ian Lance Taylor
6070e432d2 cmd/dist: report correct CC name in error about missing CC
Fixes #25611

Change-Id: I487463584e4d9d99cf5d8db0c9a4b4e66464ecd8
Reviewed-on: https://go-review.googlesource.com/114935
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-28 19:00:18 +00:00
Yury Smolsky
68de5508d3 cmd/vet: eliminate use of Perl in tests
This change uses errorCheck and wantedErrors functions copied from
the test/run.go to eliminate use of the test/errchk perl script.

Tests' error messages that contained full filenames were changed to
have base filenames because the errorCheck function processes output
from "go vet" in the same way.

Fixes #20032.

Change-Id: Ieb7be67c2d7281b9648171c698398449b7e2d4dd
Reviewed-on: https://go-review.googlesource.com/114176
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-05-28 17:08:33 +00:00
David Symonds
4fe688c6a4 cmd/cover: fix sorting of profile segment boundaries
If a span of coverable code is empty (e.g. an empty select clause)
then there will be two Boundary values with the same offset. In that
case, the starting Boundary needs to come first so that the generated
HTML output will open the <span> tag before it tries to close it.

Change-Id: Ib44a8b7c36ae57757c18b6cceb7a88ffa4e95394
Reviewed-on: https://go-review.googlesource.com/114855
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-28 03:35:36 +00:00
Ian Lance Taylor
c1d9d1f305 cmd/go: don't generate output for "go build -o /dev/null x.go"
We look for "-o /dev/null", and, if found, pretend that there was no
"-o" option and don't generate an action to create the final executable.

We look for "go build x.go", and, if found, and if -o was not used,
pretend that the user specified "-o x".

Unfortunately, we were doing those in the wrong order, so that "go
build -o /dev/null x.go" would first clear the "-o" option and then
set it to "-o x".

This CL flips the order so that the right thing happens.

Fixes #25579

Change-Id: Ic9556ac0a57f7b45b685951bc96ba5ea4633b860
Reviewed-on: https://go-review.googlesource.com/114715
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-27 07:33:08 +00:00
Elias Naur
4258b43afe cmd/compile,go/build,internal/cpu: gofmt
I don't know why these files were not formatted. Perhaps because
their changes came from Github PRs?

Change-Id: Ida8d7b9a36f0d1064caf74ca1911696a247a9bbe
Reviewed-on: https://go-review.googlesource.com/114824
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-26 20:52:04 +00:00
Alex Brainman
f7b625e4cb cmd/go/internal/load: use lowercase package directory comparisons on Windows
go build

command is short for

go build .

and it builds . package. When command above is executed from
directory inside of GOPATH, it uses GOPATH to calculate package
source directory. So . package uses GOPATH as part of package
source directory.

On the other hand

go build -ldflags=abc

only passes flag to the linker for packages that are listed
on the command line. The command above assumes . package again,
and that package source path is compared with current directory.

Current code compares result of os.Getwd with what GOPATH
environment variable contains. But these values might differ
in letter case on Windows. For example, one might return
c:\gopath\..., while the other might contain C:\GOPATH.

Fixes #24750
Fixes #24232
Fixes #25046

Change-Id: I03d8c7a9b73e847f88ae61c88cd41efa546c6d0e
Reviewed-on: https://go-review.googlesource.com/109235
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-26 07:56:52 +00:00
Than McIntosh
1ba26a33ce cmd/compile: fix DWARF inline debug issue with dead local vars
Fix a problem in DWARF inline debug generation relating to handling of
statically unreachable local variables. For a function such as:

    const always = true

    func HasDeadLocal() int {
      if always {
        return 9
      }
      x := new(Something)
      ...
      return x.y
    }

the variable "x" is placed onto the Dcl list for the function during
parsing, but the actual declaration node is deleted later on when
gc.Main invokes "deadcode". Later in the compile the DWARF code emits
an abstract function with "x" (since "x" was on the Dcl list at the
point of the inline), but the export data emitted does not contain
"x". This then creates clashing/inconsistant DWARF abstract function
DIEs later on if HasDeadLocal is inlined in somewhere else.

As a fix, the inliner now pruned away variables such as "x" when
creating a copy of the Dcl list as part of the inlining; this means
that both the export data generator and the DWARF emitter wind up
seeing a consistent picture.

Fixes #25459

Change-Id: I753dc4e9f9ec694340adba5f43c907ba8cc9badc
Reviewed-on: https://go-review.googlesource.com/114090
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2018-05-25 19:37:35 +00:00
Tobias Klauser
88756931d0 cmd/vendor/golang.org/x: pick up fixes for broken android and linux tests
While fixing some failing tests, CL 114416 also picked up the newly
added TestXattr from golang.org/x/sys/unix which fails on android. Pick
up CL 114535 to fix it as well.

Also pick up CL 114616 to fix TestStatx occasionally failing on linux.

Change-Id: I6ebebd7761fa7a086d96ee0447dbbc5c6b94131d
Reviewed-on: https://go-review.googlesource.com/114575
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-25 16:49:28 +00:00
Josh Bleecher Snyder
bdaadeb387 cmd/compile: make -W and -w headers and footers clearer
-W and -w turn on printing of Nodes for both order and walk.
I have found their output mildly incomprehensible for years.
Improve it, at long last.

Change-Id: Ia05d77e59aa741c2dfc9fcca07f45019420b655e
Reviewed-on: https://go-review.googlesource.com/114520
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-25 13:09:29 +00:00
Josh Bleecher Snyder
124eccd5f7 cmd/compile: improve fncall docs
Comment changes only.

Change-Id: I3f9c1c38ae6b4989f02b62fff09265e4bcb934f7
Reviewed-on: https://go-review.googlesource.com/114519
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-25 13:08:56 +00:00
Ian Lance Taylor
30b6bc30b2 cmd/go, cmd/vet, go/internal/gccgoimport: make vet work with gccgo
When using gccgo/GoLLVM, there is no package file for a standard
library package. Since it is impossible for the go tool to rebuild the
package, and since the package file exists only in the form of a .gox
file, this seems like the best choice. Unfortunately it was confusing
vet, which wanted to see a real file. This caused vet to report errors
about missing package files for standard library packages. The
gccgoimporter knows how to correctly handle this case. Fix this by

1) telling vet which packages are standard;
2) letting vet skip those packages;
3) letting the gccgoimporter handle this case.

As a separate required fix, gccgo/GoLLVM has no runtime/cgo package,
so don't try to depend on it (as it happens, this fixes #25324).

The result is that the cmd/go vet tests pass when using -compiler=gccgo.

Fixes #25324

Change-Id: Iba8f948fe944da5dc674f580bd3321929ee50fa0
Reviewed-on: https://go-review.googlesource.com/113716
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-24 22:08:00 +00:00
Tobias Klauser
c2b4b316b4 cmd/vendor/golang.org/x: pick up upstream fixes for broken android and iOS tests
Pick up the changes from CL 114395, CL 114396 and CL 114415.

By re-running govendor in the latest version, some files from
golang.org/x/sys/unix which are ignored for the build also got removed
from the vendored copy.

Updates #25528
Updates #25535

Change-Id: I5c0002fc3a37d6abaafed2e15cc3e2ade803ad7b
Reviewed-on: https://go-review.googlesource.com/114416
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-24 20:56:47 +00:00
Richard Musiol
8aa57f1e9d cmd/compile: fix write barrier control value on wasm
This commit fixes a regression with wasm caused by a367f44c18.
It adds optimizations to the lowering rules of wasm to ensure
that the lowered version of the code generated for write barriers
is simple enough so it can be processed by Liveness.markUnsafePoints.

Change-Id: Ic98f0dd3791fe1df23dcb34d2457fbde7ffce441
Reviewed-on: https://go-review.googlesource.com/114375
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-05-24 17:19:09 +00:00
Heschi Kreinick
65c365bf0f cmd/compile: fix debug info generation for loads from Phis
Apparently a LoadReg can take a Phi as its argument. The Phi has names
in the NamedValue table, so just read the Load's names from the Phi.

The example given, XORKeyStream in chacha20, is pretty complicated so I
didn't try to actually debug it and verify that the results are right.
But the debug logging looks reasonable, with the right names in the right
registers at the right times.

Fixes #25404

Change-Id: I2c3183dcfb033948556d6805bd66c22c0b45625c
Reviewed-on: https://go-review.googlesource.com/114008
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-05-23 23:51:30 +00:00
Heschi Kreinick
391a963bba cmd/compile: clean up debug info generation logging
Remove the unexpected function, which is a lot less relevant now that
the generation basically can't detect invalid states, and make sure no
logging appears without -d locationlists=2.

Updates #25404

Change-Id: If3522df5a7397f2e7b43cb808936e319132132b6
Reviewed-on: https://go-review.googlesource.com/114007
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-05-23 23:51:25 +00:00
Richard Musiol
482d241936 cmd/compile: add wasm stack optimization
Go's SSA instructions only operate on registers. For example, an add
instruction would read two registers, do the addition and then write
to a register. WebAssembly's instructions, on the other hand, operate
on the stack. The add instruction first pops two values from the stack,
does the addition, then pushes the result to the stack. To fulfill
Go's semantics, one needs to map Go's single add instruction to
4 WebAssembly instructions:
- Push the value of local variable A to the stack
- Push the value of local variable B to the stack
- Do addition
- Write value from stack to local variable C

Now consider that B was set to the constant 42 before the addition:
- Push constant 42 to the stack
- Write value from stack to local variable B

This works, but is inefficient. Instead, the stack is used directly
by inlining instructions if possible. With inlining it becomes:
- Push the value of local variable A to the stack (add)
- Push constant 42 to the stack (constant)
- Do addition (add)
- Write value from stack to local variable C (add)

Note that the two SSA instructions can not be generated sequentially
anymore, because their WebAssembly instructions are interleaved.

Design doc: https://docs.google.com/document/d/131vjr4DH6JFnb-blm_uRdaC0_Nv3OUwjEY5qVCxCup4

Updates #18892

Change-Id: Ie35e1c0bebf4985fddda0d6330eb2066f9ad6dec
Reviewed-on: https://go-review.googlesource.com/103535
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-05-23 21:37:59 +00:00
Hana Kim
02399fa65c cmd/vendor/.../unix: pick up upstream fixes for broken tests
Update golang/go#25528
Update golang/go#25529

Change-Id: I47ec282e76eb7740547e220ac00d6a7992e17b9e
Reviewed-on: https://go-review.googlesource.com/114094
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-23 21:11:41 +00:00
Hana (Hyang-Ah) Kim
3f89214940 cmd/pprof: add readline support similar to upstream
The upstream pprof implements the readline feature using
the github.com/chzyer/readline package in its pprof.go main.

It would be ideal to use the same readline support package as
the upstream for better user experience and code maintenance.
However, bringing in third-party packages requires more work
than I envisioned (e.g. clean up the vendored code to meet the
expected standard - iow don't break builders).

As a result, this change implements the similar feature
for the pprof command included in the go distribution
(cmd/pprof/pprof.go) using golang.org/x/crypto/ssh/terminal
for now.

Auto-completion is not yet supported (same in the upstream).

The feature is enabled only in linux, windows, darwin, and
only when terminal support is available.

This change brings in new vendored packages,
golang.org/x/crypto/ssh/terminal and
golang.org/x/sys/{unix,windows}.

For #14041

Change-Id: If4a790796acf2ab20f7e81268b9d9354c5a5cd2b
Reviewed-on: https://go-review.googlesource.com/112436
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-23 19:01:58 +00:00
David Chase
77c51c6c62 cmd/compile: grow stack before test() to avoid gdb misbehavior
While next-ing over a call in gdb, if execution of that call
causes a goroutine's stack to grow (i.e., be moved), gdb loses
track and runs ahead to the next breakpoint, or to the end of
the program, whichever comes first.

Prevent this by preemptively growing the stack so that
ssa/debug_test.go will reliably measure what is intended,
the goodness of line number placement and variable printing.

Fixes #25497.

Change-Id: I8daf931650292a8c8faad2285d7fd405f2157bd2
Reviewed-on: https://go-review.googlesource.com/114080
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-23 18:05:07 +00:00
isharipo
67fe8b5677 cmd/internal/obj/x86: add missing Yi8 for VEX ytabs
This change adds Yi8 forms for every ytab that had them before AVX-512 patch.
The rationale is backwards-compatibility.

EVEX forms remain strict and unchanged as they're not bound to any
backwards-compatibility issues.

Fixes #25510

Change-Id: Icd692266010ed64c9fe47cc837afc2edf2ad2d1d
Reviewed-on: https://go-review.googlesource.com/114136
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
2018-05-23 15:34:19 +00:00
Alex Brainman
ef880a2f61 cmd/go: skip TestLinkerTmpDirIsDeleted if cgo is not enabled
Fixes builders that do not have cgo installed.

Change-Id: I719b7959226b0e67c3ffc11e071784787cabc5ab
Reviewed-on: https://go-review.googlesource.com/114235
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-23 14:13:24 +00:00
Alex Brainman
1174ad3a8f cmd/link: close go.o before deleting it
Windows does not allow to delete opened file.

Fixes #24704

Change-Id: Idfca2d00a2c46bdd9bd2a721478bfd003c474ece
Reviewed-on: https://go-review.googlesource.com/113935
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-23 09:44:27 +00:00
Austin Clements
132900982c cmd/compile: ignore g register in liveness analysis
In rare circumstances that we don't yet fully understand, the g
register can be spilled to the stack and then reloaded. If this
happens, liveness analysis sees a pointer load into a
non-general-purpose register and panics.

We should fix the root cause of this, but fix the build for now by
ignoring pointer loads into the g register.

For #25504.

Change-Id: I0dfee1af9750c8e9157c7637280cdf07118ef2ca
Reviewed-on: https://go-review.googlesource.com/114081
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-22 21:49:36 +00:00
David Chase
cfbf375a81 cmd/compile: common up code in fuse for joining blocks
There's semantically-but-not-literally equivalent code in
two cases for joining blocks' value lists in ssa/fuse.go.
It can be made literally equivalent, then commoned up.

Updates #25426.

Change-Id: Id1819366c9d22e5126f9203dcd4c622423994110
Reviewed-on: https://go-review.googlesource.com/113719
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2018-05-22 21:46:36 +00:00
Austin Clements
f11e9aac4f cmd/compile: reuse liveness structures
Currently liveness analysis is a significant source of allocations in
the compiler. This CL mitigates this by moving the main sources of
allocation to the ssa.Cache, allowing them to be reused between
different liveness runs.

Passes toolstash -cmp.

name        old time/op       new time/op       delta
Template          194ms ± 1%        193ms ± 1%    ~     (p=0.156 n=10+9)
Unicode          99.1ms ± 1%       99.3ms ± 2%    ~     (p=0.853 n=10+10)
GoTypes           689ms ± 0%        687ms ± 0%  -0.27% 	(p=0.022 n=10+9)
Compiler          3.29s ± 1%        3.30s ± 1%    ~ 	(p=0.489 n=9+9)
SSA               8.02s ± 2%        7.97s ± 1%  -0.71%  (p=0.011 n=10+10)
Flate             131ms ± 1%        130ms ± 1%  -0.59%  (p=0.043 n=9+10)
GoParser          162ms ± 1%        160ms ± 1%  -1.53%  (p=0.000 n=10+10)
Reflect           454ms ± 0%        454ms ± 0%    ~    	(p=0.959 n=8+8)
Tar               185ms ± 1%        185ms ± 2%    ~ 	(p=0.905 n=9+10)
XML               235ms ± 1%        232ms ± 1%  -1.15% 	(p=0.001 n=9+10)
[Geo mean]        414ms             412ms       -0.39%

name        old alloc/op      new alloc/op      delta
Template         35.6MB ± 0%       34.2MB ± 0%  -3.75%  (p=0.000 n=10+10)
Unicode          29.5MB ± 0%       29.4MB ± 0%  -0.26%  (p=0.000 n=10+9)
GoTypes           117MB ± 0%        112MB ± 0%  -3.78%  (p=0.000 n=9+10)
Compiler          532MB ± 0%        512MB ± 0%  -3.80%  (p=0.000 n=10+10)
SSA              1.55GB ± 0%       1.48GB ± 0%  -4.82%  (p=0.000 n=10+10)
Flate            24.5MB ± 0%       23.6MB ± 0%  -3.61%  (p=0.000 n=10+9)
GoParser         28.7MB ± 0%       27.7MB ± 0%  -3.43%  (p=0.000 n=10+10)
Reflect          80.5MB ± 0%       78.1MB ± 0%  -2.96%  (p=0.000 n=10+10)
Tar              35.1MB ± 0%       33.9MB ± 0%  -3.49%  (p=0.000 n=10+10)
XML              43.7MB ± 0%       42.4MB ± 0%  -3.05%  (p=0.000 n=10+10)
[Geo mean]       78.4MB            75.8MB       -3.30%

name        old allocs/op     new allocs/op     delta
Template           335k ± 0%         335k ± 0%  -0.12%  (p=0.000 n=10+10)
Unicode            339k ± 0%         339k ± 0%  -0.01%  (p=0.001 n=10+10)
GoTypes           1.18M ± 0%        1.17M ± 0%  -0.12%  (p=0.000 n=10+10)
Compiler          4.94M ± 0%        4.94M ± 0%  -0.06%  (p=0.000 n=10+10)
SSA               12.5M ± 0%        12.5M ± 0%  -0.07%  (p=0.000 n=10+10)
Flate              223k ± 0%         223k ± 0%  -0.11%  (p=0.000 n=10+10)
GoParser           281k ± 0%         281k ± 0%  -0.08%  (p=0.000 n=10+10)
Reflect            963k ± 0%         960k ± 0%  -0.23%  (p=0.000 n=10+9)
Tar                330k ± 0%         330k ± 0%  -0.12%  (p=0.000 n=10+10)
XML                392k ± 0%         392k ± 0%  -0.08%  (p=0.000 n=10+10)
[Geo mean]         761k              760k       -0.10%

Compared to just before "cmd/internal/obj: consolidate emitting entry
stack map", the cumulative effect of adding stack maps everywhere and
register maps, plus these optimizations, is:

name        old time/op       new time/op       delta
Template          186ms ± 1%        194ms ± 1%  +4.41%  (p=0.000 n=9+10)
Unicode          96.5ms ± 1%       99.1ms ± 1%  +2.76%  (p=0.000 n=9+10)
GoTypes           659ms ± 1%        689ms ± 0%  +4.56%  (p=0.000 n=9+10)
Compiler          3.14s ± 2%        3.29s ± 1%  +4.95%  (p=0.000 n=9+9)
SSA               7.68s ± 3%        8.02s ± 2%  +4.41%  (p=0.000 n=10+10)
Flate             126ms ± 0%        131ms ± 1%  +4.14%  (p=0.000 n=10+9)
GoParser          153ms ± 1%        162ms ± 1%  +5.90%  (p=0.000 n=10+10)
Reflect           436ms ± 1%        454ms ± 0%  +4.14%  (p=0.000 n=10+8)
Tar               177ms ± 1%        185ms ± 1%  +4.28%  (p=0.000 n=8+9)
XML               224ms ± 1%        235ms ± 1%  +5.23%  (p=0.000 n=10+9)
[Geo mean]        396ms             414ms       +4.47%

name        old alloc/op      new alloc/op      delta
Template         34.5MB ± 0%       35.6MB ± 0%  +3.24%  (p=0.000 n=10+10)
Unicode          29.3MB ± 0%       29.5MB ± 0%  +0.51%  (p=0.000 n=9+10)
GoTypes           113MB ± 0%        117MB ± 0%  +3.31%  (p=0.000 n=8+9)
Compiler          509MB ± 0%        532MB ± 0%  +4.46%  (p=0.000 n=10+10)
SSA              1.49GB ± 0%       1.55GB ± 0%  +4.10%  (p=0.000 n=10+10)
Flate            23.8MB ± 0%       24.5MB ± 0%  +2.92%  (p=0.000 n=10+10)
GoParser         27.9MB ± 0%       28.7MB ± 0%  +2.88%  (p=0.000 n=10+10)
Reflect          77.4MB ± 0%       80.5MB ± 0%  +4.01%  (p=0.000 n=10+10)
Tar              34.1MB ± 0%       35.1MB ± 0%  +3.12%  (p=0.000 n=10+10)
XML              42.6MB ± 0%       43.7MB ± 0%  +2.65%  (p=0.000 n=10+10)
[Geo mean]       76.1MB            78.4MB       +3.11%

name        old allocs/op     new allocs/op     delta
Template           320k ± 0%         335k ± 0%  +4.60%  (p=0.000 n=10+10)
Unicode            336k ± 0%         339k ± 0%  +0.96%  (p=0.000 n=9+10)
GoTypes           1.12M ± 0%        1.18M ± 0%  +4.55%  (p=0.000 n=10+10)
Compiler          4.66M ± 0%        4.94M ± 0%  +6.18%  (p=0.000 n=10+10)
SSA               11.9M ± 0%        12.5M ± 0%  +5.37%  (p=0.000 n=10+10)
Flate              214k ± 0%         223k ± 0%  +4.15%  (p=0.000 n=9+10)
GoParser           270k ± 0%         281k ± 0%  +4.15%  (p=0.000 n=10+10)
Reflect            921k ± 0%         963k ± 0%  +4.49%  (p=0.000 n=10+10)
Tar                317k ± 0%         330k ± 0%  +4.25%  (p=0.000 n=10+10)
XML                375k ± 0%         392k ± 0%  +4.75%  (p=0.000 n=10+10)
[Geo mean]         729k              761k       +4.34%

Updates #24543.

Change-Id: Ia951fdb3c17ae1c156e1d05fc42e69caba33c91a
Reviewed-on: https://go-review.googlesource.com/110179
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-05-22 20:44:06 +00:00
Austin Clements
75dadbec1e cmd/compile: make LivenessMap dense
Currently liveness information is kept in a map keyed by *ssa.Value.
This made sense when liveness information was sparse, but now we have
liveness for nearly every ssa.Value. There's a fair amount of memory
and CPU overhead to this map now.

This CL replaces this map with a slice indexed by value ID.

Passes toolstash -cmp.

name        old time/op       new time/op       delta
Template          197ms ± 1%        194ms ± 1%  -1.60%  (p=0.000 n=9+10)
Unicode           100ms ± 2%         99ms ± 1%  -1.31%  (p=0.012 n=8+10)
GoTypes           695ms ± 1%        689ms ± 0%  -0.94%  (p=0.000 n=10+10)
Compiler          3.34s ± 2%        3.29s ± 1%  -1.26%  (p=0.000 n=10+9)
SSA               8.08s ± 0%        8.02s ± 2%  -0.70%  (p=0.034 n=8+10)
Flate             133ms ± 1%        131ms ± 1%  -1.04%  (p=0.006 n=10+9)
GoParser          163ms ± 1%        162ms ± 1%  -0.79%  (p=0.034 n=8+10)
Reflect           459ms ± 1%        454ms ± 0%  -1.06%  (p=0.000 n=10+8)
Tar               186ms ± 1%        185ms ± 1%  -0.87%  (p=0.003 n=9+9)
XML               238ms ± 1%        235ms ± 1%  -1.01%  (p=0.004 n=8+9)
[Geo mean]        418ms             414ms       -1.06%

name        old alloc/op      new alloc/op      delta
Template         36.4MB ± 0%       35.6MB ± 0%  -2.29%  (p=0.000 n=9+10)
Unicode          29.7MB ± 0%       29.5MB ± 0%  -0.68%  (p=0.000 n=10+10)
GoTypes           119MB ± 0%        117MB ± 0%  -2.30%  (p=0.000 n=9+9)
Compiler          546MB ± 0%        532MB ± 0%  -2.47%  (p=0.000 n=10+10)
SSA              1.59GB ± 0%       1.55GB ± 0%  -2.41%  (p=0.000 n=10+10)
Flate            24.9MB ± 0%       24.5MB ± 0%  -1.77%  (p=0.000 n=8+10)
GoParser         29.5MB ± 0%       28.7MB ± 0%  -2.60%  (p=0.000 n=9+10)
Reflect          81.7MB ± 0%       80.5MB ± 0%  -1.49%  (p=0.000 n=10+10)
Tar              35.7MB ± 0%       35.1MB ± 0%  -1.64%  (p=0.000 n=10+10)
XML              45.0MB ± 0%       43.7MB ± 0%  -2.76%  (p=0.000 n=9+10)
[Geo mean]       80.1MB            78.4MB       -2.04%

name        old allocs/op     new allocs/op     delta
Template           336k ± 0%         335k ± 0%  -0.31%  (p=0.000 n=9+10)
Unicode            339k ± 0%         339k ± 0%  -0.05%  (p=0.000 n=10+10)
GoTypes           1.18M ± 0%        1.18M ± 0%  -0.26%  (p=0.000 n=10+10)
Compiler          4.96M ± 0%        4.94M ± 0%  -0.24%  (p=0.000 n=10+10)
SSA               12.6M ± 0%        12.5M ± 0%  -0.30%  (p=0.000 n=10+10)
Flate              224k ± 0%         223k ± 0%  -0.30%  (p=0.000 n=10+10)
GoParser           282k ± 0%         281k ± 0%  -0.32%  (p=0.000 n=10+10)
Reflect            965k ± 0%         963k ± 0%  -0.27%  (p=0.000 n=9+10)
Tar                331k ± 0%         330k ± 0%  -0.27%  (p=0.000 n=10+10)
XML                393k ± 0%         392k ± 0%  -0.26%  (p=0.000 n=10+10)
[Geo mean]         763k              761k       -0.26%

Updates #24543.

Change-Id: I4cfd2461510d3c026a262760bca225dc37482341
Reviewed-on: https://go-review.googlesource.com/110178
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-22 20:44:05 +00:00
Austin Clements
3c36b8be66 cmd/compile: incrementally compact liveness maps
The per-Value slice of liveness maps is currently one of the largest
sources of allocation in the compiler. On cmd/compile/internal/ssa,
it's 5% of overall allocation, or 75MB in total. Enabling liveness
maps everywhere significantly increased this allocation footprint,
which in turn slowed down the compiler.

Improve this by compacting the liveness maps after every block is
processed. There are typically very few distinct liveness maps, so
compacting the maps after every block, rather than at the end of the
function, can significantly reduce these allocations.

Passes toolstash -cmp.

name        old time/op       new time/op       delta
Template          198ms ± 2%        196ms ± 1%  -1.11%  (p=0.008 n=9+10)
Unicode           100ms ± 1%         99ms ± 1%  -0.94%  (p=0.015 n=8+9)
GoTypes           703ms ± 2%        695ms ± 1%  -1.15%  (p=0.000 n=10+10)
Compiler          3.38s ± 3%        3.33s ± 0%  -1.66%  (p=0.000 n=10+9)
SSA               7.96s ± 1%        7.93s ± 1%    ~ 	(p=0.113 n=9+10)
Flate             134ms ± 1%        132ms ± 1%  -1.30%  (p=0.000 n=8+10)
GoParser          165ms ± 2%        163ms ± 1%  -1.32%  (p=0.013 n=9+10)
Reflect           462ms ± 2%        459ms ± 0%  -0.65%  (p=0.036 n=9+8)
Tar               188ms ± 2%        186ms ± 1%    ~     (p=0.173 n=8+10)
XML               243ms ± 7%        239ms ± 1%    ~     (p=0.684 n=10+10)
[Geo mean]        421ms             416ms       -1.10%

name        old alloc/op      new alloc/op      delta
Template         38.0MB ± 0%       36.5MB ± 0%  -3.98%  (p=0.000 n=10+10)
Unicode          30.3MB ± 0%       29.6MB ± 0%  -2.21% 	(p=0.000 n=10+10)
GoTypes           125MB ± 0%        120MB ± 0%  -4.51% 	(p=0.000 n=10+9)
Compiler          575MB ± 0%        546MB ± 0%  -5.06% 	(p=0.000 n=10+10)
SSA              1.64GB ± 0%       1.55GB ± 0%  -4.97% 	(p=0.000 n=10+10)
Flate            25.9MB ± 0%       25.0MB ± 0%  -3.41% 	(p=0.000 n=10+10)
GoParser         30.7MB ± 0%       29.5MB ± 0%  -3.97% 	(p=0.000 n=10+10)
Reflect          84.1MB ± 0%       81.9MB ± 0%  -2.64% 	(p=0.000 n=10+10)
Tar              37.0MB ± 0%       35.8MB ± 0%  -3.27% 	(p=0.000 n=10+9)
XML              47.2MB ± 0%       45.0MB ± 0%  -4.57% 	(p=0.000 n=10+10)
[Geo mean]       83.2MB            79.9MB       -3.86%

name        old allocs/op     new allocs/op     delta
Template           337k ± 0%         337k ± 0%  -0.06%  (p=0.000 n=10+10)
Unicode            340k ± 0%         340k ± 0%  -0.01% 	(p=0.014 n=10+10)
GoTypes           1.18M ± 0%        1.18M ± 0%  -0.04% 	(p=0.000 n=10+10)
Compiler          4.97M ± 0%        4.97M ± 0%  -0.03% 	(p=0.000 n=10+10)
SSA               12.3M ± 0%        12.3M ± 0%  -0.01% 	(p=0.000 n=10+10)
Flate              226k ± 0%         225k ± 0%  -0.09% 	(p=0.000 n=10+10)
GoParser           283k ± 0%         283k ± 0%  -0.06% 	(p=0.000 n=10+9)
Reflect            972k ± 0%         971k ± 0%  -0.04% 	(p=0.000 n=10+8)
Tar                333k ± 0%         332k ± 0%  -0.05% 	(p=0.000 n=10+9)
XML                395k ± 0%         395k ± 0%  -0.04% 	(p=0.000 n=10+10)
[Geo mean]         764k              764k       -0.04%

Updates #24543.

Change-Id: I6fdc46e4ddb6a8eea95d38242345205eb8397f0b
Reviewed-on: https://go-review.googlesource.com/110177
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-22 20:44:03 +00:00
Austin Clements
3c4aaf8a32 cmd/compile: abstract bvec sets
This moves the bvec hash table logic out of Liveness.compact and into
a bvecSet type. Furthermore, the bvecSet type has the ability to grow
dynamically, which the current implementation doesn't. In addition to
making the code cleaner, this will make it possible to incrementally
compact liveness bitmaps.

Passes toolstash -cmp

Updates #24543.

Change-Id: I46c53e504494206061a1f790ae4a02d768a65681
Reviewed-on: https://go-review.googlesource.com/110176
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-22 20:44:02 +00:00
Austin Clements
577c05ca1c cmd/compile: single pass over Blocks in Liveness.epilogue
Currently Liveness.epilogue makes three passes over the Blocks, but
there's no need to do this. Combine them into a single pass. This
eliminates the need for blockEffects.lastbitmapindex, but, more
importantly, will let us incrementally compact the liveness bitmaps
and significantly reduce allocatons in Liveness.epilogue.

Passes toolstash -cmp.

Updates #24543.

Change-Id: I27802bcd00d23aa122a7ec16cdfd739ae12dd7aa
Reviewed-on: https://go-review.googlesource.com/110175
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-05-22 20:44:01 +00:00
Hana Kim
51be90a251 cmd/vendor/README: temporary instruction for update
Until vgo sorts out and cleans up the vendoring process.

Ran govendor to update packages the cmd/pprof depends on
which resulted in deletion of some of unnecessary files.

Change-Id: Idfba53e94414e90a5e280222750a6df77e979a16
Reviewed-on: https://go-review.googlesource.com/114079
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
2018-05-22 20:38:19 +00:00
David Chase
402dd10a99 cmd/link: revert DWARF version to 2 for .debug_lines
On OSX 10.12 and earlier, paired with XCode 9.0,
specifying DWARF version 3 causes dsymutil to misbehave.
Version 2 appears to be good enough to allow processing
of the prologue_end opcode on (at least one version of)
Linux and OSX 10.13.

Fixes #25451.

Change-Id: Ic760e34248393a5386be96351c8e492da1d3413b
Reviewed-on: https://go-review.googlesource.com/114015
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-22 20:27:52 +00:00
Martin Möhrmann
f045ddc624 internal/cpu: add experiment to disable CPU features with GODEBUGCPU
Needs the go compiler to be build with GOEXPERIMENT=debugcpu to be active.

The GODEBUGCPU environment variable can be used to disable usage of
specific processor features in the Go standard library.
This is useful for testing and benchmarking different code paths that
are guarded by internal/cpu variable checks.

Use of processor features can not be enabled through GODEBUGCPU.

To disable usage of AVX and SSE41 cpu features on GOARCH amd64 use:
GODEBUGCPU=avx=0,sse41=0

The special "all" option can be used to disable all options:
GODEBUGCPU=all=0

Updates #12805
Updates #15403

Change-Id: I699c2e6f74d98472b6fb4b1e5ffbf29b15697aab
Reviewed-on: https://go-review.googlesource.com/91737
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-22 18:49:31 +00:00
Keith Randall
31ef3846a7 cmd/compile: add rulegen diagnostic
When rulegen complains about a missing type, report the line number
in the rules file.

Change-Id: Ic7c19e1d5f29547911909df5788945848a6080ff
Reviewed-on: https://go-review.googlesource.com/114004
Reviewed-by: David Chase <drchase@google.com>
2018-05-22 16:40:34 +00:00
Austin Clements
c5ed10f3be runtime: support for debugger function calls
This adds a mechanism for debuggers to safely inject calls to Go
functions on amd64. Debuggers must participate in a protocol with the
runtime, and need to know how to lay out a call frame, but the runtime
support takes care of the details of handling live pointers in
registers, stack growth, and detecting the trickier conditions when it
is unsafe to inject a user function call.

Fixes #21678.
Updates derekparker/delve#119.

Change-Id: I56d8ca67700f1f77e19d89e7fc92ab337b228834
Reviewed-on: https://go-review.googlesource.com/109699
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-22 15:55:05 +00:00
Austin Clements
9f95c9db23 cmd/compile, cmd/internal/obj: record register maps in binary
This adds FUNCDATA and PCDATA that records the register maps much like
the existing live arguments maps and live locals maps. The register
map is indexed independently from the argument and locals maps since
changes in register liveness tend not to correlate with changes to
argument and local liveness.

This is the final CL toward adding safe-points everywhere. The
following CLs will optimize liveness analysis to bring down the cost.
The effect of this CL is:

name        old time/op       new time/op       delta
Template          195ms ± 2%        197ms ± 1%    ~     (p=0.136 n=9+9)
Unicode          98.4ms ± 2%       99.7ms ± 1%  +1.39%  (p=0.004 n=10+10)
GoTypes           685ms ± 1%        700ms ± 1%  +2.06%  (p=0.000 n=9+9)
Compiler          3.28s ± 1%        3.34s ± 0%  +1.71%  (p=0.000 n=9+8)
SSA               7.79s ± 1%        7.91s ± 1%  +1.55%  (p=0.000 n=10+9)
Flate             133ms ± 2%        133ms ± 2%    ~     (p=0.190 n=10+10)
GoParser          161ms ± 2%        164ms ± 3%  +1.83%  (p=0.015 n=10+10)
Reflect           450ms ± 1%        457ms ± 1%  +1.62%  (p=0.000 n=10+10)
Tar               183ms ± 2%        185ms ± 1%  +0.91%  (p=0.008 n=9+10)
XML               234ms ± 1%        238ms ± 1%  +1.60%  (p=0.000 n=9+9)
[Geo mean]        411ms             417ms       +1.40%

name        old exe-bytes     new exe-bytes     delta
HelloSize         1.47M ± 0%        1.51M ± 0%  +2.79%  (p=0.000 n=10+10)

Compared to just before "cmd/internal/obj: consolidate emitting entry
stack map", the cumulative effect of adding stack maps everywhere and
register maps is:

name        old time/op       new time/op       delta
Template          185ms ± 2%        197ms ± 1%   +6.42%  (p=0.000 n=10+9)
Unicode          96.3ms ± 3%       99.7ms ± 1%   +3.60%  (p=0.000 n=10+10)
GoTypes           658ms ± 0%        700ms ± 1%   +6.37%  (p=0.000 n=10+9)
Compiler          3.14s ± 1%        3.34s ± 0%   +6.53%  (p=0.000 n=9+8)
SSA               7.41s ± 2%        7.91s ± 1%   +6.71%  (p=0.000 n=9+9)
Flate             126ms ± 1%        133ms ± 2%   +6.15%  (p=0.000 n=10+10)
GoParser          153ms ± 1%        164ms ± 3%   +6.89%  (p=0.000 n=10+10)
Reflect           437ms ± 1%        457ms ± 1%   +4.59%  (p=0.000 n=10+10)
Tar               178ms ± 1%        185ms ± 1%   +4.18%  (p=0.000 n=10+10)
XML               223ms ± 1%        238ms ± 1%   +6.39%  (p=0.000 n=10+9)
[Geo mean]        394ms             417ms        +5.78%

name        old alloc/op      new alloc/op      delta
Template         34.5MB ± 0%       38.0MB ± 0%  +10.19%  (p=0.000 n=10+10)
Unicode          29.3MB ± 0%       30.3MB ± 0%   +3.56%  (p=0.000 n=8+9)
GoTypes           113MB ± 0%        125MB ± 0%  +10.89%  (p=0.000 n=10+10)
Compiler          510MB ± 0%        575MB ± 0%  +12.79%  (p=0.000 n=10+10)
SSA              1.46GB ± 0%       1.64GB ± 0%  +12.40%  (p=0.000 n=10+10)
Flate            23.9MB ± 0%       25.9MB ± 0%   +8.56%  (p=0.000 n=10+10)
GoParser         28.0MB ± 0%       30.8MB ± 0%  +10.08%  (p=0.000 n=10+10)
Reflect          77.6MB ± 0%       84.3MB ± 0%   +8.63%  (p=0.000 n=10+10)
Tar              34.1MB ± 0%       37.0MB ± 0%   +8.44%  (p=0.000 n=10+10)
XML              42.7MB ± 0%       47.2MB ± 0%  +10.75%  (p=0.000 n=10+10)
[Geo mean]       76.0MB            83.3MB        +9.60%

name        old allocs/op     new allocs/op     delta
Template           321k ± 0%         337k ± 0%   +4.98%  (p=0.000 n=10+10)
Unicode            337k ± 0%         340k ± 0%   +1.04%  (p=0.000 n=10+9)
GoTypes           1.13M ± 0%        1.18M ± 0%   +4.85%  (p=0.000 n=10+10)
Compiler          4.67M ± 0%        4.96M ± 0%   +6.25%  (p=0.000 n=10+10)
SSA               11.7M ± 0%        12.3M ± 0%   +5.69%  (p=0.000 n=10+10)
Flate              216k ± 0%         226k ± 0%   +4.52%  (p=0.000 n=10+9)
GoParser           271k ± 0%         283k ± 0%   +4.52%  (p=0.000 n=10+10)
Reflect            927k ± 0%         972k ± 0%   +4.78%  (p=0.000 n=10+10)
Tar                318k ± 0%         333k ± 0%   +4.56%  (p=0.000 n=10+10)
XML                376k ± 0%         395k ± 0%   +5.04%  (p=0.000 n=10+10)
[Geo mean]         730k              764k        +4.61%

name        old exe-bytes     new exe-bytes     delta
HelloSize         1.46M ± 0%        1.51M ± 0%   +3.66%  (p=0.000 n=10+10)

For #24543.

Change-Id: I91e003dc64151916b384274884bf02a2d6862547
Reviewed-on: https://go-review.googlesource.com/109353
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-22 15:55:03 +00:00
Austin Clements
61158c162f cmd/compile: compute register liveness maps
This extends the liveness analysis to track registers containing live
pointers. We do this by tracking bitmaps for live pointer registers
in parallel with bitmaps for stack variables.

This does not yet do anything with these liveness maps, though they do
appear in the debug output for -live=2.

We'll optimize this in later CLs:

name        old time/op       new time/op       delta
Template          193ms ± 5%        195ms ± 2%    ~     (p=0.050 n=9+9)
Unicode          97.7ms ± 2%       98.4ms ± 2%    ~     (p=0.315 n=9+10)
GoTypes           674ms ± 2%        685ms ± 1%  +1.72%  (p=0.001 n=9+9)
Compiler          3.21s ± 1%        3.28s ± 1%  +2.28%  (p=0.000 n=10+9)
SSA               7.70s ± 1%        7.79s ± 1%  +1.07%  (p=0.015 n=10+10)
Flate             130ms ± 3%        133ms ± 2%  +2.19%  (p=0.003 n=10+10)
GoParser          159ms ± 3%        161ms ± 2%  +1.51%  (p=0.019 n=10+10)
Reflect           444ms ± 1%        450ms ± 1%  +1.43%  (p=0.000 n=9+10)
Tar               181ms ± 2%        183ms ± 2%  +1.45%  (p=0.010 n=10+9)
XML               230ms ± 1%        234ms ± 1%  +1.56%  (p=0.000 n=8+9)
[Geo mean]        405ms             411ms       +1.48%

No effect on binary size because we're not yet emitting the register
maps.

For #24543.

Change-Id: Ieb022f0aea89c0ea9a6f035195bce2f0e67dbae4
Reviewed-on: https://go-review.googlesource.com/109352
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-22 15:55:02 +00:00
Austin Clements
840f25bedd cmd/compile: dense numbering for GP registers
For register maps, we need a dense numbering of registers that may
contain pointers of interest to the garbage collector. Add this to
Register and compute it from the GP register set.

For #24543.

Change-Id: If6f0521effca5eca4d17895468b1fc52d67e0f32
Reviewed-on: https://go-review.googlesource.com/109351
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-22 15:55:01 +00:00
Austin Clements
4f765b18f8 cmd/compile: fix ARM64 build
Write barrier unsafe-point analysis needs to flow through
OpARM64MOVWUload in c-shared mode.

Change-Id: I4f06f54d9e74a739a1b4fcb9ab0a1ae9b7b88a95
Reviewed-on: https://go-review.googlesource.com/114077
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
2018-05-22 15:38:30 +00:00
Austin Clements
97bea97065 cmd/compile: fix unsafe-point analysis with -N
Compiling without optimizations (-N) can result in write barrier
blocks that have been optimized away but not actually pruned from the
block set. Fix unsafe-point analysis to recognize and ignore these.

For #24543.

Change-Id: I2ca86fb1a0346214ec71d7d6c17b6a121857b01d
Reviewed-on: https://go-review.googlesource.com/114076
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-22 15:26:32 +00:00
isharipo
5437cde96c cmd/asm: enable AVX512
- Uncomment tests for AVX512 encoder
- Permit instruction suffixes for x86
- Permit limited reg list [reg-reg] syntax for x86 for multi-source ops
- EVEX encoding support in obj/x86 (Z-cases, asmevex, etc.)
- optabs and ytabs generated by x86avxgen (https://golang.org/cl/107216)

Note: suffix formatting implemented with updated CConv function.
Now arch asm backend should register formatting function by
calling RegisterOpSuffix.

Updates #22779

Change-Id: I076a167ee49582700e058c56ad74e6696710c8c8
Reviewed-on: https://go-review.googlesource.com/113315
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-05-22 14:57:15 +00:00
Austin Clements
ed7a0682e2 cmd/compile: output stack map index everywhere it changes
Currently, the code generator only considers outputting stack map
indexes at CALL instructions. Raise this into the code generator loop
itself so that changes in the stack map index at any instruction emit
a PCDATA Prog before the actual instruction.

We'll optimize this in later CLs:

name        old time/op       new time/op       delta
Template          190ms ± 2%        191ms ± 2%    ~     (p=0.529 n=10+10)
Unicode          96.4ms ± 1%       98.5ms ± 3%  +2.18%  (p=0.001 n=9+10)
GoTypes           669ms ± 1%        673ms ± 1%  +0.62%  (p=0.004 n=9+9)
Compiler          3.18s ± 1%        3.22s ± 1%  +1.06%  (p=0.000 n=10+9)
SSA               7.59s ± 1%        7.64s ± 1%  +0.66%  (p=0.023 n=10+10)
Flate             128ms ± 1%        130ms ± 2%  +1.07%  (p=0.043 n=10+10)
GoParser          157ms ± 2%        158ms ± 3%    ~     (p=0.123 n=10+10)
Reflect           442ms ± 1%        445ms ± 1%  +0.73%  (p=0.017 n=10+9)
Tar               179ms ± 1%        180ms ± 1%  +0.58%  (p=0.019 n=9+9)
XML               229ms ± 1%        232ms ± 2%  +1.27%  (p=0.009 n=10+10)
[Geo mean]        401ms             405ms       +0.94%

name        old exe-bytes     new exe-bytes     delta
HelloSize         1.46M ± 0%        1.47M ± 0%  +0.84%  (p=0.000 n=10+10)
[Geo mean]        1.46M             1.47M       +0.84%

For #24543.

Change-Id: I4bfe45b767c9d9db47308a27763b303fa75bfa54
Reviewed-on: https://go-review.googlesource.com/109350
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-22 14:43:38 +00:00
Austin Clements
a367f44c18 cmd/compile: enable stack maps everywhere except unsafe points
This modifies issafepoint in liveness analysis to report almost every
operation as a safe point. There are four things we don't mark as
safe-points:

1. Runtime code (other than at calls).

2. go:nosplit functions (other than at calls).

3. Instructions between the load of the write barrier-enabled flag and
   the write.

4. Instructions leading up to a uintptr -> unsafe.Pointer conversion.

We'll optimize this in later CLs:

name        old time/op       new time/op       delta
Template          185ms ± 2%        190ms ± 2%   +2.95%  (p=0.000 n=10+10)
Unicode          96.3ms ± 3%       96.4ms ± 1%     ~     (p=0.905 n=10+9)
GoTypes           658ms ± 0%        669ms ± 1%   +1.72%  (p=0.000 n=10+9)
Compiler          3.14s ± 1%        3.18s ± 1%   +1.56%  (p=0.000 n=9+10)
SSA               7.41s ± 2%        7.59s ± 1%   +2.48%  (p=0.000 n=9+10)
Flate             126ms ± 1%        128ms ± 1%   +2.08%  (p=0.000 n=10+10)
GoParser          153ms ± 1%        157ms ± 2%   +2.38%  (p=0.000 n=10+10)
Reflect           437ms ± 1%        442ms ± 1%   +0.98%  (p=0.001 n=10+10)
Tar               178ms ± 1%        179ms ± 1%   +0.67%  (p=0.035 n=10+9)
XML               223ms ± 1%        229ms ± 1%   +2.58%  (p=0.000 n=10+10)
[Geo mean]        394ms             401ms        +1.75%

No effect on binary size because we're not yet emitting these extra
safe points.

For #24543.

Change-Id: I16a1eebb9183cad7cef9d53c0fd21a973cad6859
Reviewed-on: https://go-review.googlesource.com/109348
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-05-22 14:43:37 +00:00
Austin Clements
d7d9df8a5b cmd/compile: introduce LivenessMap and LivenessIndex
Currently liveness only produces a stack map index at each safe point,
so the information is summarized in a map[*ssa.Value]int. We're about
to have both a stack map index and a register map index, so replace
the int with a LivenessIndex type we can extend, and replace the map
with a LivenessMap that we can also change more easily in the future.

This also gives us an easy hook for defining the value that means "not
a safe point".

Passes toolstash -cmp.

For #24543.

Change-Id: Ic4c069839635efed4fd0f603899b80f8be3b56ec
Reviewed-on: https://go-review.googlesource.com/109347
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-22 14:43:36 +00:00
Austin Clements
02495da6b6 cmd/internal/obj: consolidate emitting entry stack map
The obj package needs to emit the PCDATA to select the entry stack map
before calling morestack. Currently this is copied for every
architecture. Since we're about to change how this works, consolidate
all of these copies into a single helper function.

For #24543.

Change-Id: Ia92d94de78f8e23fd06dba747c43e03e5989f67b
Reviewed-on: https://go-review.googlesource.com/109346
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-22 14:43:35 +00:00
Austin Clements
837ed98d63 cmd/compile: don't produce a past-the-end pointer in range loops
Currently, range loops over slices and arrays are compiled roughly
like:

for i, x := range s { b }
  ⇓
for i, _n, _p := 0, len(s), &s[0]; i < _n; i, _p = i+1, _p + unsafe.Sizeof(s[0]) { b }
  ⇓
i, _n, _p := 0, len(s), &s[0]
goto cond
body:
{ b }
i, _p = i+1, _p + unsafe.Sizeof(s[0])
cond:
if i < _n { goto body } else { goto end }
end:

The problem with this lowering is that _p may temporarily point past
the end of the allocation the moment before the loop terminates. Right
now this isn't a problem because there's never a safe-point during
this brief moment.

We're about to introduce safe-points everywhere, so this bad pointer
is going to be a problem. We could mark the increment as an unsafe
block, but this inhibits reordering opportunities and could result in
infrequent safe-points if the body is short.

Instead, this CL fixes this by changing how we compile range loops to
never produce this past-the-end pointer. It changes the lowering to
roughly:

i, _n, _p := 0, len(s), &s[0]
if i < _n { goto body } else { goto end }
top:
_p += unsafe.Sizeof(s[0])
body:
{ b }
i++
if i < _n { goto top } else { goto end }
end:

Notably, the increment is split into two parts: we increment the index
before checking the condition, but increment the pointer only *after*
the condition check has succeeded.

The implementation builds on the OFORUNTIL construct that was
introduced during the loop preemption experiments, since OFORUNTIL
places the increment and condition after the loop body. To support the
extra "late increment" step, we further define OFORUNTIL's "List"
field to contain the late increment statements. This makes all of this
a relatively small change.

This depends on the improvements to the prove pass in CL 102603. With
the current lowering, bounds-check elimination knows that i < _n in
the body because the body block is dominated by the cond block. In the
new lowering, deriving this fact requires detecting that i < _n on
*both* paths into body and hence is true in body. CL 102603 made prove
able to detect this.

The code size effect of this is minimal. The cmd/go binary on
linux/amd64 increases by 0.17%. Performance-wise, this actually
appears to be a net win, though it's mostly noise:

name                      old time/op    new time/op    delta
BinaryTree17-12              2.80s ± 0%     2.61s ± 1%  -6.88%  (p=0.000 n=20+18)
Fannkuch11-12                2.41s ± 0%     2.42s ± 0%  +0.05%  (p=0.005 n=20+20)
FmtFprintfEmpty-12          41.6ns ± 5%    41.4ns ± 6%    ~     (p=0.765 n=20+19)
FmtFprintfString-12         69.4ns ± 3%    69.3ns ± 1%    ~     (p=0.084 n=19+17)
FmtFprintfInt-12            76.1ns ± 1%    77.3ns ± 1%  +1.57%  (p=0.000 n=19+19)
FmtFprintfIntInt-12          122ns ± 2%     123ns ± 3%  +0.95%  (p=0.015 n=20+20)
FmtFprintfPrefixedInt-12     153ns ± 2%     151ns ± 3%  -1.27%  (p=0.013 n=20+20)
FmtFprintfFloat-12           215ns ± 0%     216ns ± 0%  +0.47%  (p=0.000 n=20+16)
FmtManyArgs-12               486ns ± 1%     498ns ± 0%  +2.40%  (p=0.000 n=20+17)
GobDecode-12                6.43ms ± 0%    6.50ms ± 0%  +1.08%  (p=0.000 n=18+19)
GobEncode-12                5.43ms ± 1%    5.47ms ± 0%  +0.76%  (p=0.000 n=20+20)
Gzip-12                      218ms ± 1%     218ms ± 1%    ~     (p=0.883 n=20+20)
Gunzip-12                   38.8ms ± 0%    38.9ms ± 0%    ~     (p=0.644 n=19+19)
HTTPClientServer-12         76.2µs ± 1%    76.4µs ± 2%    ~     (p=0.218 n=20+20)
JSONEncode-12               12.2ms ± 0%    12.3ms ± 1%  +0.45%  (p=0.000 n=19+19)
JSONDecode-12               54.2ms ± 1%    53.3ms ± 0%  -1.67%  (p=0.000 n=20+20)
Mandelbrot200-12            3.71ms ± 0%    3.71ms ± 0%    ~     (p=0.143 n=19+20)
GoParse-12                  3.22ms ± 0%    3.19ms ± 1%  -0.72%  (p=0.000 n=20+20)
RegexpMatchEasy0_32-12      76.7ns ± 1%    75.8ns ± 1%  -1.19%  (p=0.000 n=20+17)
RegexpMatchEasy0_1K-12       245ns ± 1%     243ns ± 0%  -0.72%  (p=0.000 n=18+17)
RegexpMatchEasy1_32-12      71.9ns ± 0%    71.7ns ± 1%  -0.39%  (p=0.006 n=12+18)
RegexpMatchEasy1_1K-12       358ns ± 1%     354ns ± 1%  -1.13%  (p=0.000 n=20+19)
RegexpMatchMedium_32-12      105ns ± 2%     105ns ± 1%  -0.63%  (p=0.007 n=19+20)
RegexpMatchMedium_1K-12     31.9µs ± 1%    31.9µs ± 1%    ~     (p=1.000 n=17+17)
RegexpMatchHard_32-12       1.51µs ± 1%    1.52µs ± 2%  +0.46%  (p=0.042 n=18+18)
RegexpMatchHard_1K-12       45.3µs ± 1%    45.5µs ± 2%  +0.44%  (p=0.029 n=18+19)
Revcomp-12                   388ms ± 1%     385ms ± 0%  -0.57%  (p=0.000 n=19+18)
Template-12                 63.0ms ± 1%    63.3ms ± 0%  +0.50%  (p=0.000 n=19+20)
TimeParse-12                 309ns ± 1%     307ns ± 0%  -0.62%  (p=0.000 n=20+20)
TimeFormat-12                328ns ± 0%     333ns ± 0%  +1.35%  (p=0.000 n=19+19)
[Geo mean]                  47.0µs         46.9µs       -0.20%

(https://perf.golang.org/search?q=upload:20180326.1)

For #10958.
For #24543.

Change-Id: Icbd52e711fdbe7938a1fea3e6baca1104b53ac3a
Reviewed-on: https://go-review.googlesource.com/102604
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-05-22 14:15:46 +00:00
Austin Clements
b812eec928 cmd/compile: detect OFORUNTIL inductive facts in prove
Currently, we compile range loops into for loops with the obvious
initialization and update of the index variable. In this form, the
prove pass can see that the body is dominated by an i < len condition,
and findIndVar can detect that i is an induction variable and that
0 <= i < len.

GOEXPERIMENT=preemptibleloops compiles range loops to OFORUNTIL and
we're preparing to unconditionally switch to a variation of this for
 #24543. OFORUNTIL moves the increment and condition *after* the body,
which makes the bounds on the index variable much less obvious. With
OFORUNTIL, proving anything about the index variable requires
understanding the phi that joins the index values at the top of the
loop body block.

This interferes with both prove's ability to see that i < len (this is
true on both paths that enter the body, but from two different
conditional checks) and with findIndVar's ability to detect the
induction pattern.

Fix this by teaching prove to detect that the index in the pattern
constructed by OFORUNTIL is an induction variable and add both bounds
to the facts table. Currently this is done separately from findIndVar
because it depends on prove's factsTable, while findIndVar runs before
visiting blocks and building the factsTable.

Without any GOEXPERIMENT, this has no effect on std or cmd. However,
with GOEXPERIMENT=preemptibleloops, this change becomes necessary to
prove 90 conditions in std and cmd.

Change-Id: Ic025d669f81b53426309da5a6e8010e5ccaf4f49
Reviewed-on: https://go-review.googlesource.com/102603
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-22 14:15:44 +00:00
Austin Clements
4816eface1 cmd/compile: derive len/cap relations in factsTable.update
Currently, the prove pass derives implicit relations between len and
cap in the code that adds branch conditions. This is fine right now
because that's the only place we can encounter len and cap, but we're
about to add a second way to add assertions to the facts table that
can also produce facts involving len and cap.

Prepare for this by moving the fact derivation from updateRestrictions
(where it only applies on branches) to factsTable.update, which can
derive these facts no matter where the root facts come from.

Passes toolstash -cmp.

Change-Id: If09692d9eb98ffaa93f4cfa58ed2d8ba0887c111
Reviewed-on: https://go-review.googlesource.com/102602
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-05-22 14:15:43 +00:00
Austin Clements
8d8f620f68 cmd/compile: teach prove about relations between constants
Currently, we never add a relation between two constants to prove's
fact table because these are eliminated before prove runs, so it
currently doesn't handle facts like this very well even though they're
easy to prove.

We're about to start asserting some conditions that don't appear in
the SSA, but are constructed from existing SSA values that may both be
constants.

Hence, improve the fact table to understand relations between
constants by initializing the constant bounds of constant values to
the value itself, rather than noLimit.

Passes toolstash -cmp.

Change-Id: I71f8dc294e59f19433feab1c10b6d3c99b7f1e26
Reviewed-on: https://go-review.googlesource.com/102601
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-05-22 14:15:42 +00:00
David Chase
87a18c6109 cmd/compile: refactor inlining parameters; inline panic
Inlining was refactored to perform tuning experiments,
with the "knobs" now set to also inline functions/methods
that include panic(), and -l=4 (inline calls) now expressed
as a change to costs, rather than scattered if-thens.

The -l=4 inline-calls penalty is chosen to be the best
found during experiments; it makes some programs much
larger and slower (notably, the compiler itself) and is
believed to be risky for machine-generated code in general,
which is why it is not the default.  It is also not
well-tested with the debugger and DWARF output.

This change includes an explicit go:noinline applied to the
method that is the largest cause of compiler binary growth
and slowdown for midstack inlining; there are others,
ideally whatever heuristic eventually appears will make
this unnecessary.

Change-Id: Idf7056ed2f961472cf49d2fd154ee98bef9421e2
Reviewed-on: https://go-review.googlesource.com/109918
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-05-22 02:58:04 +00:00
Elias Naur
c8d07295c5 cmd/link,runtime: move syscalls to libc on iOS
This CL is the darwin/arm and darwin/arm64 equivalent to CL 108679,
110215, 110437, 110438, 111258, 110655.

Updates #17490

Change-Id: Ia95b27b38f9c3535012c566f17a44b4ed26b9db6
Reviewed-on: https://go-review.googlesource.com/111015
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-21 20:35:00 +00:00
Alberto Donizetti
5095e5d8e2 cmd/go: test that Go binaries can be run on QEMU in user-mode
We have a workaround in place in the runtime (see CL 16853 and
CL 111176) to keep arm and arm64 Go binaries working under QEMU
in user-emulation mode (Issue #13024).

This change adds a regression test about arm/arm64 QEMU emulation
to cmd/go.

Change-Id: Ic67f476e7c30a7d7852d9b01834f1dcabfac2ff7
Reviewed-on: https://go-review.googlesource.com/111477
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-21 18:13:25 +00:00
Daniel Martí
64a832debe cmd/trace: fix a few bugs found by staticcheck
First, the regions sort was buggy, as its last comparison was
ineffective.

Second, the insyscall and insyscallRuntime fields were unsigned, so the
check for them being negative was pointless. Make them signed instead,
to also prevent the possibility of underflows when decreasing numbers
that might realistically be 0.

Third, the color constants were all untyped strings except the first
one. Be consistent with their typing.

Change-Id: I4eb8d08028ed92589493c2a4b9cc5a88d83f769b
Reviewed-on: https://go-review.googlesource.com/113895
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-21 16:18:29 +00:00
Michael Munday
5654114d04 cmd/compile: use math/bits functions where possible
Use the math/bits functions to calculate the number of leading/
trailing zeros, bit length and the population count.

The math/bits package is built as part of the bootstrap process
so we do not need to provide an alternative implementation for
Go versions prior to 1.9.

Passes toolstash-check -all.

Change-Id: I393b4cc1c8accd0ca7cb3599d3926fa6319b574f
Reviewed-on: https://go-review.googlesource.com/113336
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-21 09:20:25 +00:00
Keith Randall
e86c26789d runtime: fix darwin 386/amd64 stack switches
A few libc_ calls were missing stack switches.

Unfortunately, adding the stack switches revealed a deeper problem.
systemstack() is fundamentally flawed because when you do

    systemstack(func() { ... })

There's no way to mark the anonymous function as nosplit.  At first I
thought it didn't matter, as that function runs on the g0 stack.  But
nosplit is still required, because some syscalls are done when stack
bounds are not set up correctly (e.g. in a signal handler, which runs
on the g0 stack, but g is still pointing at the g stack).  Instead use
asmcgocall and funcPC, so we can be nosplit all the way down.

Mid-stack inlining now pushes darwin over the nosplit limit also.
Leaving that as a TODO.
Update #23168

This might fix the cause of occasional darwin hangs.
Update #25181

Update #17490

Change-Id: If9c3ef052822c7679f5a1dd192443f714483327e
Reviewed-on: https://go-review.googlesource.com/111258
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-19 17:38:01 +00:00
David Chase
529362e1e2 cmd/compile: refactor and cleanup of common code/workaround
There's a glitch in how attributes from procs that do not
generate code are combined, and the workaround for this
glitch appeared in two places.

"One big pile is better than two little ones."

Updates #25426.

Change-Id: I252f9adc5b77591720a61fa22e6f9dda33d95350
Reviewed-on: https://go-review.googlesource.com/113717
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2018-05-18 21:00:56 +00:00
Daniel Martí
8a16c71067 cmd/vet: -composites only checks imported types
The check has worked this way for a long time, but it has never been
well documented.

For #25453.

Change-Id: If603e53348ba51f73b2f449b943c6f97f64aa3eb
Reviewed-on: https://go-review.googlesource.com/113755
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2018-05-18 13:54:12 +00:00
Ian Lance Taylor
226651a541 cmd/go: don't pass -compiler flag to vet
Without this running go vet -compiler=gccgo causes vet to fail.
The vet tool does need to know the compiler, but it is passed in
vetConfig.Compiler.

Change-Id: If857be4f336f6d7c425972fabcf82fae2cdc8a90
Reviewed-on: https://go-review.googlesource.com/113715
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-18 03:52:36 +00:00
isharipo
8bb391312c cmd/link/internal/ld: don't call fieldtrack if it's not enabled
If go toolchain is not built with GOEXPERIMENT=fieldtrack,
skip fieldtrack pass in the linker as it does full symtab traversal.

For linking "hello world" example from net/http:

	name      old time/op  new time/op  delta
	Linker-4   530ms ± 2%   525ms ± 2%  -1.03%  (p=0.028 n=17+19)

Fixes #20318
Updates #14624

Change-Id: I99336513db77d13f95f47d27339d76f01c42a5da
Reviewed-on: https://go-review.googlesource.com/113635
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-17 17:12:27 +00:00
isharipo
d2c68bb65f cmd/internal/obj/x86: fix VPERMQ and VPERMPD ytab
Fixes invalid encoding of VPERMQ and VPERMPD that use
negative immediate argument.

Fixes #25418
Updates #25420

Change-Id: Idd8180c4c632a76b76f3a68efd5f930d94431994
Reviewed-on: https://go-review.googlesource.com/113615
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
2018-05-17 16:20:25 +00:00
Zhou Peng
67894aa7e2 cmd/asm/internal/asm/testdata: convert CRLF to LF line ending
Change-Id: Icbff14b52e040826bc6de704942ff2f8e0164e3e
Reviewed-on: https://go-review.googlesource.com/113596
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-17 14:26:16 +00:00
Hana (Hyang-Ah) Kim
750a42f42c cmd/vendor/.../pprof: delete pprof.go file
The file is not used ('go tool' uses cmd/pprof/pprof.go instead)
and the external package import in this file causes test failure.

Fixes #25367

Change-Id: I71fbf8a3631efb1bd9e459b8247e5f7a6683894c
Reviewed-on: https://go-review.googlesource.com/113295
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-17 10:11:31 +00:00
Brad Fitzpatrick
594a6bde33 cmd/dist: add support for disabling test -short mode
So we can have builders running go test -short=false.

Updates golang/go#12508

Change-Id: If90f0f6d9f89268c33b1d1876139ad551fecd3d8
Reviewed-on: https://go-review.googlesource.com/113435
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-16 19:49:01 +00:00
Tobias Klauser
ca3364836f cmd/internal/objfile, debug/macho: support disassembling arm64 Mach-O objects
Fixes #25423

Change-Id: I6bed0726b8f4c7d607a3df271b2ab1006e96fa75
Reviewed-on: https://go-review.googlesource.com/113356
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-16 15:32:50 +00:00
Michael Munday
3797f88f24 cmd/compile: improve error message emitted by debug info generation
Before:

unexpected at 2721:load with unexpected source op v3278unexpected at 2775:load with
unexpected source op v3281unexpected at 2249:load with unexpected source op
v3289unexpected at 2875:load with unexpected source op v3278unexpected at 2232:load
with unexpected source op v286unexpected at 2231:load with unexpected source op
v3291unexpected at 2784:load with unexpected source op v3289unexpected at 2785:load
with unexpected source op v3291

After:

debug info generation: v2721: load with unexpected source op: Phi (v3278)
debug info generation: v2775: load with unexpected source op: Phi (v3281)
debug info generation: v2249: load with unexpected source op: Phi (v3289)
debug info generation: v2875: load with unexpected source op: Phi (v3278)
debug info generation: v2232: load with unexpected source op: Phi (v286)
debug info generation: v2231: load with unexpected source op: Phi (v3291)
debug info generation: v2784: load with unexpected source op: Phi (v3289)
debug info generation: v2785: load with unexpected source op: Phi (v3291)

Updates #25404.

Change-Id: Ib97722848d27ca18bdcd482a610626bc3c6def7d
Reviewed-on: https://go-review.googlesource.com/113275
Run-TryBot: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2018-05-15 17:48:30 +00:00
David du Colombier
218650fac8 cmd/compile: skip TestStmtLines on Plan 9
TestStmtLines has been added in CL 102435.
This test is failing on Plan 9 because executables
don't have a DWARF symbol table.

Fixes #25387.

Change-Id: I6ae7cba0e8ad4ab569a29ea8920b7849acfb9846
Reviewed-on: https://go-review.googlesource.com/113115
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-05-14 21:05:27 +00:00
Alberto Donizetti
05ca34093b testing: only compute b.N once when passed -count > 1
When running a benchmark multiple times, instead of re-computing the
value of b.N each time, use the value found by the first run.

For

  go test -bench=. -benchtime 3s -count 2 p_test.go

on the benchmark in the linked issue; before:

  BenchmarkBenchmark-4   	     500	  10180593 ns/op
  --- BENCH: BenchmarkBenchmark-4
  	  p_test.go:13: single call took 10.111079ms
  	  p_test.go:13: single call took 1.017298685s
  	  p_test.go:13: single call took 5.090096124s
  BenchmarkBenchmark-4   	     500	  10182164 ns/op
  --- BENCH: BenchmarkBenchmark-4
  	  p_test.go:13: single call took 10.098169ms
  	  p_test.go:13: single call took 1.017712905s
  	  p_test.go:13: single call took 5.090898517s
  PASS
  ok  	command-line-arguments	12.244s

and after:

  BenchmarkBenchmark-4   	     500	  10177076 ns/op
  --- BENCH: BenchmarkBenchmark-4
  	  p_test.go:13: single call took 10.091301ms
  	  p_test.go:13: single call took 1.016943125s
  	  p_test.go:13: single call took 5.088376028s
  BenchmarkBenchmark-4   	     500	  10171497 ns/op
  --- BENCH: BenchmarkBenchmark-4
  	  p_test.go:13: single call took 10.140245ms
  	  p_test.go:13: single call took 5.085605921s
  PASS
  ok  	command-line-arguments	11.218s

Fixes #23423

Change-Id: Ie66a8c5ac43881eb8741e14105db28745b4d56d3
Reviewed-on: https://go-review.googlesource.com/110775
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-14 17:07:43 +00:00
Giovanni Bajo
3c8545c5f6 cmd/compile: reduce allocations in prove by reusing posets
In prove, reuse posets between different functions by storing them
in the per-worker cache.

Allocation count regression caused by prove improvements is down
from 5% to 3% after this CL.

Updates #25179

Change-Id: I6d14003109833d9b3ef5165fdea00aa9c9e952e8
Reviewed-on: https://go-review.googlesource.com/110455
Run-TryBot: Giovanni Bajo <rasky@develer.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-05-14 14:44:55 +00:00
Giovanni Bajo
67656ba71b cmd/compile: improve undo of poset
prove uses the poset datastructure in a DFS walk, and always undoes
it back to its pristine status. Before this CL, poset's undo of
a new node creation didn't fully deallocate the node, which means
that at the end of prove there was still some allocated memory pending.

This was not a problem until now because the posets used by prove
were discarded after each function, but it would prevent recycling
them between functions (as a followup CL does).

Change-Id: I1c1c99c03fe19ad765395a43958cb256f686765a
Reviewed-on: https://go-review.googlesource.com/112976
Run-TryBot: Giovanni Bajo <rasky@develer.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
2018-05-14 14:31:48 +00:00
David Chase
7bac2a95f6 cmd/compile: plumb prologueEnd into DWARF
This marks the first instruction after the prologue for
consumption by debuggers, specifically Delve, who asked
for it.  gdb appears to ignore it, lldb appears to use it.

The bits for end-of-prologue and beginning-of-epilogue
are added to Pos (reducing maximum line number by 4x, to
1048575).  They're added in cmd/internal/obj/<ARCH>.go
(currently x86 only), so the compiler-proper need not
deal with them.

The linker currently does nothing with beginning-of-epilogue,
but the plumbing exists to make it easier in the future.

This also upgrades the line number table to DWARF version 3.

This CL includes a regression in the coverage for
testdata/i22558.gdb-dbg.nexts, this appears to be a gdb
artifact but the fix would be in the preceding CL in the
stack.

Change-Id: I3bda5f46a0ed232d137ad48f65a14835c742c506
Reviewed-on: https://go-review.googlesource.com/110416
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-05-14 14:12:31 +00:00
David Chase
c2c1822b12 cmd/compile: assign and preserve statement boundaries.
A new pass run after ssa building (before any other
optimization) identifies the "first" ssa node for each
statement. Other "noise" nodes are tagged as being never
appropriate for a statement boundary (e.g., VarKill, VarDef,
Phi).

Rewrite, deadcode, cse, and nilcheck are modified to move
the statement boundaries forward whenever possible if a
boundary-tagged ssa value is removed; never-boundary nodes
are ignored in this search (some operations involving
constants are also tagged as never-boundary and also ignored
because they are likely to be moved or removed during
optimization).

Code generation treats all nodes except those explicitly
marked as statement boundaries as "not statement" nodes,
and floats statement boundaries to the beginning of each
same-line run of instructions found within a basic block.

Line number html conversion was modified to make statement
boundary nodes a bit more obvious by prepending a "+".

The code in fuse.go that glued together the value slices
of two blocks produced a result that depended on the
former capacities (not lengths) of the two slices.  This
causes differences in the 386 bootstrap, and also can
sometimes put values into an order that does a worse job
of preserving statement boundaries when values are removed.

Portions of two delve tests that had caught problems were
incorporated into ssa/debug_test.go.  There are some
opportunities to do better with optimized code, but the
next-ing is not lying or overly jumpy.

Over 4 CLs, compilebench geomean measured binary size
increase of 3.5% and compile user time increase of 3.8%
(this is after optimization to reuse a sparse map instead
of creating multiple maps.)

This CL worsens the optimized-debugging experience with
Delve; we need to work with the delve team so that
they can use the is_stmt marks that we're emitting now.

The reference output changes from time to time depending
on other changes in the compiler, sometimes better,
sometimes worse.

This CL now includes a test ensuring that 99+% of the lines
in the Go command itself (a handy optimized binary) include
is_stmt markers.

Change-Id: I359c94e06843f1eb41f9da437bd614885aa9644a
Reviewed-on: https://go-review.googlesource.com/102435
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-05-14 14:09:49 +00:00
Yury Smolsky
c06f027520 cmd/go: fix TestBuildIDContainsArchModeEnv
Changing GOARCH, GOARM, GO386 leads to a stale dependency.

Updates #24436.

Change-Id: I5b5b3fca6401be50fa81fb040bc56356de7555de
Reviewed-on: https://go-review.googlesource.com/112975
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-14 13:45:18 +00:00
Ben Shi
bec2f51b07 cmd/internal/obj/arm: fix wrong encoding of MUL
The arm assembler incorrectly encodes the following instructions.
"MUL R2, R4" -> 0xe0040492 ("MUL R4, R2, R4")
"MUL R2, R4, R4" -> 0xe0040492 ("MUL R4, R2, R4")

The CL fixes that issue.

fixes #25347

Change-Id: I883716c7bc51c5f64837ae7d81342f94540a58cb
Reviewed-on: https://go-review.googlesource.com/112737
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-14 01:53:39 +00:00
Alessandro Arzilli
3636d53c61 cmd/link: writelines should keep is_stmt in sync with what it's writing
For all functions but the last one if the function ends on a
non-statement instruction the statement flag in debug_line is changed
but is_stmt is not updated to match.

Change-Id: I03c275c5e261ea672ce4da7baca2458810708326
Reviewed-on: https://go-review.googlesource.com/112979
Reviewed-by: David Chase <drchase@google.com>
2018-05-13 20:09:56 +00:00
Martin Möhrmann
6495bf1710 cmd/compile: ensure init of memclr happens after growslice in extendslice
Using the extendslice init node list to add the init nodes for the memclr
call could add init nodes for memclr function before the growslice call
created by extendslice.

As all arguments of the memclr were explicitly set in OAS nodes before
the memclr call this does not change the generated code currently.
./all.bash runs fine when replacing memclr init with nil suggesting there
are currently no additional nodes added to the init of extendslice by
the memclr call.

Add the init nodes for the memclr call directly before the node of the
memclr call to prevent additional future init nodes for function calls
and argument evaluations to be evaluated too early when other compiler
code is added.

passes toolstash -cmp

Updates #21266

Change-Id: I44bd396fe864bfda315175aa1064f9d51c5fb57a
Reviewed-on: https://go-review.googlesource.com/112595
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-13 14:45:58 +00:00
quasilyte
e405c9cca3 cmd/internal/obj/x86: use named consts for movtab Z-cases
Use 0-terminated opbyte sequences for Zlit-like movtabs instead of E=0xff.

movCodeFullPtr is unused (load full ptr is unsupported), but it should
be removed in a separate CL (if removed at all).

Passes toolstash-check.

Change-Id: I28436718d93b017153de0e50e3bcec344ea4ee05
Reviewed-on: https://go-review.googlesource.com/107076
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-05-11 14:40:34 +00:00
Robert Griesemer
b9c8e870d1 cmd/compile: use 'not defined' rather than 'unnamed' in error message
A receiver type may have an (alias type) name and thus be 'named'
even though the name doesn't refer to a defined type. Adjust the
error message to make this clearer.

Change-Id: I969bf8d1ba3db8820f67f6ecd6d5cfe564c5b80d
Reviewed-on: https://go-review.googlesource.com/112638
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-10 19:32:01 +00:00
Russ Cox
4826d20a09 cmd/go/internal/work: cache cgo invocations for vet, build modes
Even if we had an up-to-date package binary, we reran cgo anyway if
(1) we needed a header file for buildmode c-archive or c-shared, or
(2) we needed cgo-translated files source files for input to go vet.

Cache those outputs too, so that we can avoid cgo if possible.

Working toward exposing the cgo-generated files in go list.

Change-Id: I339ecace925d2b0adc235a17977ecadb3d636c73
Reviewed-on: https://go-review.googlesource.com/108015
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-05-10 19:15:33 +00:00
Russ Cox
9ccfde6ee7 cmd/go: add support for 'go run pkg' or 'go run .'
To date, go run has required a list of .go files.
This CL allows in place of that list a single import path
or a directory name or a pattern matching a single patckage.
This allows 'go run pkg' or 'go run dir', most importantly 'go run .'.

The discussion in #22726 gives more motivation.
The basic idea is that you can already run 'go test .'
but if you're developing a command it's pretty awkward
to iterate at the same speed. This lets you do that,
by using 'go run . [args]'.

Fixes #22726.

Change-Id: Ibfc8172a4f752588ad96df0a6b0928e9b61fa27f
Reviewed-on: https://go-review.googlesource.com/109341
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-05-10 19:15:27 +00:00
Russ Cox
670cb7603a cmd/go: remove import path debugging hooks
These are no longer needed.

Change-Id: Ie42a84f2bd24d2f59324bb66551c46e6af60c302
Reviewed-on: https://go-review.googlesource.com/109339
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-05-10 18:41:24 +00:00
Keith Randall
599f56dc05 cmd/compile: fix zero extend after float->int conversion
Don't do direct loads from argument slots if the sizes don't match.
This prevents us from loading from a float32 using a uint64 load
during expressions like uint64(math.float32Bits(f)) where f is a float32 arg.

Fixes #25322

Change-Id: I3887d76f78c844ba546243e7721d811c3d4a9700
Reviewed-on: https://go-review.googlesource.com/112637
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-10 17:32:43 +00:00
Lynn Boger
e4172e5f5e cmd/compile/internal/ssa: initialize t.UInt in SetTypPtrs()
Initialization of t.UInt is missing from SetTypPtrs in config.go,
preventing rules that use it from matching when they should.
This adds the initialization to allow those rules to work.

Updated test/codegen/rotate.go to test for this case, which
appears in math/bits RotateLeft32 and RotateLeft64. There had been
a testcase for this in go 1.10 but that went away when asm_test.go
was removed.

Change-Id: I82fc825ad8364df6fc36a69a1e448214d2e24ed5
Reviewed-on: https://go-review.googlesource.com/112518
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-10 14:50:30 +00:00
Richard Musiol
bf23a4e61d cmd/internal/obj/wasm: avoid invalid offsets for Load/Store
Offsets for Load and Store instructions have type i32. Bad index
expression offsets can cause an offset to be larger than MaxUint32,
which is not allowed. One example for this is the test test/index0.go.

Generate valid code by adding a guard to the responsible rewrite rule.
Also emit a proper error when using such a bad index in assembly code.

Change-Id: Ie90adcbf3ae3861c26680eb81790f28692913ccf
Reviewed-on: https://go-review.googlesource.com/111955
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-05-10 12:05:17 +00:00
Yury Smolsky
3e297120fd cmd/go: fix the rebuilding stale packages test
Non-main packages do not depend on the "runtime" package,
but main packages still do. Use a main package in the test.

This change passes the -i flag to the install command
to allow installation of updated dependencies,
and removes "install std" as unnecessary.

https://golang.org/cl/107957 is relevant to fixed test.

Updates #24436

Change-Id: If1845f37581a16ad77e72e50be21010e198bc7c5
Reviewed-on: https://go-review.googlesource.com/103675
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-09 21:14:24 +00:00
Hana (Hyang-Ah) Kim
46047e6447 cmd/vendor/.../pprof: update to 520140b6bf47519c766e8380e5f094576347b016
Change-Id: If431dfa59496b86f58f2ba2a83ca544a28a2a972
Reviewed-on: https://go-review.googlesource.com/112435
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-09 16:42:28 +00:00
Ian Lance Taylor
d540da105c go/build, cmd/go: don't expect gccgo to have GOROOT packages
When using gccgo the standard library sources are not available in
GOROOT. Don't expect them to be there. In the gccgo build, use a set
of standard library packages generated at build time.

Change-Id: Id133022604d9b7e778e73e8512f9080c61462fba
Reviewed-on: https://go-review.googlesource.com/111595
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2018-05-09 16:42:20 +00:00
Ian Lance Taylor
814c749c8f cmd/go: force untranslated output when running GCC/clang driver
When we look for the tool ID to use for a compiler, force untranslated
output so that we can match the literal string "version".

Fixes https://gcc.gnu.org/PR84765

Change-Id: I607df445dbd3c5a7c3a6907601adcb039ac16fc1
Reviewed-on: https://go-review.googlesource.com/111575
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2018-05-09 13:37:52 +00:00
Ian Lance Taylor
8088a7fc12 cmd/go: fix testsuite for gccgo
A number of cmd/go tests can never work with gccgo, for various
different reasons. Skip those tests when using gccgo. Adjust some
other tests to pass when using gccgo. Adjust one test to not skip when
using gccgo, since it does work.

Change-Id: I33b09558581a1e304416cf1c05a96f9526abba0e
Reviewed-on: https://go-review.googlesource.com/110915
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2018-05-09 12:54:58 +00:00
Ian Lance Taylor
c465064067 cmd/go: for gccgo, don't edit cgo header when using -o
This change was made to the gccgo sources as part of CL 47037.
It is required to make the testcarchive and testcshared tests work.
Otherwise using `go build -mode=c-archive -o libgo.a` will cause the
header file to be named go.h rather than libgo.h.

Change-Id: I2db1d7b0f575368b31273cc01097447a0471efd6
Reviewed-on: https://go-review.googlesource.com/111615
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2018-05-09 12:53:36 +00:00
Michael Munday
6d00e8c478 cmd/compile: convert memmove call into Move when arguments are disjoint
Move ops can be faster than memmove calls because the number of bytes
to be moved is fixed and they don't incur the overhead of a call.
This change allows memmove to be converted into a Move op when the
arguments are disjoint.

The optimization is only enabled on s390x at the moment, however
other architectures may also benefit from it in the future. The
memmove inlining rule triggers an extra 12 times when compiling the
standard library. It will most likely make more of a difference as the
disjoint function is improved over time (to recognize fresh heap
allocations for example).

Change-Id: I9af570dcfff28257b8e59e0ff584a46d8e248310
Reviewed-on: https://go-review.googlesource.com/110064
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
2018-05-09 11:20:40 +00:00
Martin Möhrmann
337cc29156 cmd/compile: simplify extendslice and isAppendOfMake
Change-Id: Ia66361812837dde23aac09e916f058ba509a323c
Reviewed-on: https://go-review.googlesource.com/111737
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2018-05-09 05:24:36 +00:00
Daniel Martí
2486ebfb63 cmd/vet: assume that no builtin funcs are pure
That was the intention with the existing code, but it was buggy; builtin
functions aren't treated as values by types.TypeAndVal. Thus, we should
use the IsBuiltin method instead of IsValue.

Teaching vet what builtin funcs are pure is already being tracked as a
separate issue, #22851.

While at it, also add a test with methods, just to be sure that the
current logic doesn't break with that edge case either.

Fixes #25303.

Change-Id: Ic18402b22cceeabf76641c02f575b194b9a536cc
Reviewed-on: https://go-review.googlesource.com/112177
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-05-09 05:13:03 +00:00
Martin Möhrmann
aee71dd70b cmd/compile: optimize map-clearing range idiom
replace map clears of the form:

        for k := range m {
                delete(m, k)
        }

(where m is map with key type that is reflexive for ==)
with a new runtime function that clears the maps backing
array with a memclr and reinitializes the hmap struct.

Map key types that for example contain floats are not
replaced by this optimization since NaN keys cannot
be deleted from maps using delete.

name                           old time/op  new time/op  delta
GoMapClear/Reflexive/1         92.2ns ± 1%  47.1ns ± 2%  -48.89%  (p=0.000 n=9+9)
GoMapClear/Reflexive/10         108ns ± 1%    48ns ± 2%  -55.68%  (p=0.000 n=10+10)
GoMapClear/Reflexive/100        303ns ± 2%   110ns ± 3%  -63.56%  (p=0.000 n=10+10)
GoMapClear/Reflexive/1000      3.58µs ± 3%  1.23µs ± 2%  -65.49%  (p=0.000 n=9+10)
GoMapClear/Reflexive/10000     28.2µs ± 3%  10.3µs ± 2%  -63.55%  (p=0.000 n=9+10)
GoMapClear/NonReflexive/1       121ns ± 2%   124ns ± 7%     ~     (p=0.097 n=10+10)
GoMapClear/NonReflexive/10      137ns ± 2%   139ns ± 3%   +1.53%  (p=0.033 n=10+10)
GoMapClear/NonReflexive/100     331ns ± 3%   334ns ± 2%     ~     (p=0.342 n=10+10)
GoMapClear/NonReflexive/1000   3.64µs ± 3%  3.64µs ± 2%     ~     (p=0.887 n=9+10)
GoMapClear/NonReflexive/10000  28.1µs ± 2%  28.4µs ± 3%     ~     (p=0.247 n=10+10)

Fixes #20138

Change-Id: I181332a8ef434a4f0d89659f492d8711db3f3213
Reviewed-on: https://go-review.googlesource.com/110055
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-08 21:15:16 +00:00
Hana (Hyang-Ah) Kim
43b18f4241 cmd/trace: handle invalid goid para in /trace
Change-Id: I1cb7c8b70a5ae16386f6abb577c23d821f7ff7f0
Reviewed-on: https://go-review.googlesource.com/112197
Reviewed-by: Peter Weinberger <pjw@google.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-05-08 19:25:01 +00:00
Hana (Hyang-Ah) Kim
9eface7077 cmd/trace: skip links for buckets with 0 count
Change-Id: Ib1c2f7cc8e8f631ed9e74161699332f492d4cb0d
Reviewed-on: https://go-review.googlesource.com/112196
Reviewed-by: Peter Weinberger <pjw@google.com>
2018-05-08 19:24:56 +00:00
Keith Randall
f32348669c cmd/compile: rename memory-using operations
Some *mem ops are loads, some are stores, some are modifications.
Replace mem->load for the loads.
Replace mem->store for the stores.
Replace mem->modify for the load-modify-stores.

The only semantic change in this CL is to mark
ADD(Q|L)constmodify (which used to be ADD(Q|L)constmem) as
both a read and a write, instead of just a write. This is arguably
a bug fix, but the bug isn't triggerable at the moment, see CL 112157.

Change-Id: Iccb45aea817b606adb2d712ff99b10ee28e4616a
Reviewed-on: https://go-review.googlesource.com/112159
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-08 19:16:50 +00:00