1
0
mirror of https://github.com/golang/go synced 2024-10-05 05:11:25 -06:00
Commit Graph

7705 Commits

Author SHA1 Message Date
Matthew Dempsky
1e4e09612c cmd/compile: remove parser lineno hack for issue #13267
After golang.org/cl/19652 removed the bizarre lexlineno{++,--}
statements for parsing canned imports, this hack for #13267 is no
longer necessary:

    $ echo -n 0 > /tmp/0.go
    $ go tool compile /tmp/0.go
    /tmp/0.go:1: syntax error: package statement must be first

Apparently setting lexlineno to 2 while parsing the canned imports
caused prevlineno and lineno to also be set to 2.  After we finished
parsing imports and restored lexlineno to 1, since "package" is the
first token in a source file, we'll have fixed lineno = 1, but
prevlineno was still set to 2.

Change-Id: Ibcc49fe3402264819b9abb53505631f7a0ad4a36
Reviewed-on: https://go-review.googlesource.com/19859
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-24 00:19:46 +00:00
Keith Randall
e360f7c4db cmd/compile: keep JMPs around with -N
When -N, make sure we don't drop every instruction from
a block, even ones which would otherwise be empty.
Helps keep line numbers around for debugging, particularly
for break and continue statements (which often compile
down to nothing).

Fixes #14379

