1
0
mirror of https://github.com/golang/go synced 2024-10-04 23:31:22 -06:00
Commit Graph

8167 Commits

Author SHA1 Message Date
David Crawshaw
c9638810df cmd/compile: use type. prefix on importpath symbol
This ensures that importpath symbols are treated like other type data
and end up in the same section under all build modes.

Fixes: go test -buildmode=pie reflect

Change-Id: Ibb8348648e8dcc850f2424d206990a06090ce4c6
Reviewed-on: https://go-review.googlesource.com/22081
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-14 19:59:15 +00:00
Josh Bleecher Snyder
644493f109 cmd/compile: clear hidden value at end of channel range body
While we’re here, clean up a few comments.

Fixes #15281

Change-Id: Ia6173e9941133db08f57bc80bdd3c5722122bfdb
Reviewed-on: https://go-review.googlesource.com/22082
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-04-14 19:20:26 +00:00
David Chase
6b0b3f86d6 cmd/compile: fix use of original spill name after sinking
This is a fix for the ssacheck builder
http://build.golang.org/log/baa00f70c34e41186051cfe90568de3d91f115d7
after CL 21307 for sinking spills down loop exits
https://go-review.googlesource.com/#/c/21037/

The fix is to reuse (move) the original spill, thus preserving
the definition of the variable and its use count. Original and
copy both use the same stack slot, but ssacheck needs to see
a definition for the variable itself.

Fixes #15279.

Change-Id: I286285490193dc211b312d64dbc5a54867730bd6
Reviewed-on: https://go-review.googlesource.com/21995
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-14 18:24:54 +00:00
Josh Bleecher Snyder
67cdec00c2 cmd/vet: teach asm checker about PEXTRD’s op size
Fixes #15271

Change-Id: I28e3fb5bde1e6fd5b263b1434873b8ce051aee97
Reviewed-on: https://go-review.googlesource.com/22083
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-04-14 17:58:51 +00:00
Matthew Dempsky
045411e6f2 cmd/internal/obj: remove use of package bio
Also add MustClose and MustWriter to cmd/internal/bio, and use them in
cmd/asm.

Change-Id: I07f5df3b66c17bc5b2e6ec9c4357d9b653e354e0
Reviewed-on: https://go-review.googlesource.com/21938
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-14 17:58:33 +00:00
Luan Santos
8d8feb4d2f cmd/vet: allow untyped composite literals to be unkeyed
We can trust that untyped composite literals are part of a slice literal
and not emit a vet warning for those.

Fixes #9171

Change-Id: Ia7c081e543b850f8be1fd1f9e711520061e70bed
Reviewed-on: https://go-review.googlesource.com/22000
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-04-14 16:20:58 +00:00
Dmitry Vyukov
2c9d773f74 misc/trace: update trace viewer html
The old trace-viewer is broken since Chrome 49:
https://bugs.chromium.org/p/chromium/issues/detail?id=569417
It was fixed in:
506457cbd7

This change updates trace-viewer to the latest version
(now it is called catapult).