Change-Id: I33722c4f0dcd502f146fa48af262ba3a477c959a
Reviewed-on: https://go-review.googlesource.com/19854
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2016-02-24 00:16:23 +00:00
Keith Randall
80bc512449 [dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Semi-regular merge from tip to dev.ssa.

Change-Id: If7d2269f267bcbc0ecd3a483d349951044470e3f
2016-02-23 14:42:20 -08:00
Robert Griesemer
d1cc7f70cd cmd/compile: give informative error instead of "stupid shift"
Fixes #13940.

Change-Id: I00fe377c949e5be4cbc035f6ca18e547e326bfba
Reviewed-on: https://go-review.googlesource.com/19856
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-23 22:31:35 +00:00
Matthew Dempsky
9877900c8c Revert "cmd/compile: move hiter, hmap, and scase definitions into builtin.go"
This reverts commit f28bbb776a.

Change-Id: I82fb81dcff3ddcaefef72949f1ef3a41bcd22301
Reviewed-on: https://go-review.googlesource.com/19849
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-23 19:42:52 +00:00
Alexandru Moșoi
40f2b57e0b [dev.ssa] cmd/compile/internal/ssa: eliminate phis during deadcode removal
While investigating the differences between 19710 (remove
tautological controls) and 12960 (bounds and nil propagation)
I observed that part of the wins of 19710 come from missed
opportunities for deadcode elimination due to phis.
See for example runtime.stackcacherelease. 19710 happens much
later than 12960 and has more chances to eliminate bounds.

Size of pkg/tool/linux_amd64/* excluding compile:

-this -12960 95882248
+this -12960 95880120
-this +12960 95581512
+this +12960 95555224

This change saves about 25k.

Change-Id: Id2f4e55fc92b71595842ce493c3ed527d424fe0e
Reviewed-on: https://go-review.googlesource.com/19728
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-23 18:52:15 +00:00
David Crawshaw
735e5a483c cmd/compile: stop aligning string data
Makes godoc 10KB smaller.
For #6853.

Change-Id: Id54bd8c82cb2a1ba11d2d724e3107f73024b19d9
Reviewed-on: https://go-review.googlesource.com/19696
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-23 17:15:39 +00:00
Shawn Smith
58ec5839cd all: fix typos
Change-Id: I6035941df8b0de6aeaf6c05df7257bcf6e9191fe
Reviewed-on: https://go-review.googlesource.com/19320
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-23 13:58:47 +00:00
Matthew Dempsky
3ec0651539 cmd/compile: add copyright notice to util.go
util.go was originally added in golang.org/cl/4851, and later moved to
its current location in golang.org/cl/10287.

Change-Id: I10b4941d42ae1ff2e78990c497c1347bbbae4e3d
Reviewed-on: https://go-review.googlesource.com/19851
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-23 10:49:47 +00:00
Matthew Dempsky
e34295e647 cmd/compile: use path.Join in importfile
Change-Id: Ib413b0cb16405965455d7764a8c4a22bf431389b
Reviewed-on: https://go-review.googlesource.com/19850
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-23 10:49:39 +00:00
Todd Neal
c17b6b488c [dev.ssa] cmd/compile: truncate auxint when constructing Prog
The upper bits of 8/16/32 bit constants are undefined.  We need to
truncate in order to prevent x86.oclass misidentifying the size of the
constant.

Fixes #14389

Change-Id: I3e5ff79cd904376572a93f489ba7e152a5cb6e60
Reviewed-on: https://go-review.googlesource.com/19740
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-23 03:52:08 +00:00
Robert Griesemer
e7524d51fd cmd/compile: move Io state into lexer and remove Io type
Pass lexer around so state is accessible and dependency is explicit.
In the process remove EOF -> '\n' conversion that has to be corrected
for when reporting errors.

Change-Id: If95564b70e7484dedc1f5348e585cd19acbc1243
Reviewed-on: https://go-review.googlesource.com/19819
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-02-23 03:42:38 +00:00
Todd Neal
9dc1334cc7 [dev.ssa] cmd/compile : replace load of store with a copy
Loads of stores from the same pointer with compatible types
can be replaced with a copy.

Change-Id: I514b3ed8e5b6a9c432946880eac67a51b1607932
Reviewed-on: https://go-review.googlesource.com/19743
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-23 01:18:31 +00:00
Rob Pike
108218453a cmd/doc: handle embedded fields properly
The structure of the code meant that an embedded field was never
checked for export status. We need to check the name of the type,
which is either of type T or type *T, and T might be unexported.

Fixes #14356.

Change-Id: I56f468e9b8ae67e9ed7509ed0b91d860507baed2
Reviewed-on: https://go-review.googlesource.com/19701
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-22 23:40:02 +00:00
Josh Bleecher Snyder
36694064e5 cmd/compile: disable checknils during alg eq generation
Cuts 20k off cmd/go and 32k off golang.org/x/tools/cmd/godoc, approx 0.15% each.

For #6853 and #9930

Change-Id: Ic510b76b80a9153b1ede7b3533d2dbc16caa5c63
Reviewed-on: https://go-review.googlesource.com/19768
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-22 21:10:55 +00:00
Caio Marcelo de Oliveira Filho
e7f6d8b2d7 cmd/cover: don't overskip children nodes when adding counters
When visiting the AST to add counters, there are special cases in which
the code calls cuts the walking short by returning nil. In some cases
certain nodes are ignored, e.g. Init and Cond inside IfStmt.

The fix is to explicitly walk all the children nodes (not only
Body and Else) when cutting the current walk. Similar approach
was taken with SwitchStmt and TypeSwitchStmt.

While the existing test code doesn't handle different counters in the
same line, the generated HTML report does it correctly (because it takes
column into account).

The previous behavior caused lines in function literals to not be
tracked when those literals were inside Init or Cond of an IfStmt for
example.

Fixes #14039.

Change-Id: Iad591363330843ad833bd79a0388d709c8d0c8aa
Reviewed-on: https://go-review.googlesource.com/19775
Reviewed-by: Rob Pike <r@golang.org>
2016-02-22 21:06:57 +00:00
Robert Griesemer
f39cca94af cmd/compile: bring vendored copy of math/big up-to-date
These files were not added to the repo. They contain conversion
routines and corresponding tests not used by the compiler and
thus are technically not needed.

However, future changes to math/big (and corresponding updates
of this vendored version) may require these files to exist.
Add them to avoid unnecessary confusion.

Change-Id: Ie390fb54f499463b2bba2fdc084967539afbeeb3
Reviewed-on: https://go-review.googlesource.com/19730
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-22 20:50:00 +00:00
Josh Bleecher Snyder
028247d2cd cmd/compile: reuse []Flow
Benchmarked using compilebench on a quiet
but rather old OS X laptop.

Benchmarks from others would be welcome,
since the numbers look too good to be true.

name      old time/op    new time/op    delta
Template     331ms ± 9%     303ms ± 4%   -8.25%  (p=0.000 n=24+24)
GoTypes      946ms ± 4%     888ms ± 3%   -6.17%  (p=0.000 n=24+25)
Compiler     3.20s ± 1%     3.10s ± 2%   -3.07%  (p=0.000 n=24+25)

name      old alloc/op   new alloc/op   delta
Template    72.5MB ± 0%    61.8MB ± 0%  -14.76%  (p=0.000 n=25+24)
GoTypes      224MB ± 0%     189MB ± 0%  -15.65%  (p=0.000 n=25+25)
Compiler     695MB ± 0%     561MB ± 0%  -19.26%  (p=0.000 n=25+25)

name      old allocs/op  new allocs/op  delta
Template      498k ± 0%      497k ± 0%   -0.21%  (p=0.000 n=25+23)
GoTypes      1.47M ± 0%     1.47M ± 0%   -0.25%  (p=0.000 n=25+25)
Compiler     4.09M ± 0%     4.08M ± 0%   -0.18%  (p=0.000 n=25+23)

Change-Id: I2394bc748128d721863453257fa5756c410f7898
Reviewed-on: https://go-review.googlesource.com/19771
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-22 18:22:48 +00:00
David Chase
c3db6c95b6 [dev.ssa] cmd/compile: double speed of CSE phase
Replaced comparison based on (*Type).String() with an
allocation-free structural comparison.  Roughly doubles
speed of CSE, also reduces allocations.

Checked that roughly the same number of CSEs were detected
during make.bash (about a million) and that "new" CSEs
were caused by the effect described above.

Change-Id: Id205a9f6986efd518043e12d651f0b01206aeb1b
Reviewed-on: https://go-review.googlesource.com/19471
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-22 17:15:41 +00:00
Alexandru Moșoi
88c1ef5b45 [dev.ssa] cmd/compile/internal/ssa: handle commutative operations in cse
* If a operation is commutative order the parameters
in a canonical way.

Size of pkg/tool/linux_amd64/* excluding compile:
before: 95882288
 after: 95868152
change: 14136 ~0.015%

I tried something similar with Leq and Geq, but the results were
not great because it confuses the 'lowered cse' pass too much
which can no longer remove redundant comparisons from IsInBounds.

Change-Id: I2f928663a11320bfc51c7fa47e384b7411c420ba
Reviewed-on: https://go-review.googlesource.com/19727
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-22 16:52:05 +00:00
David Chase
b86cafc7dc [dev.ssa] cmd/compile: memory allocation tweaks to regalloc and dom
Spotted a minor source of excess allocation in the register
allocator.  Rearranged the dominator tree code to pull its
scratch memory from a reused buffer attached to Config.

Change-Id: I6da6e7b112f7d3eb1fd00c58faa8214cdea44e38
Reviewed-on: https://go-review.googlesource.com/19450
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-22 15:32:58 +00:00
Todd Neal
94f0245114 [dev.ssa] cmd/compile: add a zero arg cse pass
Add an initial cse pass that only operates on zero argument
values.  This removes the need for a special case in cse for removing
OpSB and speeds up arithConst_ssa.go compilation by 9% while slowing
"test -c net/http" by 1.5%.

Change-Id: Id1500482485426f66c6c2eba75eeaf4f19c8a889
Reviewed-on: https://go-review.googlesource.com/19454
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-22 13:06:18 +00:00
Matthew Dempsky
f28bbb776a cmd/compile: move hiter, hmap, and scase definitions into builtin.go
Also eliminates per-maptype hiter and hmap types, since they're not
really needed anyway.  Update packages reflect and runtime
accordingly.

Reduces golang.org/x/tools/cmd/godoc's text segment by ~170kB:

   text	   data	    bss	    dec	    hex	filename
13085702	 140640	 151520	13377862	 cc2146	godoc.before
12915382	 140640	 151520	13207542	 c987f6	godoc.after

Updates #6853.

Change-Id: I948b2bc1f22d477c1756204996b4e3e1fb568d81
Reviewed-on: https://go-review.googlesource.com/16610
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-22 07:42:37 +00:00
Keith Randall
d0c11577b9 cmd/compile: inline {i,e}facethash
These functions are really simple, the overhead of calling
them (in both time and code size) is larger than the inlined versions.

Reorganize how the nil case in a type switch is handled, as we have
to check for nil explicitly now anyway.

Saves about 0.8% in the binary size of the go tool.

Change-Id: I8501b62d72fde43650b79f52b5f699f1fbd0e7e7
Reviewed-on: https://go-review.googlesource.com/19814
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-02-22 05:09:25 +00:00
Todd Neal
4827c6d077 [dev.ssa] test: add test of pointer aliasing
This adds a test case with aliased pointers to ensure modifications to
dse don't remove valid stores.

Change-Id: I143653250f46a403835218ec685bcd336d5087ef
Reviewed-on: https://go-review.googlesource.com/19795
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-22 03:40:16 +00:00
Matthew Dempsky
5609a48931 cmd/compile: make cmpstackvarlt properly asymmetric
Previously, given two Nodes n1 and n2 of different non-PAUTO classes
(e.g., PPARAM and PPARAMOUT), cmpstackvarlt(n1, n2) and
cmpstackvarlt(n2, n1) both returned true, which is nonsense.

This doesn't seem to cause any visible miscompilation problems, but
notably fixing it does cause toolstash/buildall to fail.

Change-Id: I33b2c66e902c5eced875d8fbf18b7cfdc81e8aed
Reviewed-on: https://go-review.googlesource.com/19778
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-22 00:09:36 +00:00
Matthew Dempsky
89cfdda44d cmd/compile: replace Order's use of NodeLists with slices
Order's "temp" and "free" fields use NodeLists in a rather
non-idiomatic way.  Instead of using the "list" or "concat" functions,
it manipulates them directly and without the normal invariants (e.g.,
it doesn't maintain the "End" field).

Rather than convert it to more typical usage, just replace with a
slice, which ends up much simpler anyway.

Passes toolstash/buildall.

Change-Id: Ibd0f24324bd674c0d5bb1bc40d073b01e7824ad5
Reviewed-on: https://go-review.googlesource.com/19776
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-21 23:20:43 +00:00
Matthew Dempsky
8ffe496ae7 cmd/compile, runtime: eliminate unnecessary algorithm types
There's no need for 8 different ways to represent that a type is
non-comparable.

While here, move AMEM out of the runtime-known algorithm values since
it's not needed at run-time, and get rid of the unused AUNK constant.

Change-Id: Ie23972b692c6f27fc5f1a908561b3e26ef5a50e9
Reviewed-on: https://go-review.googlesource.com/19779
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-21 20:59:36 +00:00
Josh Bleecher Snyder
bc8458ab02 cmd/compile: use && in generated eq algs
This allows the compiler to generate better code
containing fewer jumps and only a single return value.

Cuts 12k off cmd/go and 16k off golang.org/x/tools/cmd/godoc, approx 0.1% each.

For #6853 and #9930

Change-Id: I009616df797760b01e09f06357a2d6fd6ebcf307
Reviewed-on: https://go-review.googlesource.com/19767
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-21 18:17:39 +00:00
Josh Bleecher Snyder
4cef0e980a cmd/compile: don't generate algs for [0]T and [1]T
All [0]T values are equal.
[1]T values are equal iff their sole components are.

This types show up most frequently as a by-product of variadic
function calls, such as fmt.Printf("abc") or fmt.Printf("%v", x).

Cuts 12k off cmd/go and 22k off golang.org/x/tools/cmd/godoc, approx 0.1% each.

For #6853 and #9930

Change-Id: Ic9b7aeb8cc945804246340f6f5e67bbf6008773e
Reviewed-on: https://go-review.googlesource.com/19766
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-21 18:13:55 +00:00
Josh Bleecher Snyder
e43c74a0d8 all: use cannot instead of can not
You can not use cannot, but you cannot spell cannot can not.

Change-Id: I2f0971481a460804de96fd8c9e46a9cc62a3fc5b
Reviewed-on: https://go-review.googlesource.com/19772
Reviewed-by: Rob Pike <r@golang.org>
2016-02-21 15:35:50 +00:00
Robert Griesemer
aa5b44aeab cmd/compile: set lexer nlsemi state directly
The old code used an extra function call and switch to inspect the
current token and determine the new state of curio.nlsemi. However,
the lexer knows the token w/o the need of an extra test and thus
can set curio.nlsemi directly:

- removed need for extra function call in next
- renamed _yylex to next
- set nlsemi at the point a token is identified
- moved nlsemi from curio to lexer - it's really part of the lexer state

This change makes the lexer call sequence less convoluted and should
also speed up the lexing a bit.

Change-Id: Iaf2683081f04231cb62c94e1400d455f98f6f82a
Reviewed-on: https://go-review.googlesource.com/19765
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-02-21 05:13:58 +00:00
Robert Griesemer
20ee67acc9 cmd/compile: test for lower-case letters first in isAlpha
Lower-case letters are more common in identifiers.

Change-Id: I49c39e3ac810eea57d15c1433608daec212c9792
Reviewed-on: https://go-review.googlesource.com/19760
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-02-21 05:12:38 +00:00
Robert Griesemer
11e51ed4bc cmd/compile: remove gratuituous copying of lexer token data
Rename yySymType to lexer; should eventually capture all lexer state.
Embed lexer in parser and access lexer token data directly.

Change-Id: I246194705d594f80426f3ba77d8580af9185daf7
Reviewed-on: https://go-review.googlesource.com/19759
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-02-21 05:12:14 +00:00
Matthew Dempsky
5621b09dad cmd/compile: simplify import path handling
Change-Id: I64c9b4c4978520a9bc989b7fd7d5708d364dc88a
Reviewed-on: https://go-review.googlesource.com/19755
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-21 05:05:08 +00:00
David Crawshaw
e6d6ad47f5 cmd/compile: update some type names in comments
Change-Id: I741a1205bc6256c08b36efed43652bfbb75e4401
Reviewed-on: https://go-review.googlesource.com/19691
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-20 20:16:27 +00:00
David Crawshaw
41eb5ca089 cmd/link: typo in error message
Change-Id: Ideeef320d6a01a10c89524b6d895a64210a60f64
Reviewed-on: https://go-review.googlesource.com/19693
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-20 20:16:17 +00:00
Matthew Dempsky
3a11c8d319 cmd/compile: simplify if statement parsing
Somewhat notably, this means long if statement chains are now parsed
recursively, rather than iteratively.  This shouldn't be a concern
though, as several other functions (e.g., gen, typecheck, walk)
already use recursion to process the parsed if statement Node trees.

Change-Id: Ic8c12ace9021c870d60c06f5db86a48c4ec57084
Reviewed-on: https://go-review.googlesource.com/19756
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-20 18:59:57 +00:00
Matthew Dempsky
3e40f13cf3 cmd/compile: eliminate global fileparser
Change-Id: I9b8b13731ccc2ba33d21642b12cc614dde0804b1
Reviewed-on: https://go-review.googlesource.com/19752
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2016-02-20 05:41:53 +00:00
Matthew Dempsky
338a891e79 cmd/compile: eliminate pushedio and savedstate
While here, get drop the lexlineno{++,--} hacks for canned imports.
They were added in commit d3237f9, but don't seem to serve any
purpose.

Change-Id: I00f9e6be0ae9f217f2fa113b85e041dfd0303757
Reviewed-on: https://go-review.googlesource.com/19652
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2016-02-20 05:14:32 +00:00
Matthew Dempsky
4e6e8e8c58 cmd/compile: change two pushedio.bin tests to use importpkg instead
pushedio.bin and importpkg are both non-nil iff we're parsing an
package's export data, so "pushedio.bin == nil" and "importpkg == nil"
are equivalent tests.

Change-Id: I571ee908fef867117ef72c5da1eb24fe9b3fd12d
Reviewed-on: https://go-review.googlesource.com/19751
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-20 04:40:29 +00:00
Matthew Dempsky
f8e41f6f59 cmd/compile: eliminate Io.infile and Io.cp
infile is never read and cp is never written.  Both are unneeded.

Change-Id: I0a90bb772a53a580ea4be8e5f0f770da7c1acf3a
Reviewed-on: https://go-review.googlesource.com/19651
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-20 04:39:09 +00:00
Matthew Dempsky
699a2ba137 cmd/compile: switch cannedimports to use a Biobuf
Allows eliminating the separate lexer code paths for reading from cp
in the next CL.

Change-Id: I49098ecef32b735c4a01374443c2f847235ff964
Reviewed-on: https://go-review.googlesource.com/19750
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-20 04:37:50 +00:00
Matthew Dempsky
7d3a40978a cmd/compile: refactor export data parsing
Merge push_parser and pop_parser into a single parse_import function
and inline unimportfile. Shake out function boundaries a little bit so
that the symmetry is readily visible.

Move the import_package call into parse_import (and inline
import_there into import_package).  This means importfile no longer
needs to provide fake import data to be needlessly lexed/parsed every
time it's called.

Also, instead of indicating import success/failure by whether the next
token is "package", import_spec can just check whether importpkg is
non-nil.

Tangentially, this somehow alters the diagnostics produced for
test/fixedbugs/issue11610.go.  However, the new diagnostics are more
consistent with those produced when the empty import statement is
absent, which seems more desirable than maintaining the previous
errors.

Change-Id: I5cd1c22aa14da8a743ef569ff084711d137279d5
Reviewed-on: https://go-review.googlesource.com/19650
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-20 04:31:42 +00:00
Ian Lance Taylor
0d5e6a3f07 cmd/api: fix benchmark to ignore internal packages
Change-Id: I8ee46287ae0744efa83ad343997ad6835520fa5c
Reviewed-on: https://go-review.googlesource.com/19688
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-20 01:58:38 +00:00
Matthew Dempsky
113c4d2581 cmd/compile: refactor import statement parsing
Combine parser's import_stmt and import_here methods as a single new
importdcl method, and cleanup conditional logic slightly to make the
code easier to follow.

Also, eliminate importfile's unused line parameter, and get rid of all
of its duplicate type assertions.

Change-Id: Ic37ae8490afedc533f98ead9feef383e3599bc01
Reviewed-on: https://go-review.googlesource.com/19629
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-19 22:54:15 +00:00
Alexandru Moșoi
5949524fc4 [dev.ssa] cmd/compile/internal/ssa: handle phis in fuse.
Change-Id: Idd880cc6c1e5dc34dddbdea0841a7a718d2fa836
Reviewed-on: https://go-review.googlesource.com/19544
Reviewed-by: David Chase <drchase@google.com>
2016-02-19 22:44:29 +00:00
Alexandru Moșoi
e4bee4be92 [dev.ssa] cmd/compile/internal/ssa: constant fold truncates and bool comparisons
Change-Id: I731722eb77f373ff7d6101f93830ab0a50497e2c
Reviewed-on: https://go-review.googlesource.com/19542
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-19 21:56:26 +00:00
Matthew Dempsky
d930d69fd9 cmd/compile: make -A and -newexport compatible
Packages compiled with -A may reference the builtin "any" type, so it
needs to be included in the list of predeclared types for binary
import/export.

Also, when -A is used, mark all symbols as SymExport instead of
SymPackage in importsym.  This parallels the logic in autoexport and
is necessary to prevent a "export/package mismatch" errors in
exportsym during dumpexport's verifyExport pass.

Change-Id: Iff5ec5fbfe2219525ec9d1a975307fa8936af9b9
Reviewed-on: https://go-review.googlesource.com/19627
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-19 21:42:04 +00:00
Matthew Dempsky
1402e522c6 cmd/compile: load builtin export data only once
Previously, the builtin runtime export data was reparsed before every
Go source file, and the unsafe export data was reparsed for every
import of package unsafe.  Now, we parse both of them just once ahead
of time.

This does mean package unsafe's export data will be loaded even when
compiling packages that don't import it, but it's tiny anyway.

Change-Id: Ic6931bc58f6d62f664348bfa932f92d4ccacc3ef
Reviewed-on: https://go-review.googlesource.com/19626
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-19 19:56:32 +00:00
David Chase
fb2af2b35b cmd/compile: don't walk field-name syntax in esc.go
Walking the field name as if it were an expression
caused a called to haspointers with a TFIELD, which panics.
Trigger was a field at a large offset within a large struct,
combined with a struct literal expression mentioning that
field.

Fixes #14405

Change-Id: I4589badae27cf3d7cf365f3a66c13447512f41f9
Reviewed-on: https://go-review.googlesource.com/19699
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-19 19:40:49 +00:00
Damien Neil
0e34737c9a cmd/go: don't assume cc supports -gno-record-gcc-switches
NetBSD's C compiler appears to support -fdebug-prefix-map but
not -gno-record-gcc-switches. Remove assumption that support
for the former implies the latter.

Change-Id: Iecad9e4f497ea4edc1ce440010e6fe19dc3e0566
Reviewed-on: https://go-review.googlesource.com/19686
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-19 19:12:56 +00:00
Matthew Dempsky
9a184b22ee cmd/compile: refresh builtin.go
The export data format was augmented with a new "unsafe-uintptr" tag
in https://golang.org/cl/18584, but builtin.go was not regenerated.

While here, add a test to make sure builtin.go stays up to date in the
future.

Change-Id: I4ae17da29f0855bef6ec0fcc10e7082c8427d39c
Reviewed-on: https://go-review.googlesource.com/19681
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-19 19:08:47 +00:00
Tal Shprecher
5c5e8d4105 cmd/compile: avoid leak of dottype expression if type does not contain pointers.
Fixes #13805

Change-Id: Ica9aae2e054b74f67d28ab27f72c52a3f03eeb59
Reviewed-on: https://go-review.googlesource.com/19489
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-19 16:10:14 +00:00
Mohit Agarwal
277024bd6f cmd/go: don't set GO15VENDOREXPERIMENT in TestSymlinksVendor
Change-Id: I14947b64bdafd975bf3915eceb07f98897304a85
Reviewed-on: https://go-review.googlesource.com/19708
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-19 15:54:12 +00:00
Russ Cox
9aa630faa8 cmd/dist: accept "//+build" with no spaces, like go/build
The go/build parser accepts "//+build", with no spaces.
Make the cmd/dist bootstrap parser do the same.
While in theory we should always use the space form,
I copied some code that did not into the standard tree,
and I was very confused that 'go test' had had no problem
but then make.bash died.

(As a reminder, cmd/dist does not use go/build because
cmd/dist must build against earlier versions of Go.)

Change-Id: I90a18014bd878247b8811487e5c1a7589260cbfc
Reviewed-on: https://go-review.googlesource.com/19618
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-19 01:37:51 +00:00
Russ Cox
fe5eac63c4 cmd/internal/obj: hoist fieldtrack code out of x86 back end
Change-Id: I38e59088c37426d914ce2b4dfc79f3d476e06f49
Reviewed-on: https://go-review.googlesource.com/19617
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-19 01:37:46 +00:00
Russ Cox
53ebde225e cmd/cgo: do not use gcc -xc - to compile standard input
We have private reports of compilers that mishandle that.
Write to a temporary file instead.

Change-Id: I92e3cf4274b1a8048741e07fb52b8900c93b915e
Reviewed-on: https://go-review.googlesource.com/19616
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-19 01:37:41 +00:00
Russ Cox
3e23442518 cmd/go: remove GO15VENDOREXPERIMENT variable
The Go 1.6 release notes say that Go 1.7 will remove support
for the GO15VENDOREXPERIMENT environment variable,
making vendoring always on. Do that.

Change-Id: Iba8b79532455828869c1a8076a82edce84259468
Reviewed-on: https://go-review.googlesource.com/19615
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-19 01:35:53 +00:00
Russ Cox
51b624e6a2 cmd/link: remove alternate -X flag spelling
The Go 1.6 release notes say we'll remove the “-X name value” form
(in favor of the “-X name=value” form) in Go 1.7.
Do that.

Also establish the doc/go1.7.txt file.

Change-Id: Ie4565a6bc5dbcf155181754d8d92bfbb23c75338
Reviewed-on: https://go-review.googlesource.com/19614
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-19 01:35:25 +00:00
Russ Cox
0b4f578266 cmd/asm: remove nonexistent amd64 instructions
These have no accepted input syntax and,
as far as I can tell, do not actually exist.

Change-Id: Iafdfb71adccad76230191d922eb7ddf78b7d5898
Reviewed-on: https://go-review.googlesource.com/19612
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-19 01:35:18 +00:00
Russ Cox
76f272d717 cmd/asm: remove support for amd64 3DNow! instructions
3DNotAnymore!

These only ever existed on AMD (not Intel) processors,
and AMD cancelled support for them in August 2010.

Change-Id: Ia362259add9d4f5788fd151fb373f91288677407
Reviewed-on: https://go-review.googlesource.com/19611
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-19 01:35:13 +00:00
Nathan VanBenschoten
b04f3b06ec all: replace strings.Index with strings.Contains where possible
Change-Id: Ia613f1c37bfce800ece0533a5326fca91d99a66a
Reviewed-on: https://go-review.googlesource.com/18120
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
2016-02-19 01:06:05 +00:00
Benoit Sigoure
3ddfaa5653 cmd/gofmt: Ignore file not found errors.
gofmt prints an error to stderr when a file is deleted during its
`filepath.Walk()', which can happen in builds that change the tree
concurrently with gofmt running.

Change-Id: Ia1aa4804f6bc2172baf061c093e16fe56a3ee50c
Reviewed-on: https://go-review.googlesource.com/19301
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-19 00:13:18 +00:00
David Chase
ae276d8c23 [dev.ssa] cmd/compile: reenable TestStackBarrierProfiling
Tested it 1000x on OS X and Linux amd64, no failures.
Updated TODO.

Change-Id: Ia60c8d90962f6e5f7c3ed1ded6ba1b25eee983e1
Reviewed-on: https://go-review.googlesource.com/19662
Reviewed-by: Todd Neal <todd@tneal.org>
2016-02-18 23:21:14 +00:00
Rhys Hiltner
98cc8b4cf2 cmd/link/internal/ld: remove unused call to os.Getwd
This call to os.Getwd (or getwd) has been part of the linker since the C
implementation in 7d507dc6e6. It stopped being used in 26438d4d80, and
survived the conversion to Go in 1f9dbb60ef.

Its return value goes unused (the linker gets the value for AT_comp_dir in
dwarf.go), remove it.

Change-Id: I3d4594813bb4ee0a6af31a36e19d99ec4b863677
Reviewed-on: https://go-review.googlesource.com/19655
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-18 22:34:29 +00:00
Matthew Dempsky
7555f7f2bf cmd/compile: cleanup mkbuiltin.go
Changes largely in preparation for eventually switching the builtin
export data to use the new binary format.

Replace fancy incremental line-by-line scanning with simply reading
the entire object file into memory, finding the export data section,
and processing it that way.

Just use "package runtime" and "package unsafe" in the builtin Go
source files so we don't need to rewrite references to "PACKAGE".

Stop looking for init_PACKAGE_function; it doesn't exist anyway.

Compile package runtime with -u so that its export data marks it as a
"safe" package.

Eliminate requirement to pass "runtime" and "unsafe" as command-line
arguments so that just "go run mkbuiltin.go" works.

Only rewrite builtin.go when successful.

Change-Id: I4addfde9e0cfb30607c7a83de686bde0ad1f035a
Reviewed-on: https://go-review.googlesource.com/19624
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-18 21:41:51 +00:00
Matthew Dempsky
7d80291c4c cmd/compile: eliminate Io.importsafe
It was only really necessary for ensuring that package runtime should
be treated as safe even without a "safe" marker, but mkbuiltin.go now
compiles it with -u.

Change-Id: Ifbcc62436ce40ab732ece667141afd82c1d3b64b
Reviewed-on: https://go-review.googlesource.com/19625
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-18 21:28:57 +00:00
Damien Neil
5bbb98df09 cmd/go, cmd/link: make builds deterministic
Add the following flags when supported by the compiler:
  -gno-record-gcc-switches
  -fdebug-prefix-map=$WORK=/tmp/go-build

Add an empty NAME symbol to the ELF .symtab. GNU ld will add a NAME
symbol when one is not present; including one of our own prevents it
from adding a reference to the link tempdir.

Fixes #13247 for compilers that support -fdebug-prefix-map. (gcc, clang
in the near future.)

Change-Id: I221c71fc59cd23ee8c99bcc038793ff4623c9ffc
Reviewed-on: https://go-review.googlesource.com/19363
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
2016-02-18 20:56:29 +00:00
Matthew Dempsky
1a94431a78 cmd/cgo: support multiple-value special form in VarDecl
Fixes #13930.

Change-Id: I124b7d31d1f2be05b7f23dafd1e52d9f3f02f3f0
Reviewed-on: https://go-review.googlesource.com/18623
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-18 20:12:20 +00:00
Alexandru Moșoi
bc1fb32e9d [dev.ssa] cmd/compile/internal/ssa: fix the type of constant shift folding.
Also throw in a few more shift constant folding.

Change-Id: Iabe00596987f594e0686fbac3d76376d94612340
Reviewed-on: https://go-review.googlesource.com/19543
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-17 16:31:44 +00:00
Alexandru Moșoi
c67cac0703 [dev.ssa] cmd/compile/internal/ssa: transform degenerate control blocks
* In cases where we end up with empty branches like in
if a then jmp b else jmp b;
the flow can be replaced by a; jmp b.

The following functions is optimized as follows:
func f(a bool, x int) int {
        v := 0
        if a {
                v = -1
        } else {
                v = -1
        }
        return x | v
}

Before this change:
02819 (arith_ssa.go:362)  VARDEF "".~r2+16(FP)
02820 (arith_ssa.go:362)  MOVQ  $0, "".~r2+16(FP)
02821 (arith_ssa.go:362)  MOVB  "".a(FP), AX
02822 (arith_ssa.go:362)  TESTB AX, AX
02823 (arith_ssa.go:364)  JEQ 2824
02824 (arith_ssa.go:369)  VARDEF "".~r2+16(FP)
02825 (arith_ssa.go:369)  MOVQ  $-1, "".~r2+16(FP)
02826 (arith_ssa.go:369)  RET

After this change:
02819 (arith_ssa.go:362)  VARDEF "".~r2+16(FP)
02820 (arith_ssa.go:369)  VARDEF "".~r2+16(FP)
02821 (arith_ssa.go:369)  MOVQ  $-1, "".~r2+16(FP)
02822 (arith_ssa.go:369)  RET

Updates #14277

Change-Id: Ibe7d284f43406c704903632a4fcf2a4a64059686
Reviewed-on: https://go-review.googlesource.com/19464
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-17 10:43:48 +00:00
Ian Lance Taylor
aa22c42d70 cmd/go: avoid race on test environment
Fixes #14337.

Change-Id: I58aef7e08d936b0712da577dd1ce5c9ed5d8bfd2
Reviewed-on: https://go-review.googlesource.com/19513
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-16 22:02:56 +00:00
Alexandru Moșoi
65855cf640 [dev.ssa] cmd/compile/internal/ssa: factor out copyelimValue and phielimValue
* Merge copyelim into phielim.
* Add phielimValue to rewrite. cgoIsGoPointer is, for example, 2
instructions smaller now.

Change-Id: I8baeb206d1b3ef8aba4a6e3bcdc432959bcae2d5
Reviewed-on: https://go-review.googlesource.com/19462
Reviewed-by: David Chase <drchase@google.com>
2016-02-16 21:02:56 +00:00
Russ Cox
feb2a5d610 cmd/compile: print struct tags in var decl in inlined func body
This bug was introduced in golang.org/cl/18217,
while trying to fix #13777.

Originally I wanted to just disable inlining for the case
being handled incorrectly, but it's fairly difficult to detect
and much easier just to fix. Since the case being handled
incorrectly was inlined correctly in Go 1.5, not inlining it
would also be somewhat of a regression.
So just fix it.

Test case copied from Ian's CL 19520.

The mistake to worry about in this CL would be relaxing
the condition too much (we now print the note more often
than we did yesterday). To confirm that we'd catch this mistake,
I checked that changing (!fmtbody || !t.Funarg) to (true) does
cause fixedbugs/issue13777.go to fail. And putting it back
to what is written in this CL makes that test pass again
as well as the new fixedbugs/issue14331.go.
So I believe that the new condition is correct for both constraints.

Fixes #14331.

Change-Id: I91f75a4d5d07c53af5caea1855c780d9874b8df6
Reviewed-on: https://go-review.googlesource.com/19514
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-16 19:39:10 +00:00
Todd Neal
adc8d491c2 [dev.ssa] cmd/compiler: rewrite AND x const as a shift if possible
ANDs of constants whose only set bits are leading or trailing can be
rewritten as two shifts instead.  This is slightly faster for 32 or
64 bit operands.

Change-Id: Id5c1ff27e5a4df22fac67b03b9bddb944871145d
Reviewed-on: https://go-review.googlesource.com/19485
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-16 16:53:16 +00:00
Keith Randall
e3033fc535 cmd/compile: add write barrier to type switch
Type switches need write barriers if the written-to
variable is heap allocated.

For the added needwritebarrier call, the right arg doesn't
really matter, I just pass something that will never disqualify
the write barrier.  The left arg is the one that matters.

Fixes #14306

Change-Id: Ic2754167cce062064ea2eeac2944ea4f77cc9c3b
Reviewed-on: https://go-review.googlesource.com/19481
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-12 21:07:21 +00:00
Ryan Brown
68aa7fb636 cmd/link: fix padding for dwarf aranges on 32 bit platforms.
Fixes #14278

Change-Id: I6a0c1370d595f0573ff0eb933450b1eea41f4bb3
Reviewed-on: https://go-review.googlesource.com/19452
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-12 19:13:11 +00:00
Todd Neal
e49c910900 [dev.ssa] cmd/compile: print aux value also
When printing a value with just an aux, print the aux as well. Debugging
cse is easier when the aux values are visible.

Change-Id: Ifaf96bdb25462c9df7ba01fdfdbf0d379631f555
Reviewed-on: https://go-review.googlesource.com/19476
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-12 00:44:36 +00:00
Gerrit Code Review
d509788d97 Merge "[dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch" into dev.ssa 2016-02-11 21:32:48 +00:00
Keith Randall
6d40c62732 [dev.ssa] cmd/compile: remove redundant compare ops
Flagalloc was recalculating flags is some situations
when it didn't need to.  Fixed by using the same name
for the original flag calculation instruction throughout.

Change-Id: Ic0bf58f728a8d87748434dd25a67b0708755e1f8
Reviewed-on: https://go-review.googlesource.com/19237
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-11 21:01:17 +00:00
Keith Randall
eb0cff9a76 [dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Semi-regular merge from tip to dev.ssa.

Two fixes:
1) Mark selectgo as not returning.  This caused problems
   because there are no VARKILL ops on the selectgo path,
   causing things to be marked live that shouldn't be.
2) Tell the amd64 assembler that addressing modes like
   name(SP)(AX*4) are ok.

Change-Id: I9ca81c76391b1a65cc47edc8610c70ff1a621913
2016-02-10 09:31:41 -08:00
Alexandru Moșoi
fd458ba499 [dev.ssa] cmd/compile/internal/ssa: more simplifications and normalization
Found by inspecting random generated code.

Change-Id: I57d0fed7c3a8dc91fd13cdccb4819101f9976ec9
Reviewed-on: https://go-review.googlesource.com/19413
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-09 22:14:02 +00:00
Alexandru Moșoi
d0d04d2d6c [dev.ssa] cmd/compile/internal/ssa: handle rewrite of Phis.
* Phis can have variable number of arguments, but rulegen assumed that
each operation has fixed number of arguments.
* Rewriting Phis is necessary to handle the following case:

func f1_ssa(a bool, x int) int {
        v := 0
        if a {
                v = -1
        } else {
                v = -1
        }
        return x|v
}

Change-Id: Iff6bd411b854f3d1d6d3ce21934bf566757094f2
Reviewed-on: https://go-review.googlesource.com/19412
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-09 20:46:16 +00:00
Russ Cox
ee451770a7 cmd/go: use GOPATH order for compile -I and link -L options
Given GOPATH=p1:p2 and source code of just the right form,
the go command could previously end up invoking the compiler
with -I p2 -I p1 or the linker with -L p2 -L p1, so that
compiled packages in p2 incorrectly shadowed packages in p1.
If foo were in both p1 and p2 and the compilation of bar
were such that the -I and -L options were inverted in this way,
then

	GOPATH=p2 go install foo
	GOPATH=p1:p2 go install bar

would get the p2 copy of foo instead of the (expected) p1 copy of foo.

This manifested in real usage in a few different ways, but in all
the root cause was that the -I or -L option sequence did not
match GOPATH.

Make it match GOPATH.

Fixes #14176 (second report).
Fixes #14192.
Related but less common issue #14271 not fixed.

Change-Id: I9c0f69042bb2bf92c9fc370535da2c60a1187d30
Reviewed-on: https://go-review.googlesource.com/19385
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2016-02-09 20:36:10 +00:00
Russ Cox
558a213d55 build: mv cmd/vendor cmd/internal/unvendor
And update two imports in cmd/internal/objfile/disasm.go.
This makes GO15VENDOREXPERIMENT=0 ./make.bash work.
For Go 1.7 we will move it back.

Fixes #14236.

Change-Id: I429c9af4baff8496f83d113b1b03b90e309f4f48
Reviewed-on: https://go-review.googlesource.com/19384
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-09 20:36:08 +00:00
Russ Cox
97572d5552 cmd/go: silence standard imports non-standard error for non-existent import target
This error only affects the compilation of the standard library,
but I discovered that if you import "notexist" from the standard
library then you get both an error about notexist not existing
and an error about notexist being a non-standard package
(because the non-existant package is in fact not a standard package).
Silence the second error.

Change-Id: Ib4c1523e89844260fde90de3459ec1e752df8f25
Reviewed-on: https://go-review.googlesource.com/19383
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-09 20:36:06 +00:00
Keith Randall
7f7f7cddec [dev.ssa] cmd/compile: split decompose pass in two
A first pass to decompose user types (structs, maybe
arrays someday), and a second pass to decompose builtin
types (strings, interfaces, slices, complex).  David wants
this for value range analysis so he can have structs decomposed
but slices and friends will still be intact and he can deduce
things like the length of a slice is >= 0.

Change-Id: Ia2300d07663329b51ed6270cfed21d31980daa7c
Reviewed-on: https://go-review.googlesource.com/19340
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
2016-02-09 02:18:31 +00:00
Todd Neal
9763f6f8cf [dev.ssa] cmd/compile: add test to detect cse bug
Adds a test to detect the bug that slipped in earlier when partioning
by the Aux value, but not sorting by it.

Change-Id: I56d0ba76383bbc1514b3dabd295e369771c26645
Reviewed-on: https://go-review.googlesource.com/19382
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-09 02:06:25 +00:00
Ilya Tocar
e93410d3e5 [dev.ssa] cmd/compile: use INC/DEC instead of add when we can
INC/DEC produces slightly faster and smaller code.

Change-Id: I329d9bdb01b90041be45e053d9df640818bf0c2d
Reviewed-on: https://go-review.googlesource.com/19238
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-08 22:02:58 +00:00
Alexandru Moșoi
964dda9bf1 [dev.ssa] cmd/compile/internal/ssa/gen: constant fold Neg*.
Change-Id: Id51e5c97e9653b764b809bf3424f1a6d31b6ffea
Reviewed-on: https://go-review.googlesource.com/19338
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
2016-02-08 22:01:13 +00:00
David Chase
58cfa40419 [dev.ssa] cmd/compile: fix for bug in cse speed improvements
Problem was caused by use of Args[].Aux differences
in early partitioning.  This artificially separated
two equivalent expressions because sort ignores the
Aux field, hence things can end with equal things
separated by unequal things and thus the equal things
are split into more than one partition.  For example:
SliceLen(a), SliceLen(b), SliceLen(a).

Fix: don't use Args[].Aux in initial partitioning.

Left in a debugging flag and some debugging Fprintf's;
not sure if that is house style or not.  We'll probably
want to be more systematic in our naming conventions,
e.g. ssa.cse, ssa.scc, etc.

Change-Id: Ib1412539cc30d91ea542c0ac7b2f9b504108ca7f
Reviewed-on: https://go-review.googlesource.com/19316
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-08 18:44:03 +00:00
Todd Neal
bc07922843 [dev.ssa] cmd/compile: speed up cse
Examine both Aux and AuxInt to form more precise initial partitions.
Restructure loop to avoid repeated type.Equal() call.  Speeds up
compilation of testdata/gen/arithConst_ssa by 25%.

Change-Id: I3cfb1d254adf0601ee69239e1885b0cf2a23575b
Reviewed-on: https://go-review.googlesource.com/19313
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-08 02:43:19 +00:00
Keith Randall
faf1bdb42b [dev.ssa] cmd/compile: panic doesn't return
Panic doesn't return, so record that we immediately exit after a panic
call.  This will help code analysis.

Change-Id: I4d1f67494f97b6aee130c43ff4e44307b2b0f149
Reviewed-on: https://go-review.googlesource.com/19303
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-07 13:25:33 +00:00
Keith Randall
a3055af45e [dev.ssa] cmd/compile: strength-reduce 64-bit constant divides
The frontend does this for 32 bits and below, but SSA needs
to do it for 64 bits.  The algorithms are all copied from
cgen.go:cgen_div.

Speeds up TimeFormat substantially: ~40% slower to ~10% slower.

Change-Id: I023ea2eb6040df98ccd9105e15ca6ea695610a7a
Reviewed-on: https://go-review.googlesource.com/19302
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-02-06 16:52:57 +00:00
Keith Randall
aebf6611df [dev.ssa] cmd/compile: reorg write barriers a bit
Use just a single write barrier flag test, even if there
are multiple pointer fields in a struct.

This helps move more of the wb-specific code (like the LEA
needed to materialize the write address) into the unlikely path.

Change-Id: Ic7a67145904369c4ff031e464d51267d71281c8f
Reviewed-on: https://go-review.googlesource.com/19085
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-05 16:38:45 +00:00
Keith Randall
a6fb514bf8 [dev.ssa] cmd/compile: add store constant indexed operations
Change-Id: Ifb8eba1929c79ee7a8cae2191613c55a3b8f74e5
Reviewed-on: https://go-review.googlesource.com/19236
Reviewed-by: Todd Neal <todd@tneal.org>
2016-02-05 01:53:13 +00:00
Keith Randall
a0da2d242c [dev.ssa] cmd/compile: Use ADD instead of LEA when we can
If the output register is one of the input registers,
we can use a real add instead of LEA.

Change-Id: Ide58f1536afb077c0b939d3a8c7555807fd1c5e3
Reviewed-on: https://go-review.googlesource.com/19234
Reviewed-by: Alexandru Moșoi <alexandru@mosoi.ro>
2016-02-05 00:15:35 +00:00
Alexandru Moșoi
0543447597 [dev.ssa] cmd/compile/internal/ssa/gen: enclose rules' code in a for loop
* Enclose each rule's code in a for with no condition
* The loop is ran at most once because it's always terminated by a return.
* Use break when matching condition fails
* Drop rule hashes
* Shaves about 3 lines of code per rule

The binary size is not afected.

Change-Id: I27c3e40dc8cae98dcd50739342dc38db2ef9c247
Reviewed-on: https://go-review.googlesource.com/19220
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-04 22:40:26 +00:00
Keith Randall
9278a04a8f [dev.ssa] cmd/compile: more combining of ops into instructions
Mostly indexed loads.  A few more LEA cases.

Change-Id: Idc1d447ed0dd6e906cd48e70307a95e77f61cf5f
Reviewed-on: https://go-review.googlesource.com/19172
Reviewed-by: Todd Neal <todd@tneal.org>
Run-TryBot: Keith Randall <khr@golang.org>
2016-02-04 22:30:29 +00:00
Keith Randall
7de8cfdf9c [dev.ssa] cmd/internal/obj/x86: don't clobber flags with dynlink rewrite
LEAQ symbol+100(SB), AX

Under dynamic link, rewrites to

MOVQ symbol@GOT(SB), AX
ADDQ $100, AX

but ADDQ clobbers flags, whereas the original LEAQ (when not dynamic
linking) doesn't.

Use LEAQ instead of ADDQ to add that constant in so we preserve flags.

Change-Id: Ibb055403d94a4c5163e1c7d2f45da633ffd0b6a3
Reviewed-on: https://go-review.googlesource.com/19230
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-04 22:08:22 +00:00
Alexandru Moșoi
2df4b9c265 [dev.ssa] cmd/compile/internal/ssa/gen: move variable reset code into a function
Shaves about 3 lines per generated rule.

Change-Id: I94adc94ab79f90ac5fd033f896ece3b1eddf0f3d
Reviewed-on: https://go-review.googlesource.com/19197
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-04 18:44:03 +00:00
Todd Neal
93a0b0f315 [dev.ssa] cmd/compile: rewrites for constant shifts
Add rewrite rules to optimize constant shifts.

Fixes #10637

Change-Id: I74b724d3e81aeb7098c696d02c050f7fdfd5b523
Reviewed-on: https://go-review.googlesource.com/19106
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-04 16:41:07 +00:00
Alexandru Moșoi
606a11f464 [dev.ssa] src/cmd/compile/internal/ssa/gen: detect type earlier when generating rules.
Removes approx. one assignment per rule.

Change-Id: Ie9f0a7082ae12c4447ff6b4d40678cd92bdbb6f2
Reviewed-on: https://go-review.googlesource.com/19194
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-04 16:01:53 +00:00
Alexandru Moșoi
d4a95e78fa [dev.ssa] cmd/compile/internal/ssa: simplify comparisons with constants
* Simplify comparisons of form a + const1 == const2 or a + const1 != const2.
* Canonicalize Eq, Neq, Add, Sub to have a constant as first argument.
Needed for the above new rules and helps constant folding.

Change-Id: I8078702a5daa706da57106073a3e9f640a67f486
Reviewed-on: https://go-review.googlesource.com/19192
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-04 16:00:19 +00:00
Todd Neal
c58c20f30f [dev.ssa] cmd/compile: use sparsetree in checkFunc
Modify the simple domCheck to use the sparse tree code.  This
speeds up compilation of one of the generated test cases from
1m48s to 17s.

Change-Id: If577410ee77b54918147a66917a8e3721297ee0a
Reviewed-on: https://go-review.googlesource.com/19187
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-04 12:03:33 +00:00
Todd Neal
955749c45f [dev.ssa] cmd/compile: remove dead code
Change-Id: I1738e3af7de0972c54d74325d80781059d0796d8
Reviewed-on: https://go-review.googlesource.com/19186
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-04 00:53:55 +00:00
Russ Cox
0ed70efc6b cmd/go: fix rebuild after installation of new Go release
The loading of zversion.go was expecting it to be in
package runtime, but it moved to runtime/internal/sys.
Worse, the load was not checking the error.

Update the path, check the error, add a test.

Fixes #14176.

Change-Id: I203c40afe1448875581415d5e42c29f09b14545d
Reviewed-on: https://go-review.googlesource.com/19180
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-03 04:33:08 +00:00
Ian Lance Taylor
182a9db2dc cmd/vet: don't crash in cgo checker if type is unknown
Fixes #14201.

Change-Id: Ib61f8c00cae72463f59b90ae199fbdc1e7422a79
Reviewed-on: https://go-review.googlesource.com/19174
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-03 03:34:02 +00:00
Russ Cox
224888655f cmd/go: document that -msan requires clang
Fixes #14171.

Change-Id: Ie75c1cfd88801618308d472bc04e7fc648c95e0c
Reviewed-on: https://go-review.googlesource.com/19150
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-02 19:49:11 +00:00
Todd Neal
3297a4f5f3 [dev.ssa] cmd/compile: cache sparse sets in Config
Move the cached sparse sets to the Config.  I tested make.bash with
pre-allocating sets of size 150 and not caching very small sets, but the
difference between this implementation (no min size, no preallocation)
and a min size with preallocation was fairly negligible:

Number of sparse sets allocated:
Cached in Config w/none preallocated no min size    3684 *this CL*
Cached in Config w/three preallocated no min size   3370
Cached in Config w/three preallocated min size=150  3370
Cached in Config w/none preallocated min size=150  15947
Cached in Func,  w/no min                          96996 *previous code*

Change-Id: I7f9de8a7cae192648a7413bfb18a6690fad34375
Reviewed-on: https://go-review.googlesource.com/19152
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-02 18:08:46 +00:00
Russ Cox
8de7563acd cmd/go: avoid use of git -C, which does not exist in RHEL 7
Tested manually with "go test -run TestGetSubmodules".

Fixes #14194.

Change-Id: I4f563b2b8a38f3040d7631f74a7908ab65e0860b
Reviewed-on: https://go-review.googlesource.com/19154
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-02 16:36:43 +00:00
Keith Randall
16b1fce921 [dev.ssa] cmd/compile: add aux typing, flags to ops
Add the aux type to opcodes.
Add rematerializeable as a flag.

Change-Id: I906e19281498f3ee51bb136299bf26e13a54b2ec
Reviewed-on: https://go-review.googlesource.com/19088
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-02-02 02:55:13 +00:00
David Chase
c87a62f32b [dev.ssa] cmd/compile: reducing alloc footprint of dominator calc
Converted working slices of pointer into slices of pointer
index.  Half the size (on 64-bit machine) and no pointers
to trace if GC occurs while they're live.

TODO - could expose slice mapping ID->*Block; some dom
clients also construct these.

Minor optimization in regalloc that cuts allocation count.

Minor optimization in compile.go that cuts calls to Sprintf.

Change-Id: I28f0bfed422b7344af333dc52ea272441e28e463
Reviewed-on: https://go-review.googlesource.com/19104
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-02-02 02:20:25 +00:00
Robert Griesemer
d37d76af43 cmd/compile: fix parsing of inlined interface types with unexported methods
Fixes #14164.

Change-Id: Ib1d1d29674c99cf88e0ae12724823a31f5dbb95c
Reviewed-on: https://go-review.googlesource.com/19087
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-01 20:29:19 +00:00
Todd Neal
25abe96214 [dev.ssa] cmd/compile: regenerate code
These changes were left out of the 1cc5789df9 commit.

Change-Id: Id7f49973da281a567b69228dbaea31846b82b4af
Reviewed-on: https://go-review.googlesource.com/19105
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-01 03:40:00 +00:00
Keith Randall
1cc5789df9 [dev.ssa] cmd/compile: lots of small rewrite optimizations
Small optimizations I noticed while looking at Giovanni's test cases.

More shifts by constants.
Indexed stores for smaller types.
Fold LEA into loads/stores.
More extending loads.
CMP $0 of AND -> TEST

Fix order of TEST ops.

Giovanni's test cases at https://gist.github.com/rasky/62fba94e3a20d1b05b2a

Change-Id: I7077bc0b5319bf05767eeb39f401f4bb4b39f635
Reviewed-on: https://go-review.googlesource.com/19086
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
Reviewed-by: David Chase <drchase@google.com>
2016-01-31 05:30:13 +00:00
Todd Neal
f962f33035 [dev.ssa] cmd/compile: reuse sparse sets across compiler passes
Cache sparse sets in the function so they can be reused by subsequent
compiler passes.

benchmark                        old ns/op     new ns/op     delta
BenchmarkDSEPass-8               206945        180022        -13.01%
BenchmarkDSEPassBlock-8          5286103       2614054       -50.55%
BenchmarkCSEPass-8               1790277       1790655       +0.02%
BenchmarkCSEPassBlock-8          18083588      18112771      +0.16%
BenchmarkDeadcodePass-8          59837         41375         -30.85%
BenchmarkDeadcodePassBlock-8     1651575       511169        -69.05%
BenchmarkMultiPass-8             531529        427506        -19.57%
BenchmarkMultiPassBlock-8        7033496       4487814       -36.19%

benchmark                        old allocs     new allocs     delta
BenchmarkDSEPass-8               11             4              -63.64%
BenchmarkDSEPassBlock-8          599            120            -79.97%
BenchmarkCSEPass-8               18             18             +0.00%
BenchmarkCSEPassBlock-8          2700           2700           +0.00%
BenchmarkDeadcodePass-8          4              3              -25.00%
BenchmarkDeadcodePassBlock-8     30             9              -70.00%
BenchmarkMultiPass-8             24             20             -16.67%
BenchmarkMultiPassBlock-8        1800           1000           -44.44%

benchmark                        old bytes     new bytes     delta
BenchmarkDSEPass-8               221367        142           -99.94%
BenchmarkDSEPassBlock-8          3695207       3846          -99.90%
BenchmarkCSEPass-8               303328        303328        +0.00%
BenchmarkCSEPassBlock-8          5006400       5006400       +0.00%
BenchmarkDeadcodePass-8          84232         10506         -87.53%
BenchmarkDeadcodePassBlock-8     1274940       163680        -87.16%
BenchmarkMultiPass-8             608674        313834        -48.44%
BenchmarkMultiPassBlock-8        9906001       5003450       -49.49%

Change-Id: Ib1fa58c7f494b374d1a4bb9cffbc2c48377b59d3
Reviewed-on: https://go-review.googlesource.com/19100
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-01-30 13:57:39 +00:00
David Chase
88b230eaa6 [dev.ssa] cmd/compile: exposed do-log boolean to reduce allocations
From memory profiling, about 3% reduction in allocation count.

Change-Id: I4b662d55b8a94fe724759a2b22f05a08d0bf40f8
Reviewed-on: https://go-review.googlesource.com/19103
Reviewed-by: Keith Randall <khr@golang.org>
2016-01-29 21:30:29 +00:00
Keith Randall
f3575a9561 [dev.ssa] cmd/compile: tweak init function prologue
We used to compare the init state with == to 0 and 2, which
requires 2 comparisons.  Instead, compare with 1 and use
<, ==.  That requires only one comparison.

This isn't a big deal performance-wise, as it is just init
code.  But there is a fair amount of init code, so this
should help a bit with code size.

Change-Id: I4a2765f1005776f0edce28ac143f4b7596d95a68
Reviewed-on: https://go-review.googlesource.com/18948
Reviewed-by: David Chase <drchase@google.com>
2016-01-29 20:22:35 +00:00
Keith Randall
f94e0745b3 [dev.ssa] cmd/compile: prepare for some load+op combining
Rename StoreConst to ValAndOff so we can use it for other ops.
Make ValAndOff print nicely.

Add some notes & checks related to my aborted attempt to
implement combined CMP+load ops.

Change-Id: I2f901d12d42bc5a82879af0334806aa184a97e27
Reviewed-on: https://go-review.googlesource.com/18947
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
2016-01-29 20:22:09 +00:00
Keith Randall
5ba31940dc [dev.ssa] cmd/compile: fix write barriers for SSA
The old write barriers used _nostore versions, which
don't work for Ian's cgo checker.  Instead, we adopt the
same write barrier pattern as the default compiler.

It's a bit trickier to code up but should be more efficient.

Change-Id: I6696c3656cf179e28f800b0e096b7259bd5f3bb7
Reviewed-on: https://go-review.googlesource.com/18941
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-01-29 17:49:59 +00:00
Keith Randall
d8a65672f8 [dev.ssa] cmd/compile: optimization for && and || expressions
Compiling && and || expressions often leads to control
flow of the following form:

p:
  If a goto b else c
b: <- p ...
  x = phi(a, ...)
  If x goto t else u

Note that if we take the edge p->b, then we are guaranteed
to take the edge b->t also.  So in this situation, we might
as well go directly from p to t.

Change-Id: I6974f1e6367119a2ddf2014f9741fdb490edcc12
Reviewed-on: https://go-review.googlesource.com/18910
Reviewed-by: David Chase <drchase@google.com>
2016-01-29 17:49:45 +00:00
Russ Cox
9f58bf5f6b cmd/go: avoid a few symlink-induced errors in internal and vendor checks
This CL expands symlinks only when an error would be reported otherwise.
Since the expansions are only on error paths, anything that worked yesterday
should still work after this CL.

This CL fixes a regression from Go 1.5 in "go run", or else we'd probably
postpone it.

Changing only the error paths is meant as a way to reduce the risk of
making this change so late in the release cycle, but it may actually be
the right strategy for symlinks in general.

Fixes #14054.

Change-Id: I42ed1276f67a0c395297a62bcec7d36c14c06404
Reviewed-on: https://go-review.googlesource.com/19102
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-29 17:42:04 +00:00
Keith Randall
9d6e605cf7 [dev.ssa] cmd/compile: simple forward-looking register allocation tweak
For each value that needs to be in a fixed register at the end of the
block, and try to pick that fixed register when the instruction
generating that value is scheduled (or restored from a spill).

Just used for end-of-block register requirements for now.
Fixed-register instruction requirements (e.g. shift in ecx) can be
added later.  Also two-instruction constraints (input reg == output
reg) might be recorded in a similar manner.

Change-Id: I59916e2e7f73657bb4fc3e3b65389749d7a23fa8
Reviewed-on: https://go-review.googlesource.com/18774
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-01-29 17:32:38 +00:00
Keith Randall
8a961aee28 [dev.ssa] cmd/compile: fix -N build
The OpSB hack didn't quite work.  We need to really
CSE these ops to make regalloc happy.

Change-Id: I9f4d7bfb0929407c84ee60c9e25ff0c0fbea84af
Reviewed-on: https://go-review.googlesource.com/19083
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-01-29 17:27:12 +00:00
Russ Cox
0f89efa255 cmd/vet: report uncalled functions in Printf %v
Given, say, var f *os.File, a new vet check in CL 14122 diagnoses:

	fmt.Printf("%s\n", f.Name)
	fmt.Println(f.Name)

but not

	fmt.Printf("%v\n", f.Name)

In all three cases the error is that the argument should be f.Name().

Diagnosing Println but not Printf %v seems oddly inconsistent,
so I changed %v to have the check too. In fact, all verbs now have
the check except %p and %T.

Fixes Dave Cheney's confusion when trying to write an example
of the new vet check advertised in the Go 1.6 release notes.

Change-Id: I92fa6a7a1d5d9339a6a59ae4e587a254e633f500
Reviewed-on: https://go-review.googlesource.com/19101
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-01-29 17:01:47 +00:00
Keith Randall
056c09bb88 [dev.ssa] cmd/compile: add backing store buffers for block.{Preds,Succs,Values}
Speeds up compilation by 6%.

Change-Id: Ibaad95710323ddbe13c1b0351843fe43a48d776e
Reviewed-on: https://go-review.googlesource.com/19080
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-29 01:01:39 +00:00
Keith Randall
4c5459da2b [dev.ssa] cmd/compile: fix build
Some tests make multiple Funcs per Config at once.
With value & block caching, we can't do that any more.

Change-Id: Ibdb60aa2fcf478f1726b3be0fcaa06b04433eb67
Reviewed-on: https://go-review.googlesource.com/19081
Reviewed-by: Keith Randall <khr@golang.org>
2016-01-29 00:30:13 +00:00
Keith Randall
2f57d0fe02 [dev.ssa] cmd/compile: preallocate small-numbered values and blocks
Speeds up the compiler ~5%.

Change-Id: Ia5cf0bcd58701fd14018ec77d01f03d5c7d6385b
Reviewed-on: https://go-review.googlesource.com/19060
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-28 22:52:42 +00:00
Keith Randall
6a96a2fe5a [dev.ssa] cmd/compile: make cse faster
It is one of the slowest compiler phases right now, and we
run two of them.

Instead of using a map to make the initial partition, use a sort.
It is much less memory intensive.

Do a few optimizations to avoid work for size-1 equivalence classes.

Implement -N.

Change-Id: I1d2d85d3771abc918db4dd7cc30b0b2d854b15e1
Reviewed-on: https://go-review.googlesource.com/19024
Reviewed-by: David Chase <drchase@google.com>
2016-01-28 20:59:20 +00:00
Brad Fitzpatrick
b460d1d52f cmd/internal/obj/x86: skip test when GOHOSTARCH is set
It's causing the darwin-386 builder to fail with:

--- FAIL: TestDynlink (0.07s)
    obj6_test.go:118: error exit status 3 output go tool: no such tool "asm"
FAIL
FAIL    cmd/internal/obj/x86    0.073s

So skip it for now. It's tested in enough other places.

Change-Id: I9a98ad7b8be807005750112d892ac6c676c17dd5
Reviewed-on: https://go-review.googlesource.com/18989
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-27 21:33:50 +00:00
Russ Cox
4223675913 cmd/go: refine definition of 'standard' import paths to include vendored code
The vendored copy of golang.org/x/net/http/hpack was being treated
as not standard, which in turn was making it not subject to the mtime
exception for rebuilding the standard library in a release, which in turn
was making net/http look out of date.

One fix and three tests:

- Fix the definition of standard.
- Test that everything in $GOROOT/src/ is standard during 'go test cmd/go'.
(In general there can be non-standard things in $GOROOT/src/, but this
test implies that you can do that or you can run 'go test cmd/go',
but not both. That's fine.)
- Test that 'go list std cmd' shows our vendored code.
- Enforce that no standard package can depend on a non-standard one.

Also fix a few error printing nits.

Fixes #13713.

Change-Id: I1f943f1c354174c199e9b52075c11ee44198e81b
Reviewed-on: https://go-review.googlesource.com/18978
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2016-01-27 18:03:15 +00:00
Richard Miller
158f19b259 cmd/go: recognise plan9_arm object files
Add magic word for Plan 9 ARM object header to objectMagic table.

Change-Id: I21eb8845a2ee2e8cdddc0849eedf43481aee9cde
Reviewed-on: https://go-review.googlesource.com/18963
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-27 16:05:40 +00:00
Richard Miller
bd7e084d7d cmd/link: correct byte ordering in plan9_arm object header
Fields in Plan 9 object headers are big-endian, on all architectures.

Change-Id: If95ad29750b776338178d660646568bf26a4abda
Reviewed-on: https://go-review.googlesource.com/18964
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-27 15:52:44 +00:00
Russ Cox
4ec2fd3e6a cmd/go: disable broken test for code.google.com
For Go 1.7 we can remove all the code.google.com code
(except maybe the shutdown warning).

See #10193.

Change-Id: I4b8182eb66494f0bf373b40ca5da6ae4738342be
Reviewed-on: https://go-review.googlesource.com/18974
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-27 03:35:36 +00:00
Russ Cox
73d590b4bd cmd/internal/obj/arm64: adjust literal pool flush for span-dependent jump enlargement
The current code delays the literal pool until the very last moment,
but based on the assumption that span-dependent jumps are as
short as possible. If they need to be enlarged in a later round, that
very last moment may be too late. Flush a little early to prevent that.

Fixes #13579.

Change-Id: I759b5db5c43a977bf2b940872870cbbc436ad141
Reviewed-on: https://go-review.googlesource.com/18972
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Russ Cox <rsc@golang.org>
2016-01-27 00:58:39 +00:00
Russ Cox
1d901f55bd cmd/compile: remove -h spam
This debugging print crept into an earlier CL of mine.

Change-Id: If6e8609e69a60aec50c06889c2d98a8b8a4bd02b
Reviewed-on: https://go-review.googlesource.com/18971
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-27 00:17:22 +00:00
Ian Lance Taylor
1aab7b9626 cmd/link: add -extar option to set ar program for c-archive
People who want to use -buildmode=c-archive in unusual cross-compilation
setups will need something like this.  It could also be done via (yet
another) environment variable but I use -extar by analogy with the
existing -extld.

Change-Id: I354cfabc4c470603affd13cd946997b3a24c0e6c
Reviewed-on: https://go-review.googlesource.com/18913
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-26 18:52:36 +00:00
Keith Randall
7b773946c0 [dev.ssa] cmd/compile: disable xor clearing when flags must be preserved
The x86 backend automatically rewrites MOV $0, AX to
XOR AX, AX.  That rewrite isn't ok when the flags register
is live across the MOV.  Keep track of which moves care
about preserving flags, then disable this rewrite for them.

On x86, Prog.Mark was being used to hold the length of the
instruction.  We already store that in Prog.Isize, so no
need to store it in Prog.Mark also.  This frees up Prog.Mark
to hold a bitmask on x86 just like all the other architectures.

Update #12405

Change-Id: Ibad8a8f41fc6222bec1e4904221887d3cc3ca029
Reviewed-on: https://go-review.googlesource.com/18861
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-26 17:40:22 +00:00
Keith Randall
733bf6ef67 [dev.ssa] cmd/compile: get rid of +0.0 hack
The conversion from -0.0 to +0.0 happens inside mpgetflt now.
The SSA code doesn't need this fix any more.

Change-Id: I6cd4f4a4e75b13cf284ebbb95b08af050ed9891c
Reviewed-on: https://go-review.googlesource.com/18942
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
2016-01-26 16:18:48 +00:00
Russ Cox
e634765941 cmd/asm: add amd64 HADDPD/HADDPS
Was part of #13822 but not in the first message, so I missed it.

Fixes #13822 again.

Change-Id: I775004fa8d47b6af293124605521ec396573e267
Reviewed-on: https://go-review.googlesource.com/18900
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-26 14:48:08 +00:00
Mikio Hara
295ec4f6f8 cmd/go/testdata: fix nits in test
Change-Id: I85fa5e672a476098f8711dcbb5b20ea1a3fa630d
Reviewed-on: https://go-review.googlesource.com/18953
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-26 14:47:49 +00:00
Ian Lance Taylor
3415d0c49d cmd/go: fix handling of asm files for -compiler=gccgo
Pass -c to generate an object.  Pass GOPKGPATH as a symbol, not a
string.  Pass -xassembler-with-cpp so that the preprocessor is run.

Change-Id: I84690a73cc580bb05724ed07c120cec9cfd5e48b
Reviewed-on: https://go-review.googlesource.com/18733
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-25 02:45:09 +00:00
Russ Cox
9d6427d899 cmd/asm: reject foo(SB)(AX) instead of silently treating as foo(SB)
Add test for assembly errors, to verify fix.
Make sure invalid instruction errors are printed just once
(was printing them once per span iteration, so typically twice).

Fixes #13282.

Change-Id: Id5f66f80a80b3bc4832e00084b0a91f1afec7f8f
Reviewed-on: https://go-review.googlesource.com/18858
Reviewed-by: Rob Pike <r@golang.org>
2016-01-24 20:21:45 +00:00
Russ Cox
0bae38e094 cmd/asm: add amd64 PDEP, PEXT, and related integer VEX instructions
Requested off-list.
Trivial to add and more importantly trivial to test.

ANDNL
ANDNQ
BEXTRL
BEXTRQ
BZHIL
BZHIQ
MULXL
MULXQ
PDEPL
PDEPQ
PEXTL
PEXTQ
SARXL
SARXQ
SHRXL
SHRXQ

Change-Id: I3d46a0f653b81dd003ff6d2a394d8ce96a573b63
Reviewed-on: https://go-review.googlesource.com/18857
Reviewed-by: Rob Pike <r@golang.org>
2016-01-24 13:56:01 +00:00
Russ Cox
863d9b66f8 cmd/asm: add requested amd64 instructions
Add amd64 instructions I promised to add for Go 1.6
at the beginning of January.

These may be the last instructions added by hand.
I intend to generate the whole set mechanically for Go 1.7.

Fixes #13822.

Change-Id: I8c6bae2efd25f717f9ec750402e50f408a911d2b
Reviewed-on: https://go-review.googlesource.com/18853
Reviewed-by: Rob Pike <r@golang.org>
2016-01-24 13:55:40 +00:00
Russ Cox
8d881b811d cmd/asm: correct, complete newly added AVX instructions
Use the standard names, for discoverability.
Use the standard register arguments, for correctness.
Implement all possible arguments, for completeness.
Enable the corresponding tests now that everything is standard.
Update the uses in package runtime.

Fixes #14068.

Change-Id: I8e1af9a41e7d02d98c2a82af3d4cdb3e9204824f
Reviewed-on: https://go-review.googlesource.com/18852
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-01-24 13:55:18 +00:00
Russ Cox
7f620a57d0 cmd/asm: add x86 POPCNTW, POPCNTL
Fixes #4816.

Change-Id: Ibeaa69f57b7519d56df4ea357edf8d9dc2102ffe
Reviewed-on: https://go-review.googlesource.com/18851
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-24 05:51:04 +00:00
Russ Cox
659c632885 cmd/asm: add generated test of amd64 instruction encodings
Generated by x86test, from https://golang.org/cl/18842
(still in progress).

The commented out lines are either missing or misspelled
or incorrectly handled instructions.

For #4816, #8037, #13822, #14068, #14069.

Change-Id: If309310c97d9d2a3c71fc64c51d4a957e9076ab7
Reviewed-on: https://go-review.googlesource.com/18850
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-24 05:50:53 +00:00
Russ Cox
2eb8d94dbd cmd/asm: add test for verification of instruction encodings
Not much testing yet, but the test now exists.

Another step toward #13822.

Change-Id: Idb2b06bf53a6113c83008150b4c0b631bb195279
Reviewed-on: https://go-review.googlesource.com/18844
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2016-01-24 05:50:41 +00:00
Russ Cox
d3ff40fb1f cmd/internal/obj/x86: fix doubled REX byte in POPCNT, others
Tests for this and many other instructions are in a separate followup CL.

For #14068.

Change-Id: I6955315996a34d7fb79369b9d9a0119d11745e85
Reviewed-on: https://go-review.googlesource.com/18849
Reviewed-by: Rob Pike <r@golang.org>
2016-01-24 05:01:32 +00:00
Russ Cox
f844b0be18 cmd/internal/obj/x86: rename POPCNT to POPCNTQ
Ilya added POPCNT in a CL earlier this month but it's really only POPCNTQ.
The other forms still need to be added.

For #4816.

Change-Id: I1186850d32ad6d5777475c7808e6fc9d9133e118
Reviewed-on: https://go-review.googlesource.com/18848
Reviewed-by: Rob Pike <r@golang.org>
2016-01-24 05:01:18 +00:00
Russ Cox
02717bdc20 cmd/asm: add -e flag (no limit on errors) to match compiler
Change-Id: I5b749c575e0ec78fb3c50d056899bd1fe5d91853
Reviewed-on: https://go-review.googlesource.com/18847
Reviewed-by: Rob Pike <r@golang.org>
2016-01-24 05:01:00 +00:00
Russ Cox
d2b0c387b2 cmd/asm: add YMM registers Y0 through Y15
Not recognized in any instructions yet, but this lets the
assembler parse them at least.

For #14068.

Change-Id: Id4f7329a969b747a867ce261b20165fab2cdcab8
Reviewed-on: https://go-review.googlesource.com/18846
Reviewed-by: Rob Pike <r@golang.org>
2016-01-24 05:00:43 +00:00
Russ Cox
36edf48a10 cmd/asm: report more than one instruction encoding error
Also, remove output file if there are encoding errors.
The extra reports are convenient.
Removing the output file is very important.
Noticed while testing.

Change-Id: I0fab17d4078f93c5a0d6d1217d8d9a63ac789696
Reviewed-on: https://go-review.googlesource.com/18845
Reviewed-by: Rob Pike <r@golang.org>
2016-01-24 05:00:28 +00:00
Russ Cox
a5ba581ae0 cmd/asm: simplify golden test maintenance
Instead of two parallel files that look almost identical,
mark the expected differences in the original file.

The annotations being added here keep the tests passing,
but they also make clear a number of printing or parsing
errors that were not as easily seen when the data was
split across two files.

Fix a few diagnostic problems in cmd/internal/obj as well.

A step toward #13822.

Change-Id: I997172681ea6fa7da915ff0f0ab93d2b76f8dce2
Reviewed-on: https://go-review.googlesource.com/18823
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-24 05:00:04 +00:00
Keith Randall
3c26c0db39 [dev.ssa] cmd/compile: short-circuit empty blocks
Empty blocks are introduced to remove critical edges.
After regalloc, we can remove any of the added blocks
that are still empty.

Change-Id: I0b40e95ac3a6cc1e632a479443479532b6c5ccd9
Reviewed-on: https://go-review.googlesource.com/18833
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-01-22 22:12:12 +00:00
Shenghou Ma
1b6d55acab cmd/internal/obj/mips, cmd/internal/obj: reduce MIPS register space
Change-Id: I43458ce0e78ffc3d0943d28dc8df8e1c9e4cf679
Reviewed-on: https://go-review.googlesource.com/18821
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-22 04:33:47 +00:00
Robert Griesemer
a4599efcfb cmd/compile: update vendored copy of math/big
- obtained by running sh vendor.bash
- contains updated tests and some bug fixes for Montgomery mult.
  (not used by compiler)
- for consistency of math/big versions only

Change-Id: Ib47e48d5b7f6d0e05d7837b1bc74bdb03f2b094e
Reviewed-on: https://go-review.googlesource.com/18831
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-22 01:14:16 +00:00
Robert Griesemer
445c6855fc cmd/compile: remove unused (dead) fields
Change-Id: I4816a788e7b89b76dc70d05f4b176e99684d0680
Reviewed-on: https://go-review.googlesource.com/18830
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-22 01:13:43 +00:00
Keith Randall
7730880f7c [dev.ssa] cmd/compile: update SSA TODOs
Change-Id: I78743987dcb45d821212caf95a00ae15b7a6cfd8
Reviewed-on: https://go-review.googlesource.com/18773
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-01-21 03:20:29 +00:00
Ian Lance Taylor
33a784e1f7 cmd/go: document PackageError in go list output
Fixes #14007.

Change-Id: I1f73dfccb466d8fd00efbd8c92a31ac538bf5988
Reviewed-on: https://go-review.googlesource.com/18731
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-21 01:35:07 +00:00
Keith Randall
a734bbc953 [dev.ssa] cmd/compile: Allow structs to be SSAd
Break small structs up into their components so they
can be registerized.

Change StructSelect to use field indexes instead of
field offsets, as field offsets aren't unique in the
presence of zero-sized fields.

Change-Id: I2f1dc89f7fa58e1cf58aa1a32b238959d53f62e4
Reviewed-on: https://go-review.googlesource.com/18570
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-01-20 22:37:11 +00:00
Keith Randall
b5c5efd5de [dev.ssa] cmd/compile: optimize phi ops
Redo how we keep track of forward references when building SSA.
When the forward reference is resolved, update the Value node
in place.

Improve the phi elimination pass so it can simplify phis of phis.

Give SSA package access to decoded line numbers.  Fix line numbers
for constant booleans.

Change-Id: I3dc9896148d260be2f3dd14cbe5db639ec9fa6b7
Reviewed-on: https://go-review.googlesource.com/18674
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
2016-01-20 21:45:37 +00:00
Michael Hudson-Doyle
cd9fc3ebfb cmd/link: allow symbols from .a files to override those from .so files
https://golang.org/s/execmodes defines rules for how multiple codes of a go
package work when they end up in the address space of a single process, but
currently the linker blows up in this situation. Fix that by loading all .a
files before any .so files and ignoring duplicate symbols found when loading
shared libraries.

I know this is very very late for 1.6 but at least it should clearly not have
any effect when shared libraries are not in use.

Change-Id: I512ac912937e7502ff58eb5628b658ecce3c38e5
Reviewed-on: https://go-review.googlesource.com/18714
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2016-01-20 19:53:53 +00:00
Shenghou Ma
97266969d8 cmd/dist: pass -tags race to go list in -race mode
so that runtime/race tests are included in the race builder.

Update #14011.

Change-Id: I04ac6e47366fdb1fe84ba89da556c6d38f7d4a47
Reviewed-on: https://go-review.googlesource.com/18686
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-20 06:10:20 +00:00
Robert Griesemer
5395846890 cmd/compile: don't print (empty) package name in errors referring to built-ins
Fixes #14010.

Change-Id: Idfd4b063eecf453fe00f3e798099023707a65963
Reviewed-on: https://go-review.googlesource.com/18738
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
2016-01-20 04:43:43 +00:00
Keith Randall
23d5810c8f [dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Semi-regular merge from tip to dev.ssa.

Conflicts:
	src/runtime/sys_windows_amd64.s

Change-Id: I5f733130049c810e6ceacd46dad85faebca52b29
2016-01-19 14:13:16 -08:00
Keith Randall
d9b32f0c7d cmd/compile: add VARLIVE to opnames list
Change-Id: Ie8cb7c7428ae9026c11643b22f9ecf7977e25f5f
Reviewed-on: https://go-review.googlesource.com/18737
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-19 21:56:09 +00:00
Robert Griesemer
7ce2402bae cmd/compile: don't crash on invalid labeled statement
Fixes #14006.

Change-Id: Ia819073677ad6993c02255e23760ee21598427b4
Reviewed-on: https://go-review.googlesource.com/18736
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-19 21:34:28 +00:00
Robert Griesemer
92ba69d216 cmd/compile: set importpkg.Direct correctly when using binary imports
Fixes #13977.

Change-Id: Icf54b4d2d746d30da207d1e17c975d18188b1cf8
Reviewed-on: https://go-review.googlesource.com/18702
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-01-19 18:28:08 +00:00
OneOfOne
5e7110b92b cmd/link: fix elf64phdr to allow using upx (and other broken ELF loaders).
The linker already applies the fix for elf32, so this just extends it to elf64.

Inspired by https://github.com/pwaller/goupx

Fixes #13974

Change-Id: I65d92b5be9590657060a0e8e80ff5b86ba40017f
Reviewed-on: https://go-review.googlesource.com/18690
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-19 18:01:33 +00:00
Keith Randall
90065eaba4 [dev.ssa] cmd/compile: use wider move instruction for floats
Distinguish move/load/store ops.  Unify some of this code a bit.

Reduces Mandelbrot slowdown with SSA from 58% to 12%.

Change-Id: I3276eaebcbcdd9de3f8299c79b5f25c0429194c4
Reviewed-on: https://go-review.googlesource.com/18677
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-01-19 15:44:03 +00:00
Keith Randall
da8af47710 [dev.ssa] cmd/compile: report better line numbers for Unimplemented/Fatal
If a failure occurs in SSA processing, we always report the
last line of the function we're compiling.  Modify the callbacks
from SSA to the GC compiler so we can pass a line number back
and use it in Fatalf.

Change-Id: Ifbfad50d5e167e997e0a96f0775bcc369f5c397e
Reviewed-on: https://go-review.googlesource.com/18599
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-01-19 15:43:32 +00:00
Russ Cox
383d817e02 cmd/go: fix vendor directory check on Windows
Fixes build.

Change-Id: Idd7d87f0bf3fe553b3ab00dd32eee4925a4fe3ff
Reviewed-on: https://go-review.googlesource.com/18647
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2016-01-14 20:41:14 +00:00
Russ Cox
f36ee8c249 cmd/go: respect internal directories during 'go run'
Fixes #12217.

Change-Id: I5ee6cb18eaa66bdec1affe689aa531c05e719fc9
Reviewed-on: https://go-review.googlesource.com/18645
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-01-14 04:01:47 +00:00
Russ Cox
8534429181 cmd/go, go/build: ignore vendor directories with no Go source files
Otherwise it is impossible to vendor a/b/c without hiding the real a/b.
I also updated golang.org/s/go15vendor.

Fixes #13832.

Change-Id: Iee3d53c11ea870721803f6e8e67845b405686e79
Reviewed-on: https://go-review.googlesource.com/18644
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-01-14 03:43:57 +00:00
Russ Cox
5f23bc8903 cmd/compile: add AVARLIVE to peep for arm, arm64, mips64, ppc64
Fixes build on those systems.

Also fix printing of AVARLIVE.

Change-Id: I1b38cca0125689bc08e4e1bdd0d0c140b1ea079a
Reviewed-on: https://go-review.googlesource.com/18641
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-14 02:04:50 +00:00
Russ Cox
ed03dab853 cmd/internal/obj: separate code layout from object writing
This will allow the compiler to crunch Prog lists down to code as each
function is compiled, instead of waiting until the end, which should
reduce the working set of the compiler. But not until Go 1.7.

This also makes it easier to write some machine code output tests
for the assembler, which is why it's being done now.

For #13822.

Change-Id: I0811123bc6e5717cebb8948f9cea18e1b9baf6f7
Reviewed-on: https://go-review.googlesource.com/18311
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-14 01:51:27 +00:00
Russ Cox
1ac637c766 cmd/compile: recognize Syscall-like functions for liveness analysis
Consider this code:

	func f(*int)

	func g() {
		p := new(int)
		f(p)
	}

where f is an assembly function.
In general liveness analysis assumes that during the call to f, p is dead
in this frame. If f has retained p, p will be found alive in f's frame and keep
the new(int) from being garbage collected. This is all correct and works.
We use the Go func declaration for f to give the assembly function
liveness information (the arguments are assumed live for the entire call).

Now consider this code:

	func h1() {
		p := new(int)
		syscall.Syscall(1, 2, 3, uintptr(unsafe.Pointer(p)))
	}

Here syscall.Syscall is taking the place of f, but because its arguments
are uintptr, the liveness analysis and the garbage collector ignore them.
Since p is no longer live in h once the call starts, if the garbage collector
scans the stack while the system call is blocked, it will find no reference
to the new(int) and reclaim it. If the kernel is going to write to *p once
the call finishes, reclaiming the memory is a mistake.

We can't change the arguments or the liveness information for
syscall.Syscall itself, both for compatibility and because sometimes the
arguments really are integers, and the garbage collector will get quite upset
if it finds an integer where it expects a pointer. The problem is that
these arguments are fundamentally untyped.

The solution we have taken in the syscall package's wrappers in past
releases is to insert a call to a dummy function named "use", to make
it look like the argument is live during the call to syscall.Syscall:

	func h2() {
		p := new(int)
		syscall.Syscall(1, 2, 3, uintptr(unsafe.Pointer(p)))
		use(unsafe.Pointer(p))
	}

Keeping p alive during the call means that if the garbage collector
scans the stack during the system call now, it will find the reference to p.

Unfortunately, this approach is not available to users outside syscall,
because 'use' is unexported, and people also have to realize they need
to use it and do so. There is much existing code using syscall.Syscall
without a 'use'-like function. That code will fail very occasionally in
mysterious ways (see #13372).

This CL fixes all that existing code by making the compiler do the right
thing automatically, without any code modifications. That is, it takes h1
above, which is incorrect code today, and makes it correct code.

Specifically, if the compiler sees a foreign func definition (one
without a body) that has uintptr arguments, it marks those arguments
as "unsafe uintptrs". If it later sees the function being called
with uintptr(unsafe.Pointer(x)) as an argument, it arranges to mark x
as having escaped, and it makes sure to hold x in a live temporary
variable until the call returns, so that the garbage collector cannot
reclaim whatever heap memory x points to.

For now I am leaving the explicit calls to use in package syscall,
but they can be removed early in a future cycle (likely Go 1.7).

The rule has no effect on escape analysis, only on liveness analysis.

Fixes #13372.

Change-Id: I2addb83f70d08db08c64d394f9d06ff0a063c500
Reviewed-on: https://go-review.googlesource.com/18584
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-14 01:16:45 +00:00
Ian Lance Taylor
7ec5508810 cmd/go: fix gccSupportsNoPie for old GCC's that don't exit 0
GCC 4.8 exits 1 on an unrecognized option, but GCC 4.4 and 4.5 exit 0.
I didn't check other versions, or try to figure out just when this
changed.

Fixes #13937.

Change-Id: If193e9053fbb535999c9bde99f430f465a8c7c57
Reviewed-on: https://go-review.googlesource.com/18597
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-13 19:29:22 +00:00
Russ Cox
4a0eee2faa cmd/link: add LC_VERSION_MIN_MACOSX to linkmode=internal OS X binaries
This makes lldb willing to debug them.
The minimum version is hard-coded at OS X 10.7,
because that is the minimum that Go requires.
For more control over the version, users can
use linkmode=external and pass the relevant flags to the host linker.

Fixes #12941.

Change-Id: I20027be8aa034d07dd2a3326828f75170afe905f
Reviewed-on: https://go-review.googlesource.com/18588
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-13 19:06:40 +00:00
Keith Randall
3425295e91 [dev.ssa] cmd/compile: clean up comparisons
Add new constant-flags opcodes.  These can be generated from
comparisons that we know the result of, like x&31 < 32.

Constant-fold the constant-flags opcodes into all flag users.

Reorder some CMPxconst args so they read in the comparison direction.

Reorg deadcode removal a bit - it needs to remove the OpCopy ops it
generates when strength-reducing Phi ops.  So it needs to splice out all
the dead blocks and do a copy elimination before it computes live
values.

Change-Id: Ie922602033592ad8212efe4345394973d3b94d9f
Reviewed-on: https://go-review.googlesource.com/18267
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-01-13 18:42:00 +00:00
Keith Randall
9094e3ada2 [dev.ssa] cmd/compile: fix spill sizes
In code that does:

    var x, z int32
    var y int64
    z = phi(x, int32(y))

We silently drop the int32 cast because truncation is a no-op.
The phi operation needs to make sure it uses the size of the
phi, not the size of its arguments, when generating spills.

Change-Id: I1f7baf44f019256977a46fdd3dad1972be209042
Reviewed-on: https://go-review.googlesource.com/18390
Reviewed-by: David Chase <drchase@google.com>
2016-01-13 18:39:15 +00:00
Joe Sylve
9efc46f1cb cmd/go: -buildmode=c-shared should work on darwin/386
* Enable c-shared buildmode on darwin/386
* dyld does not support text relocation on i386. Add -read_only_relocs suppress flag to linker

Fixes #13904

Change-Id: I9adbd20d3f36ce9bbccf1bffb746b391780d088f
Reviewed-on: https://go-review.googlesource.com/18500
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-13 18:24:38 +00:00
Keith Randall
3d01f28e47 cmd/compile: stop using fucomi* ops for 387 builds
The fucomi* opcodes were only introduced for the Pentium Pro.
They do not exist for an MMX Pentium.  Use the fucom* instructions
instead and move the condition codes from the fp flags register to
the integer flags register explicitly.

The use of fucomi* opcodes in ggen.go was introduced in 1.5 (CL 8738).
The bad ops were generated for 64-bit floating-point comparisons.

The use of fucomi* opcodes in gsubr.go dates back to at least 1.1.
The bad ops were generated for float{32,64} to uint64 conversions.

Fixes #13923

Change-Id: I5290599f5edea8abf8fb18036f44fa78bd1fc9e6
Reviewed-on: https://go-review.googlesource.com/18590
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-13 16:23:13 +00:00
Ian Lance Taylor
f3ce054a44 cmd/go: fixes for -compiler=gccgo -buildmode=c-shared
Install pkg.h rather than libpkg.h.

Link against -lc.

Fixes #13860.

Change-Id: I4e429426f8363712a5dbbd2655b9aab802ab2888
Reviewed-on: https://go-review.googlesource.com/18592
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-13 15:14:04 +00:00
Ilya Tocar
1d1f2fb4c6 cmd/internal/obj/x86: add new instructions, cleanup.
Add several instructions that were used via BYTE and use them.
Instructions added: PEXTRB, PEXTRD, PEXTRQ, PINSRB, XGETBV, POPCNT.

Change-Id: I5a80cd390dc01f3555dbbe856a475f74b5e6df65
Reviewed-on: https://go-review.googlesource.com/18593
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-13 14:04:44 +00:00
David Chase
e779bfa5d2 cmd/compile: better modeling of escape across loop levels
Brief background on "why heap allocate".  Things can be
forced to the heap for the following reasons:

1) address published, hence lifetime unknown.
2) size unknown/too large, cannot be stack allocated
3) multiplicity unknown/too large, cannot be stack allocated
4) reachable from heap (not necessarily published)

The bug here is a case of failing to enforce 4) when an
object Y was reachable from a heap allocation X forced
because of 3).  It was found in the case of a closure
allocated within a loop (X) and assigned to a variable
outside the loop (multiplicity unknown) where the closure
also captured a map (Y) declared outside the loop (reachable
from heap). Note the variable declared outside the loop (Y)
is not published, has known size, and known multiplicity
(one). The only reason for heap allocation is that it was
reached from a heap allocated item (X), but because that was
not forced by publication, it has to be tracked by loop
level, but escape-loop level was not tracked and thus a bug
results.

The fix is that when a heap allocation is newly discovered,
use its looplevel as the minimum loop level for downstream
escape flooding.

Every attempt to generalize this bug to X-in-loop-
references-Y-outside loop succeeded, so the fix was aimed
to be general.  Anywhere that loop level forces heap
allocation, the loop level is tracked.  This is not yet
tested for all possible X and Y, but it is correctness-
conservative and because it caused only one trivial
regression in the escape tests, it is probably also
performance-conservative.

The new test checks the following:
1) in the map case, that if fn escapes, so does the map.
2) in the map case, if fn does not escape, neither does the map.
3) in the &x case, that if fn escapes, so does &x.
4) in the &x case, if fn does not escape, neither does &x.

Fixes #13799.

Change-Id: Ie280bef2bb86ec869c7c206789d0b68f080c3fdb
Reviewed-on: https://go-review.googlesource.com/18234
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-13 04:01:00 +00:00
Ian Lance Taylor
505fa7b423 cmd/cgo: document C.sizeof_T and zero-sized field restriction
Update #9401.
Update #11925.
Update #13919.

Change-Id: I52c679353693e8165b2972d4d3974ee8bb1207ef
Reviewed-on: https://go-review.googlesource.com/18542
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-12 17:31:01 +00:00
Michael Hudson-Doyle
b80b098bc5 cmd/go: pass -no-pie along with -Wl,-r to gcc when supported on linux
Go fails to build on a system which has PIE enabled by default like this:

/usr/bin/ld: -r and -pie may not be used together
collect2: error: ld returned 1 exit status

The only system I know that has this property right now is Ubuntu Xenial
running on s390x, which is hardly the most accessible system, but it's planned
to enable this on amd64 soon too. The fix is to pass -no-pie along with -Wl,-r
to the compiler, but unfortunately that flag is very new as well. So this does
a test compile of a trivial file to see if the flag is supported.

Change-Id: I1345571142b7c3a96212e43297d19e84ec4a3d41
Reviewed-on: https://go-review.googlesource.com/18359
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-11 21:20:00 +00:00
Yao Zhang
30919fe978 cmd/dist: restrict parallel tests to NumCPU on mips64x
mips64 builder and one machine of the mips64le builder has small amount
of memory. Since CL 18199, they have been running slowly, as more
processes were launched in running 'test' directory, and a lot of swap
were used. This CL brings all.bash from 5h back to 3h on Loongson 2E
with 512 MB memory.

Change-Id: I4a22e239a542a99ba5986753205d8cd1f4b3d3c6
Reviewed-on: https://go-review.googlesource.com/18483
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-10 06:18:22 +00:00
Russ Cox
a8fc547f78 cmd/compile: apply -importmap to imports before checking for package unsafe
There are fewer special cases this way: the import map applies
to all import paths, not just the ones not spelled "unsafe".

This is also consistent with what the code in cmd/go and go/build expects.
They make no exception for "unsafe".

For #13703.

Change-Id: I622295261ca35a6c1e83e8508d363bddbddb6c0a
Reviewed-on: https://go-review.googlesource.com/18438
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-01-08 19:16:50 +00:00
Russ Cox
ecc01a7ddf go/build: invert AllowVendor to IgnoreVendor
Looking for vendor directories is a better default.

Fixes #13772

Change-Id: Iabbaea71ccc67b72f14f1f412dc8ab70cb41996d
Reviewed-on: https://go-review.googlesource.com/18450
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2016-01-08 18:49:01 +00:00
Joel Sing
beb1741ae3 cmd/dist: fix cgoTestSO on FreeBSD amd64 with GOHOSTARCH=386
The cgoTestSO test currently fails when run on FreeBSD amd64 with
GOHOSTARCH=386. This is due to it failing to find the shared object.

On FreeBSD 64-bit architectures, the linker for 32-bit objects
looks for a separate environment variable. Export both LD_LIBRARY_PATH
and LD_32_LIBRARY_PATH on FreeBSD when GOHOSTARCH=386.

Update issue #13873.

Change-Id: I1fb20dd04eb2007061768b2e4530886521813d42
Reviewed-on: https://go-review.googlesource.com/18420
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-08 17:00:53 +00:00
Ian Lance Taylor
d91ec5bb40 cmd/cgo, runtime: recognize unsafe.Pointer(&s[0]) in cgo pointer checks
It's fairly common to call cgo functions with conversions to
unsafe.Pointer or other C types.  Apply the simpler checking of address
expressions when possible when the address expression occurs within a
type conversion.

Change-Id: I5187d4eb4d27a6542621c396cad9ee4b8647d1cd
Reviewed-on: https://go-review.googlesource.com/18391
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-08 03:56:30 +00:00
Keith Randall
035fcc0c4d [dev.ssa] cmd/compile: add some more TODOs
Change-Id: If8b6b85d2165d6222b36f101adb95b7ee40371c1
Reviewed-on: https://go-review.googlesource.com/18300
Reviewed-by: David Chase <drchase@google.com>
2016-01-08 02:51:49 +00:00
Matthew Dempsky
27691fa467 cmd/compile: recognize !typedbool is typed
Adding the evconst(n) call for OANDAND and OOROR in
golang.org/cl/18262 was originally just to parallel the above iscmp
branch, but upon further inspection it seemed odd that removing it
caused test/fixedbugs/issue6671.go's

    var b mybool
    // ...
    b = bool(true) && true // ERROR "cannot use"

to start failing (i.e., by not emitting the expected "cannot use"
error).

The problem is that evconst(n)'s settrue and setfalse paths always
reset n.Type to idealbool, even for logical operators where n.Type
should preserve the operand type.  Adding the evconst(n) call for
OANDAND/OOROR inadvertantly worked around this by turning the later
evconst(n) call at line 2167 into a noop, so the "n.Type = t"
assignment at line 739 would preserve the operand type.

However, that means evconst(n) was still clobbering n.Type for ONOT,
so declarations like:

    const _ bool = !mybool(true)

were erroneously accepted.

Update #13821.

Change-Id: I18e37287f05398fdaeecc0f0d23984e244f025da
Reviewed-on: https://go-review.googlesource.com/18362
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-07 21:43:47 +00:00
Austin Clements
fdf9b3c994 runtime: increase assumed stack size in externalthreadhandler
On Windows, externalthreadhandler currently sets the assumed stack
size for the profiler thread and the ctrlhandler threads to 8KB. The
actual stack size is determined by the SizeOfStackReserve field in the
binary set by the linker, which is currently at least 64KB (and
typically 128KB).

It turns out the profiler thread is running within a few words of the
8KB-(stack guard) bound set by externalthreadhandler. If it overflows
this bound, morestack crashes unceremoniously with an access
violation, which we then fail to handle, causing the whole process to
exit without explanation.

To avoid this problem and give us some breathing room, increase the
assumed stack size in externalthreadhandler to 32KB (there's some
unknown amount of stack already in use, so it's not safe to increase
this all the way to the reserve size).

We also document the relationships between externalthreadhandler and
SizeOfStackReserve to make this more obvious in the future.

Change-Id: I2f9f9c0892076d78e09827022ff0f2bedd9680a9
Reviewed-on: https://go-review.googlesource.com/18304
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
2016-01-07 19:40:32 +00:00
Keith Randall
b386c34ef9 [dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Semi-regular merge from tip into dev.ssa.

Change-Id: I1627d7c7e6892cd4f1f5da5f3e07389ff1d677ce
2016-01-07 10:01:08 -08:00
Tamir Duberstein
24ef1d60f0 cmd/dist: improve isGitRepo to handle git "worktree"s
Simply checking the exit code of `git rev-parse --git-dir` should
suffice here, but that requires deviating from the infrastructure
provided by `run`, so I've left that for a future change.

Originally by Tamir Duberstein but updated by iant & rsc to add
the filepath.Join logic.

Fixes #11211 (again).

Change-Id: I6d29b5ae39ba456088ae1fb5d41014cb91c86897
Reviewed-on: https://go-review.googlesource.com/18323
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-07 01:23:05 +00:00
Russ Cox
fb142ee9b9 cmd/go: for go get -insecure, skip TLS certificate checking
The flag is already named -insecure. Make it more so.

If we're willing to accept HTTP, it's not much worse to accept
HTTPS man-in-the-middle attacks too. This allows servers
with self-signed certificates to work.

Fixes #13197.

Change-Id: Ia5491410bc886da0a26ef3bce4bf7d732f5e19e4
Reviewed-on: https://go-review.googlesource.com/18324
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-07 01:22:59 +00:00
Russ Cox
4220659867 cmd/go: do not force use of git master branch (again)
This time with a test.
Also adjust another test to skip when hg is not present,
and delete no longer needed fixDetachedHead code.

Fixes #9032 (again).

Change-Id: I481717409e1d44b524f83c70a8dc377699d1a2a5
Reviewed-on: https://go-review.googlesource.com/18334
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-06 21:57:20 +00:00
Russ Cox
6866f5e143 cmd/dist: assume amd64 on OS X, don't run sysctl
Fixes #13425.

Change-Id: I82f49d07841e89fc4f3fde9ea41e710a634579d0
Reviewed-on: https://go-review.googlesource.com/18313
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-06 17:59:25 +00:00
Russ Cox
bb91a7e2fd test/bench/shootout: delete
We don't use these for benchmarking anymore.
Now we have the go1 dir and the benchmarks subrepo.
Some have problematic copyright notices, so move out of main repo.

Preserved in golang.org/x/exp/shootout.

Fixes #12688.
Fixes #13584.

Change-Id: Ic0b71191ca1a286d33d7813aca94bab1617a1c82
Reviewed-on: https://go-review.googlesource.com/18320
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-06 17:58:27 +00:00
Russ Cox
91ba9f45c2 Revert "cmd/dist: improve isGitRepo to handle git "worktree"s"
This reverts commit ab096d587f.

Change-Id: Icf366aa43acc41b4f8474edae0297e554368bf14
Reviewed-on: https://go-review.googlesource.com/18321
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 17:39:43 +00:00
Tamir Duberstein
ab096d587f cmd/dist: improve isGitRepo to handle git "worktree"s
Simply checking the exit code of `git rev-parse --git-dir` should
suffice here, but that requires deviating from the infrastructure
provided by `run`, so I've left that for a future change.

Fixes #11211.

Change-Id: I7cbad86a8a06578f52f66f734f5447b597ddc962
Reviewed-on: https://go-review.googlesource.com/18213
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 15:04:13 +00:00
Matthew Dempsky
be20948e27 cmd/compile: recognize bool(true) as a constant expression
Fixes #13821.

Change-Id: I4a28a92d137edac3061537af25ac9d7aba411a66
Reviewed-on: https://go-review.googlesource.com/18262
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 14:38:33 +00:00
Kevin Vu
aaabe3d849 cmd/compile/internal/gc: fix initialization logic
Also add relevant test.

Fixes #13343.

Change-Id: Ib1e65af1d643d501de89adee3618eddbf6c69c9e
Reviewed-on: https://go-review.googlesource.com/18159
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-06 02:10:52 +00:00
Tamir Duberstein
7e24e89944 cmd/dist: correct run's comment
Change-Id: I45b026f4b4bf23b222a81669280cbe245048022b
Reviewed-on: https://go-review.googlesource.com/18212
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-06 02:02:07 +00:00
Michael Hudson-Doyle
ae8e55860b cmd/go: special case shared library name when passed "$prefix/..."
Before golang.org/cl/13921, "go install -buildmode=shared prefix/..." created a
file called "libprefix.so", which was obviously a problem when prefix was
something like "." or "../".  However, now it expands the ... into all the
matched packages, joins them with -, which can clearly be a very long name
indeed. Because I plan to build shared libraries for Ubuntu by running commands
exactly like "go install -buildmode=shared prefix/...", this special cases this
to produce the old behaviour (but de-relativises prefix first).

Fixes #13714

Change-Id: I4fd8d4934279f9a18cc70a13e4ef3e23f6abcb6e
Reviewed-on: https://go-review.googlesource.com/18114
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-06 01:46:39 +00:00
Keith Randall
d7ad7b9efe [dev.ssa] cmd/compile: zero register masks for each edge
Forgot to reset these masks before each merge edge is processed.

Change-Id: I2f593189b63f50a1cd12b2dd4645ca7b9614f1f3
Reviewed-on: https://go-review.googlesource.com/18223
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
2016-01-05 20:20:18 +00:00
David Chase
ab5d2bf92f cmd/compile: suppress export of Note field within exported bodies
Added a format option to inhibit output of .Note field in
printing, and enabled that option during export.
Added test.

Fixes #13777.

Change-Id: I739f9785eb040f2fecbeb96d5a9ceb8c1ca0f772
Reviewed-on: https://go-review.googlesource.com/18217
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2016-01-05 15:42:12 +00:00
Russ Cox
906f979119 cmd/dist: wait for pending tests before exiting
When 'go tool dist test' stops, it was intended that it first wait for
pending background tests, like a failed compilation waits for pending
background compiles. But these three lines prevented that.
Fix by deleting them. (The actual loop already contains the correct
logic to avoid running the others and to wait for what's left.)

Change-Id: I4e945495ada903fb0af567910626241bc1c52ba6
Reviewed-on: https://go-review.googlesource.com/18232
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-05 14:18:38 +00:00
Matthew Dempsky
66f1f89dc0 cmd/internal/obj: fix PCSP table at runtime.morestack calls
Fixes #13346.

Change-Id: Ic903ee90575e8dbe23905d0678d3295745d1d47f
Reviewed-on: https://go-review.googlesource.com/18154
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-05 01:48:31 +00:00
Aaron Jacobs
6c8a141a6d cmd/go: update out of date help text about vendoring
Change-Id: I2b61f3b3ecf28d8f6a8dff94d194b6d3d450ea22
Reviewed-on: https://go-review.googlesource.com/17996
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-04 20:50:18 +00:00
Russ Cox
83746fd55a cmd/link: use current GOROOT for source file paths for standard library
This CL changes the source file information in the
standard library's .a files to say "$GOROOT/src/runtime/chan.go"
(with a literal "$GOROOT") instead of spelling out the actual directory.
The linker then substitutes the actual $GOROOT (or $GOROOT_FINAL)
as appropriate.

If people download a binary distribution to an alternate location,
following the instructions at https://golang.org/doc/install#install,
the code before this CL would end up with source paths pointing to
/usr/local/go no matter where the actual sources were.
Now the source paths for built binaries will point to the actual sources
(hopefully).

The source line information in distributed binaries is not affected:
those will still say /usr/local/go. But binaries people build themselves
(their own programs, not the go distribution programs) will be correct.

Fixing this path also fixes the lookup of the runtime-gdb.py file.

Fixes #5533.

Change-Id: I03729baae3fbd8cd636e016275ee5ad2606e4663
Reviewed-on: https://go-review.googlesource.com/18200
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-04 20:09:57 +00:00
Russ Cox
f034ee8c22 cmd/dist: apply final edits from CL 18199.
I broke the rule: never click the Submit button on the web.

Change-Id: If81a5cc31c1f28664960bad124cc596f5cab1222
Reviewed-on: https://go-review.googlesource.com/18203
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-29 17:25:06 +00:00
Russ Cox
d513ee774c cmd/dist: run shards of test dir in parallel
Saves 15 seconds from all.bash on my laptop (3:20 -> 3:05).

Change-Id: Ic5dc3c7804e78b584789dd856a3dada94000a8e2
Reviewed-on: https://go-review.googlesource.com/18199
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-29 17:18:04 +00:00
Russ Cox
b6473ff132 cmd/dist: run wiki, shootout etc tests only on builders
These find approximately nothing.
Takes 5% off my all.bash run time.

For #10571.

Change-Id: I21d3a844af756eb37f59bba0064f24995626da0d
Reviewed-on: https://go-review.googlesource.com/18198
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-29 16:26:50 +00:00
Russ Cox
baa928a782 cmd/dist: run various one-off tests in parallel
Takes 15% off my all.bash run time
(after this and earlier CLs, now down to 3½ from 5½ minutes).

For #10571.

Change-Id: Iac316ffb730c9ff0a0faa7cc3b82ed4f7e6d4361
Reviewed-on: https://go-review.googlesource.com/18088
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-29 15:50:04 +00:00
Russ Cox
f41378e225 cmd/dist: run limited tests in race and libgcc=none modes
Mostly we just care that the test binaries link and start up.
No need to run the full test suites.

Takes 12% off my all.bash run time.

For #10571.

Change-Id: I01af618f3d51deb841ea638424e1389a2df7d746
Reviewed-on: https://go-review.googlesource.com/18086
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-12-29 15:48:04 +00:00
Russ Cox
f70f277875 cmd/dist: make test default to --no-rebuild
I'm tired of having to remember it on every command.
Rebuilding everything is the wrong default.

This CL updates the build script, but the builders may
(or may not) need work, depending on whether they
rebuild using the test command (I doubt it).

Change-Id: I21f202a2f13e73df3f6bd54ae6a317c467b68151
Reviewed-on: https://go-review.googlesource.com/18084
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-29 15:20:00 +00:00
Keith Randall
7d9f1067d1 [dev.ssa] cmd/compile: better register allocator
Reorder how register & stack allocation is done.  We used to allocate
registers, then fix up merge edges, then allocate stack slots.  This
lead to lots of unnecessary copies on merge edges:

v2 = LoadReg v1
v3 = StoreReg v2

If v1 and v3 are allocated to the same stack slot, then this code is
unnecessary.  But at regalloc time we didn't know the homes of v1 and
v3.

To fix this problem, allocate all the stack slots before fixing up the
merge edges.  That way, we know what stack slots values use so we know
what copies are required.

Use a good technique for shuffling values around on merge edges.

Improves performance of the go1 TimeParse benchmark by ~12%

Change-Id: I731f43e4ff1a7e0dc4cd4aa428fcdb97812b86fa
Reviewed-on: https://go-review.googlesource.com/17915
Reviewed-by: David Chase <drchase@google.com>
2015-12-21 23:12:05 +00:00
Robert Griesemer
d6a203ecab cmd/compile: const name and label name may match
Fixes #13684.

Change-Id: I3977119b6eb1d6b7dc2ea1e7d6656a8f0d421bc1
Reviewed-on: https://go-review.googlesource.com/18060
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-12-21 20:21:28 +00:00
Russ Cox
5b085482ae cmd/go: ignore XML errors after Go <meta> tags
Fixes #13683.

Change-Id: I26afb3ac346beb95624f9032d94a29b5bc7853ef
Reviewed-on: https://go-review.googlesource.com/18051
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-18 19:51:06 +00:00
Russ Cox
ab74f5944e cmd/go: do not skip dirs with syntax errors in wildcard matching (like ./...)
Fixes #11407.

Change-Id: If35a8e04a3abf8acf955250c909dde57131b6bb8
Reviewed-on: https://go-review.googlesource.com/17971
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-18 17:21:29 +00:00
Ian Lance Taylor
ebf64bcc24 cmd/vet: add some checks for invalid pointer passing using cgo
Update #12416.

Change-Id: I21d97cbe211ccc8048e5a78ea4d89664f4d195ba
Reviewed-on: https://go-review.googlesource.com/17041
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-18 00:31:21 +00:00
Keith Randall
5b355a7907 [dev.ssa] cmd/compile: change ssa compilation trigger
We used to compile everything with SSA and then decide whether
to use the result or not.  It was useful when we were working
on coverage without much regard for correctness, but not so much now.

Instead, let's decide what we're going to compile and go through
the SSA compiler for only those functions.

TODO: next CL: get rid of all the UnimplementedF stuff.

Change-Id: If629addd8b62cd38ef553fd5d835114137885ce0
Reviewed-on: https://go-review.googlesource.com/17763
Reviewed-by: David Chase <drchase@google.com>
2015-12-18 00:02:16 +00:00
Brad Fitzpatrick
8db371b3d5 api: create go1.6.txt
Change-Id: If2b30ab412d6799c8be01eb007462d6b58660ece
Reviewed-on: https://go-review.googlesource.com/18014
Reviewed-by: Chris Broadfoot <cbro@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-17 22:45:50 +00:00
Russ Cox
c7b1ef9918 cmd/link: reject non-package main toplevel.a file, remove dead code
The test for non-package main top-level inputs is done while parsing
the export data. Issue #13468 happened because we were not parsing
the export data when using compiler-generated archives
(that is, when using go tool compile -pack).

Fix this by parsing the export data even for archives.

However, that turns up a different problem: the export data check
reports (one assumes spurious) skew errors now, because it has
not been run since Go 1.2.
(Go 1.3 was the first release to use go tool compile -pack.)

Since the code hasn't run since Go 1.2, it can't be that important.
Since it doesn't work today, just delete it.

Figuring out how to make this code work with Robert's export
format was one of the largest remaining TODOs for that format.
Now we don't have to.

Fixes #13468 and makes the world a better place.

Change-Id: I40a4b284cf140d49d48b714bd80762d6889acdb9
Reviewed-on: https://go-review.googlesource.com/17976
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-12-17 20:59:51 +00:00
Russ Cox
2f08bd96a0 cmd/go: for go get -insecure, do not fall back to HTTP for non-200 responses
Since we allow non-200 responses from HTTPS in normal operation,
it seems odd to reject them in -insecure operation.

Fixes #13037 (again).

Change-Id: Ie232f7544ab192addfad407525888db6b967befe
Reviewed-on: https://go-review.googlesource.com/17945
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 20:28:14 +00:00
Russ Cox
a227351b62 cmd/go: fix processing of HTTPS 404 without -insecure
The change here is to move the closeBody call into the if block.
The logging adjustments are just arranging to tell the truth:
in particular if we're not in insecure mode and we get a non-200
error then we do not actually ignore the response
(except as caused by closing the body incorrectly).

As the comment below the change indicates, it is intentional that
we process non-200 pages. The code does process them, because
the if err != nil || status != 200 block does not return.
But that block does close the body, which depending on timing
can apparently poison the later read from the body.

See #13037's initial report:

	$ go get -v bosun.org/cmd/bosun/cache
	Fetching https://bosun.org/cmd/bosun/cache?go-get=1
	ignoring https fetch with status code 404
	Parsing meta tags from https://bosun.org/cmd/bosun/cache?go-get=1 (status code 404)
	import "bosun.org/cmd/bosun/cache": parsing bosun.org/cmd/bosun/cache: http: read on closed response body
	package bosun.org/cmd/bosun/cache: unrecognized import path "bosun.org/cmd/bosun/cache"

The log print about ignoring the https fetch is not strictly true,
since the next thing that happened was parsing the body of that fetch.
But the read on the closed response body failed during parsing.

Moving the closeBody to happen only when we're about to discard the
result and start over (that is, only in -insecure mode) fixes the parse.

At least it should fix the parse. I can't seem to break the parse anymore,
because of #13648 (close not barring future reads anymore),
but this way is clearly better than the old way. If nothing else the old code
closed the body twice when err != nil and -insecure was not given.

Fixes #13037.

Change-Id: Idf57eceb6d5518341a2f7f75eb8f8ab27ed4e0b4
Reviewed-on: https://go-review.googlesource.com/17944
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 20:28:00 +00:00
Russ Cox
9f0055a232 Revert "cmd/go: allow omitted user name in git ssh repo syntax"
This caused #13657.
Reverting fixes #13657.

I was trying to be helpful by fixing #12313,
but I don't need the fix myself.
Will leave for someone with more motivation.

This reverts commit 3e9f063670.

Change-Id: Ifc78a6196f23e0f58e3b9ad7340e207a2d5de0a6
Reviewed-on: https://go-review.googlesource.com/17977
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 20:25:42 +00:00
Russ Cox
761ac75a94 cmd/go: fix git submodule fetch
Thanks to @toxeus on GitHub for the test case.

Fixes #12612.

Change-Id: I0c32fbe5044f3552053460a5347c062568093dff
Reviewed-on: https://go-review.googlesource.com/17974
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 20:18:18 +00:00
Ian Lance Taylor
54977cd3de cmd/go: runtime and runtime/internal packages depend on runtime/internal/sys
Fixes #13655.

Change-Id: I764019aecdd59743baa436b7339499e6c2126268
Reviewed-on: https://go-review.googlesource.com/17916
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 19:37:18 +00:00
Russ Cox
0cb68acea2 cmd/go: respect umask when creating executables
Also update many call sites where I forgot that the permission
argument is going to be masked by umask.

Fixes #12692.

Change-Id: I52b315b06236122ca020950447863fa396b68abd
Reviewed-on: https://go-review.googlesource.com/17950
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 19:24:06 +00:00
Russ Cox
0d641c754f cmd/go: allow ~ as first char of path element in general git import paths
This makes go get gitserver/~user/repo.git/foo work.

Fixes #9193.

Change-Id: I8c9d4096903288f7f0e82d6ed1aa78bf038fb81a
Reviewed-on: https://go-review.googlesource.com/17952
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:13:03 +00:00
Russ Cox
06b46c0d9c cmd/go: don't be clever about mtime precision in test
This doesn't happen enough in the tests to be worth debugging.
Empirically, I expect this to add 5 seconds to the overall 'go test -short cmd/go'
on systems with precise file systems, and nothing on systems without them
(like my Mac).

Fixes #12205.

Change-Id: I0a17cb37bdedcfc0f921c5ee658737f1698c153b
Reviewed-on: https://go-review.googlesource.com/17953
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 17:06:15 +00:00
Russ Cox
e357eb97a6 cmd/go: document that package documentation is ignored
Fixes #11801.

Change-Id: I2caeac7fdddc7f29015d6db8d4b3e296c8b9c423
Reviewed-on: https://go-review.googlesource.com/17954
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:04:55 +00:00
Russ Cox
3e9f063670 cmd/go: allow omitted user name in git ssh repo syntax
No test because the code has no test.

Fixes #12313.

Change-Id: I2cfd0a0422c0cd76f0371c2d3bbbdf5bb3b3f1eb
Reviewed-on: https://go-review.googlesource.com/17951
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:01:05 +00:00
Russ Cox
f9137c5373 cmd/go: document that tests run in the source directory
Fixes #13538.

Change-Id: I621bbe2befe838d16d3664d7a5e30d5d7cceae33
Reviewed-on: https://go-review.googlesource.com/17949
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:00:37 +00:00
Russ Cox
f474885f8a cmd/go: document where get writes, and not vendor directories
Fixes #12260.

Change-Id: I95c27aad6de8064b9a205d4ee507bce75926f16d
Reviewed-on: https://go-review.googlesource.com/17948
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:00:02 +00:00
Russ Cox
8fac7e3cc7 cmd/go: document that go generate accepts all build flags
Fixes #12544.

Change-Id: I5e2fd1fbb21816e9f6fb022e2664484a71093b04
Reviewed-on: https://go-review.googlesource.com/17947
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 16:59:46 +00:00
Russ Cox
0a0f8bae27 cmd/go: document that -p applies to test binary execution
Fixes #11521.

Change-Id: I73615b881df4a0d5e2f5bc5059359d150ca8c105
Reviewed-on: https://go-review.googlesource.com/17946
Reviewed-by: Joe Shaw <joe@joeshaw.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 16:59:30 +00:00
Brad Fitzpatrick
7688f0d9fb cmd/pprof: fix scaling of "gigabyte" unit
Fixes #13654

Change-Id: Id2ce32c52efcfdbd66630725d62d2ca6bf0916d5
Reviewed-on: https://go-review.googlesource.com/17934
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 16:38:28 +00:00
Russ Cox
70cee781fc cmd/go: use tags when evaluating file system wildcards like ./...
Thanks to Albert Hafvenström for the diagnosis.

Fixes #11246.

Change-Id: I2b9e670c0ecf6aa01e5bf4d7a402619e93cc4f4a
Reviewed-on: https://go-review.googlesource.com/17942
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 05:46:29 +00:00
Russ Cox
37f2afa625 cmd/go: disable use of -linkmode=external in tests when CGO_ENABLED=0
If cgo is turned off, there may not be an external linker available.

Fixes #13450.

Change-Id: Idbf3f3f57b4bb3908b67264f96d276acc952102a
Reviewed-on: https://go-review.googlesource.com/17941
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 05:46:21 +00:00
Russ Cox
4378746a4b cmd/dist: show output from failed compiler execution
Maybe it will say something that helps the user understand the problem.

Note that we can't use os/exec.ExitError's new Stderr field because
cmd/dist is compiled with Go 1.4.

Fixes #13099.

Change-Id: I4b5910434bf324d1b85107002a64684d8ba14dc8
Reviewed-on: https://go-review.googlesource.com/17940
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 03:14:11 +00:00