This version has a bug in the lean config that we use, though:
https://github.com/catapult-project/catapult/issues/2247
So use full config for now (it works, but leads to larger html).
When the bug is fixed we need to switch back to lean config (issue #15302).

Change-Id: Ifb8d782ced66e3292d81c5604039fe18eaf267c5
Reviewed-on: https://go-review.googlesource.com/22013
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-14 14:48:04 +00:00
Matthew Dempsky
babfb4ec3b cmd/internal/obj: change Link.Flag_shared to bool
Change-Id: I9bda2ce6f45fb8292503f86d8f9f161601f222b7
Reviewed-on: https://go-review.googlesource.com/22053
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-04-14 02:11:17 +00:00
Matthew Dempsky
980ab12ade cmd/compile/internal/gc: change flags to bool where possible
Some of the Debug[x] flags are actually boolean too, but not all, so
they need to be handled separately.

While here, change some obj.Flagstr and obj.Flagint64 calls to
directly use flag.StringVar and flag.Int64Var instead.

Change-Id: Iccedf6fed4328240ee2257f57fe6d66688f237c4
Reviewed-on: https://go-review.googlesource.com/22052
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-04-14 02:10:35 +00:00
Robert Griesemer
ae98045958 cmd/compile: use correct export function (fix debugFormat)
Tested with debugFormat enabled and running
(export GO_GCFLAGS=-newexport; sh all.bash).

Change-Id: If7d43e1e594ea43c644232b89e670f7abb6b003e
Reviewed-on: https://go-review.googlesource.com/22033
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-04-14 00:41:29 +00:00
Robert Griesemer
6e5027a37a cmd/compile: don't export unneeded OAS, OASWB nodes
Also:
- "rewrite" node Op in exporter for some nodes instead of importer
- more comments

Change-Id: I809e6754d14987b28f1da9379951ffa2e690c2a7
Reviewed-on: https://go-review.googlesource.com/22008
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-13 23:16:02 +00:00
David Crawshaw
f120936dff cmd/compile, etc: use name for type pkgPath
By replacing the *string used to represent pkgPath with a
reflect.name everywhere, the embedded *string for package paths
inside the reflect.name can be replaced by an offset, nameOff.
This reduces the number of pointers in the type information.

This also moves all reflect.name types into the same section, making
it possible to use nameOff more widely in later CLs.

No significant binary size change for normal binaries, but:

linux/amd64 PIE:
	cmd/go: -440KB (3.7%)
	jujud:  -2.6MB (3.2%)

For #6853.

Change-Id: I3890b132a784a1090b1b72b32febfe0bea77eaee
Reviewed-on: https://go-review.googlesource.com/21395
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-13 20:48:26 +00:00
David Crawshaw
79048df2cc cmd/link: handle long symbol names
Fixes #15104.

Change-Id: I9ddfbbf39ef0a873b703ee3e04fbb7d1192f5f39
Reviewed-on: https://go-review.googlesource.com/21581
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-13 20:31:43 +00:00
Todd Neal
3ea7cfabbb cmd/compile: sort partitions by dom to speed up cse
We do two O(n) scans of all values in an eqclass when computing
substitutions for CSE.

In unfortunate cases, like those found in #15112, we can have a large
eqclass composed of values found in blocks none of whom dominate the
other.  This leads to O(n^2) behavior. The elements are removed one at a
time, with O(n) scans each time.

This CL removes the linear scan by sorting the eqclass so that dominant
values will be sorted first.  As long as we also ensure we don't disturb
the sort order, then we no longer need to scan for the maximally
dominant value.

For the code in issue #15112:

Before:
real    1m26.094s
user    1m30.776s
sys     0m1.125s

Aefter:
real    0m52.099s
user    0m56.829s
sys     0m1.092s

Updates #15112

Change-Id: Ic4f8680ed172e716232436d31963209c146ef850
Reviewed-on: https://go-review.googlesource.com/21981
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-13 19:55:15 +00:00
Dmitry Vyukov
da6205b67e cmd/pprof/internal/profile: always subtract 1 from PCs
Go runtime never emits PCs that are not a return address
(except for cpu profiler).

Change-Id: I08d9dc5c7c71e23f34f2f0c16f8baeeb4f64fcd6
Reviewed-on: https://go-review.googlesource.com/21735
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-13 17:22:38 +00:00
Robert Griesemer
eb79f21c48 cmd/compile, go/importer: minor cleanups
Change-Id: Ic7a1fb0dbbf108052c970a4a830269a5673df7df
Reviewed-on: https://go-review.googlesource.com/21963
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-04-13 17:03:08 +00:00
Robert Griesemer
7d0d122247 cmd/compile: move more compiler specifics into compiler specific export section
Instead of indicating with each function signature if it has an inlineable
body, collect all functions in order and export function bodies with function
index in platform-specific section.

Moves this compiler specific information out of the platform-independent
export data section, and removes an int value for all functions w/o body.
Also simplifies the code a bit.

Change-Id: I8b2d7299dbe81f2706be49ecfb9d9f7da85fd854
Reviewed-on: https://go-review.googlesource.com/21939
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-04-13 17:00:49 +00:00
David Chase
6b85a45edc cmd/compile: move spills to loop exits when easy.
For call-free inner loops.

Revised statistics:
  85 inner loop spills sunk
 341 inner loop spills remaining
1162 inner loop spills that were candidates for sinking
     ended up completely register allocated
 119 inner loop spills could have been sunk were used in
     "shuffling" at the bottom of the loop.
   1 inner loop spill not sunk because the register assigned
     changed between def and exit,

 Understanding how to make an inner loop definition not be
 a candidate for from-memory shuffling (to force the shuffle
 code to choose some other value) should pick up some of the
 119 other spills disqualified for this reason.

 Modified the stats printing based on feedback from Austin.

Change-Id: If3fb9b5d5a028f42ccc36c4e3d9e0da39db5ca60
Reviewed-on: https://go-review.googlesource.com/21037
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-13 15:59:42 +00:00
David Crawshaw
66afbf1010 cmd/link: use a switch for name prefix switching
Minor cleanup.

Change-Id: I7574f58a7e55c2bb798ebe9c7c98d36b8c258fb8
Reviewed-on: https://go-review.googlesource.com/21982
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-13 14:42:30 +00:00
David Crawshaw
7d469179e6 cmd/compile, etc: store method tables as offsets
This CL introduces the typeOff type and a lookup method of the same
name that can turn a typeOff offset into an *rtype.

In a typical Go binary (built with buildmode=exe, pie, c-archive, or
c-shared), there is one moduledata and all typeOff values are offsets
relative to firstmoduledata.types. This makes computing the pointer
cheap in typical programs.

With buildmode=shared (and one day, buildmode=plugin) there are
multiple modules whose relative offset is determined at runtime.
We identify a type in the general case by the pair of the original
*rtype that references it and its typeOff value. We determine
the module from the original pointer, and then use the typeOff from
there to compute the final *rtype.

To ensure there is only one *rtype representing each type, the
runtime initializes a typemap for each module, using any identical
type from an earlier module when resolving that offset. This means
that types computed from an offset match the type mapped by the
pointer dynamic relocations.

A series of followup CLs will replace other *rtype values with typeOff
(and name/*string with nameOff).

For types created at runtime by reflect, type offsets are treated as
global IDs and reference into a reflect offset map kept by the runtime.

darwin/amd64:
	cmd/go:  -57KB (0.6%)
	jujud:  -557KB (0.8%)

linux/amd64 PIE:
	cmd/go: -361KB (3.0%)
	jujud:  -3.5MB (4.2%)

For #6853.

Change-Id: Icf096fd884a0a0cb9f280f46f7a26c70a9006c96
Reviewed-on: https://go-review.googlesource.com/21285
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-13 13:03:11 +00:00
Alexandru Moșoi
e0611b1664 cmd/compile: use shared dom tree for cse, too
Missed this in the previous CL where the shared
dom tree was introduced.

Change-Id: If0bd85d4b4567d7e87814ed511603b1303ab3903
Reviewed-on: https://go-review.googlesource.com/21970
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-04-13 12:42:44 +00:00
Shahar Kohanim
61b7a9c57b cmd/link: rename Pcln to FuncInfo
After non pcln fields were added to it in a previous commit.

Change-Id: Icf92c0774d157c61399a6fc2a3c4d2cd47a634d2
Reviewed-on: https://go-review.googlesource.com/21921
Run-TryBot: Shahar Kohanim <skohanim@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-04-13 11:51:20 +00:00
Tal Shprecher
24967ec122 cmd/compile: make enqueued map keys fail validation on forward types
Map keys are currently validated in multiple locations but share
a common validation routine. The problem is that early validations
should be lenient enough to allow for forward types while the final
validations should not. The final validations should fail on forward
types since they've already settled.

This change also separates the key type checking from the creation
of the map via typMap. Instead of the mapqueue being populated in
copytype() by checking the map line number, it's populated in the
same block that validates the key type. This isolates key validation
logic while type checking.

Fixes #14988

Change-Id: Ia47cf6213585d6c63b3a35249104c0439feae658
Reviewed-on: https://go-review.googlesource.com/21830
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-13 08:43:12 +00:00
Matthew Dempsky
0e01db4b8d cmd/compile: fix crash on bare package name in constant declarations
Fixes #11361.

Change-Id: I70b8808f97f0e07de680e7e6ede1322ea0fdbbc0
Reviewed-on: https://go-review.googlesource.com/21936
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-13 06:37:39 +00:00
Tal Shprecher
6531fab06f cmd/compile: remove unnecessary assignments while type checking.
Change-Id: Ica0ec84714d7f01d800d62fa10cdb08321d43cf3
Reviewed-on: https://go-review.googlesource.com/21967
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-04-13 06:16:05 +00:00
Josh Bleecher Snyder
db5338f879 cmd/compile: teach CSE that new objects are bespoke
runtime.newobject never returns the same thing twice,
so the resulting value will never be a common subexpression.

This helps when compiling large static data structures
that include pointers, such as maps and slices.
No clear performance impact on other code. (See below.)

For the code in issue #15112:

Before:
  real	1m14.238s
  user	1m18.985s
  sys	0m0.787s

After:
  real	0m47.172s
  user	0m52.248s
  sys	0m0.767s

For the code in issue #15235, size 10k:

Before:
  real	0m44.916s
  user	0m46.577s
  sys	0m0.304s

After:
  real	0m7.703s
  user	0m9.041s
  sys	0m0.316s

Still more work to be done, particularly for #15112.

Updates #15112
Updates #15235


name       old time/op      new time/op      delta
Template        330ms ±11%       333ms ±13%    ~           (p=0.749 n=20+19)
Unicode         148ms ± 6%       152ms ± 8%    ~           (p=0.072 n=18+20)
GoTypes         1.01s ± 7%       1.01s ± 3%    ~           (p=0.583 n=20+20)
Compiler        5.04s ± 2%       5.06s ± 2%    ~           (p=0.314 n=20+20)

name       old user-ns/op   new user-ns/op   delta
Template   444user-ms ±11%  445user-ms ±10%    ~           (p=0.738 n=20+20)
Unicode    215user-ms ± 5%  218user-ms ± 5%    ~           (p=0.239 n=18+18)
GoTypes    1.45user-s ± 3%  1.45user-s ± 4%    ~           (p=0.620 n=20+20)
Compiler   7.23user-s ± 2%  7.22user-s ± 2%    ~           (p=0.901 n=20+19)

name       old alloc/op     new alloc/op     delta
Template       55.0MB ± 0%      55.0MB ± 0%    ~           (p=0.547 n=20+20)
Unicode        37.6MB ± 0%      37.6MB ± 0%    ~           (p=0.301 n=20+20)
GoTypes         177MB ± 0%       177MB ± 0%    ~           (p=0.065 n=20+19)
Compiler        798MB ± 0%       797MB ± 0%  -0.05%        (p=0.000 n=19+20)

name       old allocs/op    new allocs/op    delta
Template         492k ± 0%        493k ± 0%  +0.03%        (p=0.030 n=20+20)
Unicode          377k ± 0%        377k ± 0%    ~           (p=0.423 n=20+19)
GoTypes         1.40M ± 0%       1.40M ± 0%    ~           (p=0.102 n=20+20)
Compiler        5.53M ± 0%       5.53M ± 0%    ~           (p=0.094 n=17+18)

name       old text-bytes   new text-bytes   delta
HelloSize        561k ± 0%        561k ± 0%    ~     (all samples are equal)
CmdGoSize       6.13M ± 0%       6.13M ± 0%    ~     (all samples are equal)

name       old data-bytes   new data-bytes   delta
HelloSize        128k ± 0%        128k ± 0%    ~     (all samples are equal)
CmdGoSize        306k ± 0%        306k ± 0%    ~     (all samples are equal)

name       old exe-bytes    new exe-bytes    delta
HelloSize        905k ± 0%        905k ± 0%    ~     (all samples are equal)
CmdGoSize       9.64M ± 0%       9.64M ± 0%    ~     (all samples are equal)

Change-Id: Id774e2901d7701a3ec7a1c1d1cf1d9327a4107fc
Reviewed-on: https://go-review.googlesource.com/21937
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-04-13 02:11:56 +00:00
Shahar Kohanim
b0cbe158da cmd/link: move function only lsym fields to pcln struct
name       old secs    new secs    delta
LinkCmdGo   0.53 ± 9%   0.53 ±10%  -1.30%  (p=0.022 n=100+99)

name       old MaxRSS  new MaxRSS  delta
LinkCmdGo   151k ± 4%   142k ± 6%  -5.92%  (p=0.000 n=98+100)

Change-Id: Ic30e63a948f8e626b3396f458a0163f7234810c1
Reviewed-on: https://go-review.googlesource.com/21920
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-13 00:23:45 +00:00
Matthew Dempsky
e46b00a43b cmd/internal/obj: remove unused Pciter type
Change-Id: Ie8323cfcd1193f390729d0d3dd67863aedf47d13
Reviewed-on: https://go-review.googlesource.com/21906
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-12 22:12:42 +00:00
Shahar Kohanim
24fc323442 cmd/internal/obj: split plist flushing from object writing
Only splits into separate files, no other changes.

Change-Id: Icc0da2c5f18e03e9ed7c0043bd7c790f741900f2
Reviewed-on: https://go-review.googlesource.com/21804
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-12 21:07:16 +00:00
David Crawshaw
f028b9f9e2 cmd/link, etc: store typelinks as offsets
This is the first in a series of CLs to replace the use of pointers
in binary read-only data with offsets.

In standard Go binaries these CLs have a small effect, shrinking
8-byte pointers to 4-bytes. In position-independent code, it also
saves the dynamic relocation for the pointer. This has a significant
effect on the binary size when building as PIE, c-archive, or
c-shared.

darwin/amd64:
	cmd/go: -12KB (0.1%)
	jujud:  -82KB (0.1%)

linux/amd64 PIE:
	cmd/go:  -86KB (0.7%)
	jujud:  -569KB (0.7%)

For #6853.

Change-Id: Iad5625bbeba58dabfd4d334dbee3fcbfe04b2dcf
Reviewed-on: https://go-review.googlesource.com/21284
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-12 20:32:41 +00:00
Alberto Donizetti
da224a5c42 cmd/pprof: pass the event to pprof_toggle_asm for the weblist command
Fixes #15225

Change-Id: I1f85590b2c3293463c6476beebcd3256adc1bf23
Reviewed-on: https://go-review.googlesource.com/21802
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-12 19:52:09 +00:00
Matthew Dempsky
e07a4459a1 cmd: replace x[i:][0] expressions with x[i]
Passes toolstash -cmp.

Change-Id: Id504e71ed1f23900e24a9aed25143c94f4d7d50c
Reviewed-on: https://go-review.googlesource.com/21899
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-12 19:35:10 +00:00
Robert Griesemer
b1851a3c11 cmd/compile: move compiler-specific flags into compiler-spec. export data section
Also: Adjust go/importer accordingly.

Change-Id: Ia6669563793e218946af45b9fba1cf986a21c031
Reviewed-on: https://go-review.googlesource.com/21896
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-04-12 18:57:51 +00:00
Michael Munday
be7c786dd0 cmd/objdump: skip TestDisasm* on s390x
The disassembler is not yet implemented on s390x.

Updates #15255.

Change-Id: Ibab319c8c087b1a619baa1529398305c1e721877
Reviewed-on: https://go-review.googlesource.com/21894
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-12 18:10:47 +00:00
Michael Munday
613ba6cda8 cmd/compile/internal/gc: add s390x support
Allows instructions with a From3 field to be used in regopt so
long as From3 represents a constant. This is needed because the
storage-to-storage instructions on s390x place the length of the
data into From3.

Change-Id: I12cd32d4f997baf2fe97937bb7d45bbf716dfcb5
Reviewed-on: https://go-review.googlesource.com/20875
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2016-04-12 18:04:02 +00:00
Josh Bleecher Snyder
811ebb6ac9 cmd/compile: temporarily disable inplace append special case
Fixes #15246
Re-opens #14969

Change-Id: Ic0b41c5aa42bbb229a0d62b7f3e5888c6b29293d
Reviewed-on: https://go-review.googlesource.com/21891
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-04-12 17:44:43 +00:00
Michael Munday
7f5a063d15 cmd/compile/internal/gc: minor Cgen_checknil cleanup
Most architectures can only generate nil checks when the
the address to check is in a register. Currently only
amd64 and 386 can generate checks for addresses that
reside in memory. This is unlikely to change so the architecture
check has been inverted.

Change-Id: I73697488a183406c79a9039c62823712b510bb6a
Reviewed-on: https://go-review.googlesource.com/21861
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-12 15:11:51 +00:00
Keith Randall
cd85f711c0 cmd/compile: add x.Uses==1 test to load combiners
We need to make sure that when we combine loads, we only do
so if there are no other uses of the load.  We can't split
one load into two because that can then lead to inconsistent
loaded values in the presence of races.

Add some aggressive copy removal code so that phantom
"dead copy" uses of values are cleaned up promptly.  This lets
us use x.Uses==1 conditions reliably.

Change-Id: I9037311db85665f3868dbeb3adb3de5c20728b38
Reviewed-on: https://go-review.googlesource.com/21853
Reviewed-by: Todd Neal <todd@tneal.org>
2016-04-12 15:10:16 +00:00
Dmitry Vyukov
204b6f48c5 cmd/pprof/internal: move to cmd/internal/pprof
Make internal pprof packages available to cmd/trace.
cmd/trace needs access to them to generate symbolized
svg profiles (create and serialize Profile struct).
And potentially generate svg programmatically instead
of invoking go tool pprof.

Change-Id: Iafd0c87ffdd4ddc081093be0b39761f19507907a
Reviewed-on: https://go-review.googlesource.com/21870
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-12 15:02:28 +00:00
Alexandru Moșoi
9743e4b031 cmd/compile: share dominator tree among many passes
These passes do not modify the dominator tree too much.

% benchstat old.txt new.txt
name       old time/op     new time/op     delta
Template       335ms ± 3%      325ms ± 8%    ~             (p=0.074 n=8+9)
GoTypes        1.05s ± 1%      1.05s ± 3%    ~            (p=0.095 n=9+10)
Compiler       5.37s ± 4%      5.29s ± 1%  -1.42%         (p=0.022 n=9+10)
MakeBash       34.9s ± 3%      34.4s ± 2%    ~            (p=0.095 n=9+10)

name       old alloc/op    new alloc/op    delta
Template      55.4MB ± 0%     54.9MB ± 0%  -0.81%        (p=0.000 n=10+10)
GoTypes        179MB ± 0%      178MB ± 0%  -0.89%        (p=0.000 n=10+10)
Compiler       807MB ± 0%      798MB ± 0%  -1.10%        (p=0.000 n=10+10)

name       old allocs/op   new allocs/op   delta
Template        498k ± 0%       496k ± 0%  -0.29%          (p=0.000 n=9+9)
GoTypes        1.42M ± 0%      1.41M ± 0%  -0.24%        (p=0.000 n=10+10)
Compiler       5.61M ± 0%      5.60M ± 0%  -0.12%        (p=0.000 n=10+10)

Change-Id: I4cd20cfba3f132ebf371e16046ab14d7e42799ec
Reviewed-on: https://go-review.googlesource.com/21806
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-04-12 14:44:26 +00:00
Michael Munday
a223ccae38 cmd/compile/internal/s390x: add s390x support
s390x does not require duffzero/duffcopy since it has
storage-to-storage instructions that can copy/clear up to 256
bytes at a time.

peep contains several new passes to optimize instruction
sequences that match s390x instructions such as the
compare-and-branch and load/store multiple instructions.

copyprop and subprop have been extended to work with moves that
require sign/zero extension. This work could be ported to other
architectures that do not used sized math however it does add
complexity and will probably be rendered unnecessary by ssa in
the near future.

Change-Id: I1b64b281b452ed82a85655a0df69cb224d2a6941
Reviewed-on: https://go-review.googlesource.com/20873
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bill O'Farrell <billotosyr@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-12 14:38:17 +00:00
Dmitri Shuralyov
b6cd6d7d32 cmd/go: fix vcsFromDir returning bad root on Windows
Apply golang/tools@5804fef4c0.

In the context of cmd/go build tool, import path is a '/'-separated path.
This can be inferred from `go help importpath` and `go help packages`.
vcsFromDir documentation says on return, root is the import path
corresponding to the root of the repository. On Windows and other
OSes where os.PathSeparator is not '/', that wasn't true since root
would contain characters other than '/', and therefore it wasn't a
valid import path corresponding to the root of the repository.
Fix that by using filepath.ToSlash.

Add test coverage for vcsFromDir, it was previously not tested.
It's taken from golang.org/x/tools/go/vcs tests, and modified to
improve style.

Additionally, remove an unneccessary statement from the documentation
"(thus root is a prefix of importPath)". There is no variable
importPath that is being referred to (it's possible p.ImportPath
was being referred to). Without it, the description of root value
matches the documentation of repoRoot.root struct field:

	// root is the import path corresponding to the root of the
	// repository
	root string

Rename and change signature of vcsForDir(p *Package) to
vcsFromDir(dir, srcRoot string). This is more in sync with the x/tools
version. It's also simpler, since vcsFromDir only needs those two
values from Package, and nothing more. Change "for" to "from" in name
because it's more consistent and clear.

Update usage of vcsFromDir to match the new signature, and respect
that returned root is a '/'-separated path rather than a os.PathSeparator
separated path.

Fixes #15040.
Updates #7723.
Helps #11490.

Change-Id: Idf51b9239f57248739daaa200aa1c6e633cb5f7f
Reviewed-on: https://go-review.googlesource.com/21345
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-12 06:25:45 +00:00
Martin Möhrmann
07669d2737 cmd/compile: cleanup pragcgo
Removes dynimport, dynexport, dynlinker cases since they can not
be reached due to prefix check for "go:cgo_" in getlinepragma.

Replaces the if chains for verb distinction by a switch statement.
Replaces fmt.Sprintf by fmt.Sprintln for string concatenation.

Removes the more, getimpsym and getquoted functions by introducing a
pragmaFields function that partitions a pragma into its components.

Adds tests for cgo pragmas.

Change-Id: I43c7b9550feb3ddccaff7fb02198a3f994444123
Reviewed-on: https://go-review.googlesource.com/21607
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-12 05:37:00 +00:00
Rob Pike
d1feddb7ae cmd/vet: improve documentation for flags, slightly
The way that -all works was unclear from the documentation and made
worse by recent changes to the flag package. Improve matters by making
the help message say "default true" for the tests that do default to true,
and tweak some of the wording.

Before:

Usage of vet:
	vet [flags] directory...
	vet [flags] files... # Must be a single package
For more information run
	go doc cmd/vet

Flags:
  -all
    	enable all non-experimental checks (default unset)
  -asmdecl
    	check assembly against Go declarations (default unset)
...

After:

Usage of vet:
	vet [flags] directory...
	vet [flags] files... # Must be a single package
By default, -all is set and all non-experimental checks are run.
For more information run
	go doc cmd/vet

Flags:
  -all
    	enable all non-experimental checks (default true)
  -asmdecl
    	check assembly against Go declarations (default true)
...

Change-Id: Ie94b27381a9ad2382a10a7542a93bce1d59fa8f5
Reviewed-on: https://go-review.googlesource.com/21495
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-11 22:35:22 +00:00
Josh Bleecher Snyder
a4650a2111 cmd/compile: avoid write barrier in append fast path
When we are writing the result of an append back
to the same slice, we don’t need a write barrier
on the fast path.

This re-implements an optimization that was present
in the old backend.

Updates #14921
Fixes #14969

Sample code:

var x []byte

func p() {
	x = append(x, 1, 2, 3)
}

Before:

"".p t=1 size=224 args=0x0 locals=0x48
	0x0000 00000 (append.go:21)	TEXT	"".p(SB), $72-0
	0x0000 00000 (append.go:21)	MOVQ	(TLS), CX
	0x0009 00009 (append.go:21)	CMPQ	SP, 16(CX)
	0x000d 00013 (append.go:21)	JLS	199
	0x0013 00019 (append.go:21)	SUBQ	$72, SP
	0x0017 00023 (append.go:21)	FUNCDATA	$0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0017 00023 (append.go:21)	FUNCDATA	$1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0017 00023 (append.go:19)	MOVQ	"".x+16(SB), CX
	0x001e 00030 (append.go:19)	MOVQ	"".x(SB), DX
	0x0025 00037 (append.go:19)	MOVQ	"".x+8(SB), BX
	0x002c 00044 (append.go:19)	MOVQ	BX, "".autotmp_0+64(SP)
	0x0031 00049 (append.go:22)	LEAQ	3(BX), BP
	0x0035 00053 (append.go:22)	CMPQ	BP, CX
	0x0038 00056 (append.go:22)	JGT	$0, 131
	0x003a 00058 (append.go:22)	MOVB	$1, (DX)(BX*1)
	0x003e 00062 (append.go:22)	MOVB	$2, 1(DX)(BX*1)
	0x0043 00067 (append.go:22)	MOVB	$3, 2(DX)(BX*1)
	0x0048 00072 (append.go:22)	MOVQ	BP, "".x+8(SB)
	0x004f 00079 (append.go:22)	MOVQ	CX, "".x+16(SB)
	0x0056 00086 (append.go:22)	MOVL	runtime.writeBarrier(SB), AX
	0x005c 00092 (append.go:22)	TESTB	AL, AL
	0x005e 00094 (append.go:22)	JNE	$0, 108
	0x0060 00096 (append.go:22)	MOVQ	DX, "".x(SB)
	0x0067 00103 (append.go:23)	ADDQ	$72, SP
	0x006b 00107 (append.go:23)	RET
	0x006c 00108 (append.go:22)	LEAQ	"".x(SB), CX
	0x0073 00115 (append.go:22)	MOVQ	CX, (SP)
	0x0077 00119 (append.go:22)	MOVQ	DX, 8(SP)
	0x007c 00124 (append.go:22)	PCDATA	$0, $0
	0x007c 00124 (append.go:22)	CALL	runtime.writebarrierptr(SB)
	0x0081 00129 (append.go:23)	JMP	103
	0x0083 00131 (append.go:22)	LEAQ	type.[]uint8(SB), AX
	0x008a 00138 (append.go:22)	MOVQ	AX, (SP)
	0x008e 00142 (append.go:22)	MOVQ	DX, 8(SP)
	0x0093 00147 (append.go:22)	MOVQ	BX, 16(SP)
	0x0098 00152 (append.go:22)	MOVQ	CX, 24(SP)
	0x009d 00157 (append.go:22)	MOVQ	BP, 32(SP)
	0x00a2 00162 (append.go:22)	PCDATA	$0, $0
	0x00a2 00162 (append.go:22)	CALL	runtime.growslice(SB)
	0x00a7 00167 (append.go:22)	MOVQ	40(SP), DX
	0x00ac 00172 (append.go:22)	MOVQ	48(SP), AX
	0x00b1 00177 (append.go:22)	MOVQ	56(SP), CX
	0x00b6 00182 (append.go:22)	ADDQ	$3, AX
	0x00ba 00186 (append.go:19)	MOVQ	"".autotmp_0+64(SP), BX
	0x00bf 00191 (append.go:22)	MOVQ	AX, BP
	0x00c2 00194 (append.go:22)	JMP	58
	0x00c7 00199 (append.go:22)	NOP
	0x00c7 00199 (append.go:21)	CALL	runtime.morestack_noctxt(SB)
	0x00cc 00204 (append.go:21)	JMP	0

After:

"".p t=1 size=208 args=0x0 locals=0x48
	0x0000 00000 (append.go:21)	TEXT	"".p(SB), $72-0
	0x0000 00000 (append.go:21)	MOVQ	(TLS), CX
	0x0009 00009 (append.go:21)	CMPQ	SP, 16(CX)
	0x000d 00013 (append.go:21)	JLS	191
	0x0013 00019 (append.go:21)	SUBQ	$72, SP
	0x0017 00023 (append.go:21)	FUNCDATA	$0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0017 00023 (append.go:21)	FUNCDATA	$1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0017 00023 (append.go:19)	MOVQ	"".x+16(SB), CX
	0x001e 00030 (append.go:19)	MOVQ	"".x+8(SB), DX
	0x0025 00037 (append.go:19)	MOVQ	DX, "".autotmp_0+64(SP)
	0x002a 00042 (append.go:19)	MOVQ	"".x(SB), BX
	0x0031 00049 (append.go:22)	LEAQ	3(DX), BP
	0x0035 00053 (append.go:22)	MOVQ	BP, "".x+8(SB)
	0x003c 00060 (append.go:22)	CMPQ	BP, CX
	0x003f 00063 (append.go:22)	JGT	$0, 84
	0x0041 00065 (append.go:22)	MOVB	$1, (BX)(DX*1)
	0x0045 00069 (append.go:22)	MOVB	$2, 1(BX)(DX*1)
	0x004a 00074 (append.go:22)	MOVB	$3, 2(BX)(DX*1)
	0x004f 00079 (append.go:23)	ADDQ	$72, SP
	0x0053 00083 (append.go:23)	RET
	0x0054 00084 (append.go:22)	LEAQ	type.[]uint8(SB), AX
	0x005b 00091 (append.go:22)	MOVQ	AX, (SP)
	0x005f 00095 (append.go:22)	MOVQ	BX, 8(SP)
	0x0064 00100 (append.go:22)	MOVQ	DX, 16(SP)
	0x0069 00105 (append.go:22)	MOVQ	CX, 24(SP)
	0x006e 00110 (append.go:22)	MOVQ	BP, 32(SP)
	0x0073 00115 (append.go:22)	PCDATA	$0, $0
	0x0073 00115 (append.go:22)	CALL	runtime.growslice(SB)
	0x0078 00120 (append.go:22)	MOVQ	40(SP), CX
	0x007d 00125 (append.go:22)	MOVQ	56(SP), AX
	0x0082 00130 (append.go:22)	MOVQ	AX, "".x+16(SB)
	0x0089 00137 (append.go:22)	MOVL	runtime.writeBarrier(SB), AX
	0x008f 00143 (append.go:22)	TESTB	AL, AL
	0x0091 00145 (append.go:22)	JNE	$0, 168
	0x0093 00147 (append.go:22)	MOVQ	CX, "".x(SB)
	0x009a 00154 (append.go:22)	MOVQ	"".x(SB), BX
	0x00a1 00161 (append.go:19)	MOVQ	"".autotmp_0+64(SP), DX
	0x00a6 00166 (append.go:22)	JMP	65
	0x00a8 00168 (append.go:22)	LEAQ	"".x(SB), DX
	0x00af 00175 (append.go:22)	MOVQ	DX, (SP)
	0x00b3 00179 (append.go:22)	MOVQ	CX, 8(SP)
	0x00b8 00184 (append.go:22)	PCDATA	$0, $0
	0x00b8 00184 (append.go:22)	CALL	runtime.writebarrierptr(SB)
	0x00bd 00189 (append.go:22)	JMP	154
	0x00bf 00191 (append.go:22)	NOP
	0x00bf 00191 (append.go:21)	CALL	runtime.morestack_noctxt(SB)
	0x00c4 00196 (append.go:21)	JMP	0

Change-Id: I77a41ad3a22557a4bb4654de7d6d24a029efe34a
Reviewed-on: https://go-review.googlesource.com/21813
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-04-11 21:38:18 +00:00
David Chase
32efa16c3d cmd/compile: added stats printing to stackalloc
This is controlled by the "regalloc" stats flag, since regalloc
calls stackalloc.  The plan is for this to allow comparison
of cheaper stack allocation algorithms with what we have now.

Change-Id: Ibf64a780344c69babfcbb328fd6d053ea2e02cfc
Reviewed-on: https://go-review.googlesource.com/21393
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-04-11 21:22:54 +00:00
Keith Randall
7e40627a0e cmd/compile: zero all three argstorage slots
These changes were missed when going from 2 to 3 argstorage slots.
https://go-review.googlesource.com/20296/

Change-Id: I930a307bb0b695bf1ae088030c9bbb6d14ca31d2
Reviewed-on: https://go-review.googlesource.com/21841
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-04-11 20:49:22 +00:00
Keith Randall
7f53391f6b cmd/compile: fix -N build
The decomposer of builtin types is confused by having structs
still around from the user-type decomposer.  They're all dead though,
so just enabling a deadcode pass fixes things.

Change-Id: I2df6bc7e829be03eabfd24c8dda1bff96f3d7091
Reviewed-on: https://go-review.googlesource.com/21839
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-04-11 19:43:47 +00:00
Michael Munday
cd6b2b7451 cmd/internal/obj/s390x: add MULHD instruction
Emulate 64-bit signed high multiplication ((a*b)>>64). To do this
we use the 64-bit unsigned high multiplication method and then
fix the result as shown in Hacker's Delight 2nd ed., chapter 8-3.

Required to enable some division optimizations.

Change-Id: I9194f428e09d3d029cb1afb4715cd5424b5d922e
Reviewed-on: https://go-review.googlesource.com/21774
Reviewed-by: Bill O'Farrell <billotosyr@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-11 18:53:36 +00:00
Shawn Walker-Salas
e79fef8e55 cmd/link: external linking can fail on Solaris 11.2+
Workaround external linking issues encountered on Solaris 11.2+ due to
the go.o object file being created with a NULL STT_FILE symtab entry by
using a placeholder name.

Fixes #14957

Change-Id: I89c501b4c548469f3c878151947d35588057982b
Reviewed-on: https://go-review.googlesource.com/21636
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-04-11 18:03:02 +00:00