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

7932 Commits

Author SHA1 Message Date
Alexandru Moșoi
a7a199947a cmd/compile: add rules to simplify AddPtr
Fixes #14849

Change-Id: I86e2dc27ca73bb6b24261a68cbf0094a63167414
Reviewed-on: https://go-review.googlesource.com/20833
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 20:57:28 +00:00
Ian Lance Taylor
a9407b5797 cmd/compile: fix varexpr handling of ODOT
For a long time varexpr has handled ODOT incorrectly: it has always
returned false.  Before https://golang.org/cl/20890 this has been
because an ODOT had a Right field with an ONAME with no Class, for which
varexpr returns false.  CL 20890 preserved the behavior of varexpr for
ODOT, so that the change would pass toolstash -cmp.

This CL fixes varexpr so that ODOT can return true in some cases.  This
breaks toolstash -cmp.  While the changed compiler allocates temporary
variables in a different order, I have not been able to find any
examples where the generated code is different, other than using
different stack offsets and, in some cases, registers.  It seems that
other parts of the compiler will force the ODOT into a temporary anyhow.

Still, this change is clearly correct, and is a minor compiler cleanup.

Change-Id: I71506877aa3c13966bb03c281aa16271ee7fe80a
Reviewed-on: https://go-review.googlesource.com/20907
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 18:28:09 +00:00
Shahar Kohanim
93098de0cc cmd/link: patch up symbols only once per object file
name       old s/op   new s/op   delta
LinkCmdGo  0.57 ± 5%  0.55 ± 6%  -2.37%  (p=0.000 n=97+98)

GOGC=off:

name       old s/op   new s/op   delta
LinkCmdGo  0.48 ± 3%  0.47 ± 3%  -2.90%  (p=0.000 n=100+100)

Change-Id: I1a36dbf84914cacb79842bc0ddb1e26b4c5a5828
Reviewed-on: https://go-review.googlesource.com/20917
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 17:36:30 +00:00
Ian Lance Taylor
060038bdd0 cmd/compile: don't penalize ODOT and friends when inlining
Historically ODOT and friends have been considered to cost an extra
budget point when deciding whether they should be inlined, because they
had an ONAME node that represented the name to the right of the dot.
This doesn't really make sense, as in general that symbol does not add
any extra instructions; it just affects the offset of the load or store
instruction.  And the ONAME node is gone now.  So, remove the extra
cost.

This does not pass toolstash -cmp, as it changes inlining decisions.
For example, mspan.init in runtime/mheap.go is now considered to be an
inlining candidate.

Change-Id: I5ad27f08c66fd5daa4c8472dd0795df989183f5e
Reviewed-on: https://go-review.googlesource.com/20891
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 17:25:02 +00:00
Shahar Kohanim
d6d33f678d cmd/link: use encbuf when writing integers
name       old s/op   new s/op   delta
LinkCmdGo  0.59 ± 6%  0.58 ± 5%  -1.61%  (p=0.000 n=99+99)

GOGC=off:
name       old s/op   new s/op   delta
LinkCmdGo  0.50 ± 3%  0.49 ± 3%  -1.28%  (p=0.000 n=98+99)

Change-Id: I737ae056214999441a210c69ec0cf4febc39a715
Reviewed-on: https://go-review.googlesource.com/20914
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 14:34:33 +00:00
Shahar Kohanim
78fc59ef42 cmd/compile, cmd/link: remove unused fields from relocations
Reduces size of archives in pkg/linux_amd64 by 3% from 41.5MB to 40.2MB

Change-Id: Id64ca7995de8dd84c9e7ce1985730927cf4bfd66
Reviewed-on: https://go-review.googlesource.com/20912
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-20 13:44:31 +00:00
Shahar Kohanim
3504945081 cmd/link: optimize int parsing
Speeds up linking cmd/go by ~1.5%:

name       old s/op   new s/op   delta
LinkCmdGo  0.58 ± 6%  0.57 ± 5%  -1.21%  (p=0.000 n=98+99)

Less noisy benchmark, with garbage collection off:

name       old s/op   new s/op   delta
LinkCmdGo  0.49 ± 2%  0.49 ± 2%  -1.79%  (p=0.000 n=98+99)

Change-Id: I0123bcb66a87cbc4d703356e4c5a4035032012ec
Reviewed-on: https://go-review.googlesource.com/20916
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 13:10:33 +00:00
Matthew Dempsky
3eaa304629 cmd/compile: ignore receiver name when checking duplicate methods
In golang.org/cl/20602, I changed the semantics of Eqtype to stop
checking the receiver parameters for type equality, and pushed this
responsibility to addmethod (the only Eqtype caller that cared).
However, I accidentally made the check stricter by making it start
requiring that receiver names were identical.

In general, this is a non-problem because the receiver names in export
data will always match the original source. But running
GO_GCFLAGS=-newexport ./all.bash at one point tries to load both old
and new format export data for package sync, which reveals the
problem. (See golang.org/issue/14877 for details.)

Easy fix: just check the receiver type for type equality in addmethod,
instead of the entire receiver parameter list.

Fixes #14877.

Change-Id: If10b79f66ba58a1b7774622b4fbad1916aba32f1
Reviewed-on: https://go-review.googlesource.com/20906
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-20 04:37:04 +00:00
Josh Bleecher Snyder
ec7c494535 cmd/compile: remove typechecklist
Convert remaining uses to typecheckslice.

Passes toolstash -cmp.

Change-Id: I6ed0877386fb6c0b036e8ee5a228433343855abd
Reviewed-on: https://go-review.googlesource.com/20905
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 00:34:42 +00:00
Josh Bleecher Snyder
ad4c55c076 cmd/compile: convert fmt.Sprintf to concatenation
There are plenty more, but these cover most of
the trivial cases, and all the cases that
showed up in profiling.

name       old time/op     new time/op     delta
Template       331ms ± 3%      327ms ± 6%    ~           (p=0.143 n=10+10)
Unicode        183ms ± 4%      180ms ± 2%    ~             (p=0.114 n=9+8)
GoTypes        1.12s ± 4%      1.07s ± 1%  -4.34%         (p=0.000 n=10+9)
Compiler       5.16s ± 2%      5.04s ± 2%  -2.24%         (p=0.001 n=10+9)
MakeBash       41.7s ± 2%      42.3s ± 1%  +1.51%        (p=0.000 n=10+10)

name       old alloc/op    new alloc/op    delta
Template      63.4MB ± 0%     63.1MB ± 0%  -0.42%        (p=0.000 n=10+10)
Unicode       43.2MB ± 0%     43.1MB ± 0%  -0.22%         (p=0.000 n=9+10)
GoTypes        220MB ± 0%      219MB ± 0%  -0.57%         (p=0.000 n=8+10)
Compiler       978MB ± 0%      975MB ± 0%  -0.30%        (p=0.000 n=10+10)

name       old allocs/op   new allocs/op   delta
Template        702k ± 0%       686k ± 0%  -2.35%        (p=0.000 n=10+10)
Unicode         548k ± 0%       542k ± 0%  -1.09%        (p=0.000 n=10+10)
GoTypes        2.17M ± 0%      2.09M ± 0%  -3.61%        (p=0.000 n=10+10)
Compiler       9.33M ± 0%      9.15M ± 0%  -1.93%        (p=0.000 n=10+10)

Change-Id: I3a3d7f2d56876427b04cfedc7302d7f496d5bb65
Reviewed-on: https://go-review.googlesource.com/20904
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 00:17:30 +00:00
Keith Randall
8dc04cbedc cmd/compile: enforce 32-bit restrictions on ops
Most 64-bit x86 ops can only take a signed 32-bit constant.
Clean up our rewrite rules to enforce this restriction.

Modify the assembler to fail if the offset does not fit
in the instruction.

That last check triggers a few times on weird testing code.
Suppress those errors if the compiler itself generated errors.

Fixes #14862

Change-Id: I76559af035b38483b1e59621a8029fc66b3a5d1e
Reviewed-on: https://go-review.googlesource.com/20815
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-03-20 00:12:47 +00:00
Ian Lance Taylor
5f525ca60d cmd/compile: change ODOT and friends to use Sym, not Right
The Node type ODOT and its variants all represent a selector, with a
simple name to the right of the dot.  Before this change this was
represented by using an ONAME Node in the Right field.  This ONAME node
served no useful purpose.  This CL changes these Node types to store the
symbol in the Sym field instead, thus not requiring allocating a Node
for each selector.

When compiling x/tools/go/types this CL eliminates nearly 5000 calls to
newname and reduces the total number of Nodes allocated by about 6.6%.
It seems to cut compilation time by 1 to 2 percent.

Getting this right was somewhat subtle, and I added two dubious changes
to produce the exact same output as before.  One is to ishairy in
inl.go: the ONAME node increased the cost of ODOT and friends by 1, and
I retained that, although really ODOT is not more expensive than any
other node.  The other is to varexpr in walk.go: because the ONAME in
the Right field of an ODOT has no class, varexpr would always return
false for an ODOT, although in fact for some ODOT's it seemingly ought
to return true; I added an && false for now.  I will send separate CLs,
that will break toolstash -cmp, to clean these up.

This CL passes toolstash -cmp.

Change-Id: I4af8a10cc59078c436130ce472f25abc3a9b2f80
Reviewed-on: https://go-review.googlesource.com/20890
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-19 00:45:09 +00:00
Todd Neal
fc6bcdee79 cmd/compile: allow inlining of functions that declare a const
Consider functions with an ODCLCONST for inlining and modify exprfmt to
ignore those nodes when exporting. Don't add symbols to the export list
if there is no definition.  This occurs when OLITERAL symbols are looked
up via Pkglookup for non-exported symbols.

Fixes #7655

Change-Id: I1de827850f4c69e58107447314fe7433e378e069
Reviewed-on: https://go-review.googlesource.com/20773
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-18 23:26:36 +00:00
Keith Randall
3dd4f74e06 cmd/compile: merge shifts into LEAs
Change-Id: I5a43c354f36184ae64a52268023c3222da3026d8
Reviewed-on: https://go-review.googlesource.com/20880
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-18 23:08:24 +00:00
David Chase
982322769c cmd/dist: redo flag-passing for bootstrap
This ought to revert the bad effects of
https://go-review.googlesource.com/#/c/20775/
If you don't pass BOOT_GO_GCFLAGS, you get the
old behavior.

Tweaked to allow multiple space-separated flags in
BOOT_GO_GCFLAGS.

Change-Id: I2a22a04211b4535d1c5a8ec7a8a78cb051161c31
Reviewed-on: https://go-review.googlesource.com/20871
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 19:00:03 +00:00
Alan Donovan
a5cd53a9fd cmd/compile/internal/gc: support invalid types/constants in binary export data
(Corresponding x/tools/go/gcimporter change is https://go-review.googlesource.com/#/c/20827/)

Change-Id: I64e7fee2e273d387f1c51b87986294489978d250
Reviewed-on: https://go-review.googlesource.com/20828
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-18 16:33:38 +00:00
Todd Neal
b2dc1f82a5 cmd/compile: perform minimal phi elimination during critical
Phi splitting sometimes leads to a phi with only a single predecessor.
This must be replaced with a copy to maintain a valid SSA form.

Fixes #14857

Change-Id: I5ab2423fb6c85a061928e3206b02185ea8c79cd7
Reviewed-on: https://go-review.googlesource.com/20826
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-18 15:35:49 +00:00
David Chase
815c9a7f28 cmd/compile: use loop information in regalloc
This seems to help the problem reported in #14606; this
change seems to produce about a 4% improvement (mostly
for the 128-8192 shards).

Fixes #14789.

Change-Id: I1bd52c82d4ca81d9d5e9ab371fdfc860d7e8af50
Reviewed-on: https://go-review.googlesource.com/20660
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-18 01:23:29 +00:00
Christopher Nelson
e4d489a85f cmd/go: fix TestShadowingLogic fails when GOROOT path has spaces
Improve the test by also translating " " to "_".

Fixes #14671.

Change-Id: Ie5997934b93c7663d7b8432244fad47bb5d3ffbe
Reviewed-on: https://go-review.googlesource.com/20714
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-18 01:12:06 +00:00
David Chase
09a9ce60c7 cmd/compile: get gcflags to bootstrap; ssa debug opts for "all"
This is intended to help debug compiler problems that pop
up in the bootstrap phase of make.bash.  GO_GCFLAGS does not
normally apply there.  Options-for-all phases is intended
to allow crude tracing (and full timing) by turning on timing
for all phases, not just one.

Phase names can also be specified using a regular expression,
for example
BOOT_GO_GCFLAGS=-d='ssa/~^.*scc$/off' \
GO_GCFLAGS='-d=ssa/~^.*scc$/off' ./make.bash

I just added this because it was the fastest way to get
me to a place where I could easily debug the compiler.

Change-Id: I0781f3e7c19651ae7452fa25c2d54c9a245ef62d
Reviewed-on: https://go-review.googlesource.com/20775
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-18 01:04:47 +00:00
Todd Neal
2cc42cf2a8 cmd/compile/test: replace switch{} with go:noinline
Change-Id: Ic40449b2e4b4f18cbe5b5d4c3d51ea7b05ac674d
Reviewed-on: https://go-review.googlesource.com/20823
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-17 23:49:35 +00:00
Hyang-Ah Hana Kim
50487b2c8d cmd/pack,vet: use go doc instead of godoc in doc
Change-Id: Ic5f62a7d0a5c090da69213d1d0187af0ea48e358
Reviewed-on: https://go-review.googlesource.com/20820
Reviewed-by: Rob Pike <r@golang.org>
2016-03-17 21:06:40 +00:00
David Chase
3a17fdaba0 cmd/compile: correct maintain use count when phi args merge
The critical phase did not correctly maintain the use count
when two predecessors of a new critical block transmit the
same value.

Change-Id: Iba802c98ebb84e36a410721ec32c867140efb6d4
Reviewed-on: https://go-review.googlesource.com/20822
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-17 20:55:13 +00:00
Matthew Dempsky
dbed1c6361 cmd/compile: eliminate NumFields wrapper functions
Change-Id: I3c6035559288cfdc33857216f50241b81932c8a4
Reviewed-on: https://go-review.googlesource.com/20811
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-17 20:43:18 +00:00
Keith Randall
15ed37d7b7 cmd/compile: enforce nowritebarrier in SSA compiler
Make sure we don't generate write barriers in runtime
code that is marked to forbid write barriers.

Implement the optimization that if we're writing a sliced
slice back to the location it came from, we don't need a
write barrier.

Fixes #14784

Change-Id: I04b6a3b2ac303c19817e932a36a3b006de103aaa
Reviewed-on: https://go-review.googlesource.com/20791
Reviewed-by: Austin Clements <austin@google.com>
2016-03-17 20:13:24 +00:00
Shahar Kohanim
16029babe2 cmd/compile: deduplicate symbol references
Reduces size of archives in pkg/linux_amd64 by 1.4MB (3.2%),
slightly improving link time.

name       old s/op   new s/op   delta
LinkCmdGo  0.52 ± 3%  0.51 ± 2%  -0.65%  (p=0.000 n=98+99)

Change-Id: I7e265f4d4dd08967c5c5d55c1045e533466bbbec
Reviewed-on: https://go-review.googlesource.com/20802
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-17 20:09:40 +00:00
Ingo Oeser
2d03b5b572 cmd/compile: fix comment
Change-Id: I32fd5c36f055fdb1dfe56524085676aa4111089a
Reviewed-on: https://go-review.googlesource.com/20830
Reviewed-by: David Chase <drchase@google.com>
2016-03-17 19:45:30 +00:00
Matthew Dempsky
c837761b52 cmd/compile: get rid of Type's {This,In,Out}tuple fields
Boolean expressions involving t.Thistuple were converted to use
t.Recv(), because it's a bit clearer and will hopefully reveal cases
where we could remove redundant calls to t.Recv() (in followup CLs).

The other cases were all converted to use t.Recvs().NumFields(),
t.Params().NumFields(), or t.Results().NumFields().

Change-Id: I4df91762e7dc4b2ddae35995f8dd604a52c09b09
Reviewed-on: https://go-review.googlesource.com/20796
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2016-03-17 19:38:30 +00:00
Matthew Dempsky
d447613875 cmd/compile: simplify typehash
We never need a type hash for a method type, so skip trying to
overwrite Thistuple.

Change-Id: I8de6480ba5fd321dfa134facf7661461d298840e
Reviewed-on: https://go-review.googlesource.com/20795
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-17 19:38:21 +00:00
Matthew Dempsky
f6bca3f32d cmd/compile: eliminate a bunch of IterFields/IterMethods calls
This is an automated rewrite of all the calls of the form:

    for f, it := IterFields(t); f != nil; f = it.Next() { ... }

Followup CLs will work on cleaning up the remaining cases.

Change-Id: Ic1005ad45ae0b50c63e815e34e507e2d2644ba1a
Reviewed-on: https://go-review.googlesource.com/20794
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-17 19:38:15 +00:00
Matthew Dempsky
517b6131b2 cmd/compile: add and use new Fields type
Analogous to the Nodes type used as a more space efficient []*Node
representation.

Passes toolstash -cmp.

Change-Id: I8341e45304777d6e4200bd36dadc935b07ccf3ff
Reviewed-on: https://go-review.googlesource.com/20793
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-17 19:37:14 +00:00
Matthew Dempsky
ac74e5debc cmd/compile: stop constructing sudog type
The compiler doesn't care about the runtime's sudog type. Stop
constructing it.

Change-Id: If1885fe30b2e215a08d17662eab5ea6d81fe58ab
Reviewed-on: https://go-review.googlesource.com/20797
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2016-03-17 18:02:40 +00:00
Ian Lance Taylor
65b4020403 cmd/compile: don't create 2 Sym's and 2 Node's for every string
For every string constant the compiler was creating 2 Sym's and 2
Node's.  It would never refer to them again, but would keep them alive
in gostringpkg.  This changes the code to just use obj.LSym's instead.

When compiling x/tools/go/types, this yields about a 15% reduction in
the number of calls to newname and a 3% reduction in the total number of
Node objects.  Unfortunately I couldn't see any change in compile time,
but reducing memory usage is desirable anyhow.

Passes toolstash -cmp.

Change-Id: I24f1cb1e6cff0a3afba4ca66f7166874917a036b
Reviewed-on: https://go-review.googlesource.com/20792
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-17 16:15:11 +00:00
David Chase
2d56dee61b cmd/compile: escape analysis explanations added to -m -m output
This should probably be considered "experimental" at this stage, but
what it needs is feedback from adventurous adopters.  I think the data
structure used for describing escape reasons might be extendable to
allow a cleanup of the underlying algorithms, which suffers from
insufficiently separated concerns (the graph does not deal well with
escape level adjustments, so it is augmented by a second custom-walk
portion of the "flood" phase. It would be better to put it all,
including level adjustments, in a single graph structure, and then
simply flood the graph.

Tweaked to avoid allocations in the no-logging case.

Modified run.go to ignore lines with leading "#" in the output (since
it can never match a line), and in -update_errors to ignore leading
tabs in output lines and to normalize embedded filenames.

Currently requires -m -m because otherwise the noise/update
burden for the other escape tests is considerable.

There is a partial test.  Existing escape analysis tests seem to
cover all except the panic case and what looks like it might be
unreachable code in escape analysis.

Fixes #10526.

Change-Id: I2524fdec54facae48b00b2548e25d9e46fcaf832
Reviewed-on: https://go-review.googlesource.com/18041
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-17 13:29:48 +00:00
Todd Neal
50bc546d43 cmd/compile: reuse blocks in critical pass
If a phi has duplicate arguments, then the new block that is constructed
to remove the critical edge can be used for all of the duplicate
arguments.

read-only data = -904 bytes (-0.058308%)
global text (code) = -2240 bytes (-0.060056%)
Total difference -3144 bytes (-0.056218%)

Change-Id: Iee3762744d6a8c9d26cdfa880bb23feb62b03c9c
Reviewed-on: https://go-review.googlesource.com/20746
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-17 12:12:34 +00:00
Keith Randall
56e0ecc5ea cmd/compile: keep value use counts in SSA
Keep track of how many uses each Value has.  Each appearance in
Value.Args and in Block.Control counts once.

The number of uses of a value is generically useful to
constrain rewrite rules.  For instance, we might want to
prevent merging index operations into loads if the same
index expression is used lots of times.

But I have one use in particular for which the use count is required.
We must make sure we don't combine ops with loads if the load has
more than one use.  Otherwise, we may split a single load
into multiple loads and that breaks perceived behavior in
the presence of races.  In particular, the load of m.state
in sync/mutex.go:Lock can't be done twice.  (I have a separate
CL which triggers the mutex failure.  This CL has a test which
demonstrates a similar failure.)

Change-Id: Icaafa479239f48632a069d0c3f624e6ebc6b1f0e
Reviewed-on: https://go-review.googlesource.com/20790
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-17 04:20:02 +00:00
Dave Cheney
cb1f2afc99 cmd/compile/internal/gc: disable logProgs debug flag
Spotted while splunking in the compiler with GOGC=off.

name       old time/op     new time/op     delta
Template       407ms ± 5%      402ms ± 6%     ~           (p=0.301 n=20+20)
GoTypes        1.33s ± 2%      1.29s ± 1%   -3.47%        (p=0.000 n=20+20)
Compiler       6.21s ± 1%      5.91s ± 2%   -4.83%        (p=0.000 n=20+20)

name       old alloc/op    new alloc/op    delta
Template      66.8MB ± 0%     63.9MB ± 0%   -4.46%        (p=0.000 n=19+20)
GoTypes        232MB ± 0%      220MB ± 0%   -5.16%        (p=0.000 n=19+17)
Compiler      1.02GB ± 0%     0.97GB ± 0%   -5.81%        (p=0.000 n=20+20)

name       old allocs/op   new allocs/op   delta
Template        789k ± 0%       708k ± 0%  -10.28%        (p=0.000 n=19+20)
GoTypes        2.49M ± 0%      2.20M ± 0%  -11.57%        (p=0.000 n=20+20)
Compiler       10.8M ± 0%       9.4M ± 0%  -12.82%        (p=0.000 n=20+20)

Change-Id: I76615cab912dde10595ca6ab9979ff6c5f1aec49
Reviewed-on: https://go-review.googlesource.com/20782
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-17 03:50:54 +00:00
Michael Hudson-Doyle
956e9e6c83 cmd/link: do not add duplicate symbols to Allsym
When building shared libraries, all symbols on Allsym are marked reachable.
What I didn't realize was that this includes the ".dup" symbols created when
"dupok" symbols are read from multiple package files. This breaks now because
deadcode makes some assumptions that fail for these ".dup" symbols, but in any
case was a bad idea -- I suspect this change makes libstd.so a bunch smaller,
but creating it was broken before this CL so I can't be sure.

This change simply stops adding these symbols to Allsym, which might make some
of the many iterations over Allsym the linker does a touch quicker, although
that's not the motivation here.

Add a test that no symbols called ".dup" makes it into the runtime shared
library.

Fixes #14841

Change-Id: I65dd6e88d150a770db2d01b75cfe5db5fd4f8d25
Reviewed-on: https://go-review.googlesource.com/20780
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-17 01:15:19 +00:00
Matthew Dempsky
b2b5e779f5 cmd/compile: ignore receiver parameters in Eqtype
Receiver parameters generally aren't relevant to the function
signature type. In particular:

  1. When checking whether a type's method implements an interface's
     method, we specifically want to ignore the receiver parameters,
     because they'll be different.

  2. When checking interface type equality, interface methods always
     use the same "fakethis" *struct{} type as their receiver.

  3. Finally, method expressions and method values degenerate into
     receiver-less function types.

The only case where we care about receiver types matching is in
addmethod, which is easily handled by adding an extra Eqtype check of
the receiver parameters. Also, added a test for this, since
(surprisingly) there weren't any.

As precedence, go/types.Identical ignores receiver parameters when
comparing go/types.Signature values.

Notably, this allows us to slightly simplify the "implements"
function, which is used for checking whether type/interface t
implements interface iface. Currently, cmd/compile actually works
around Eqtype's receiver parameter checking by creating new throwaway
TFUNC Types without the receiver parameter.

(Worse, the compiler currently only provides APIs to build TFUNC Types
from Nod syntax trees, so building those throwaway types also involves
first building throwaway syntax trees.)

Passes toolstash -cmp.

Change-Id: Ib07289c66feacee284e016bc312e8c5ff674714f
Reviewed-on: https://go-review.googlesource.com/20602
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-17 00:38:15 +00:00
Josh Bleecher Snyder
d33e37a7e3 cmd/compile: further sinit.go cleanup
Follow-up to CL 20674.

Passes toolstash -cmp.

Change-Id: I065fd4cd80d996c1e6566773189401ca4630c1ca
Reviewed-on: https://go-review.googlesource.com/20692
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-03-16 23:28:36 +00:00
Josh Bleecher Snyder
8262564971 cmd/internal/obj/x86: estimate text size
We can’t perfectly predict how large the function
will be, but we can make a safe overestimate.
No significant CPU time changes.

name       old alloc/op    new alloc/op    delta
Template      67.7MB ± 0%     67.5MB ± 0%   -0.24%          (p=0.029 n=4+4)
Unicode       43.9MB ± 0%     43.8MB ± 0%   -0.13%          (p=0.029 n=4+4)
GoTypes        244MB ± 0%      244MB ± 0%   -0.28%          (p=0.029 n=4+4)
Compiler      1.05GB ± 0%     1.05GB ± 0%   -0.38%          (p=0.029 n=4+4)

name       old allocs/op   new allocs/op   delta
Template        795k ± 0%       794k ± 0%   -0.14%          (p=0.029 n=4+4)
Unicode         569k ± 0%       569k ± 0%     ~             (p=0.114 n=4+4)
GoTypes        2.59M ± 0%      2.58M ± 0%   -0.11%          (p=0.029 n=4+4)
Compiler       11.0M ± 0%      11.0M ± 0%   -0.09%          (p=0.029 n=4+4)

Passes toolstash -cmp.

Change-Id: I0a92ab04cba7520540ec58fe7189666d0e771454
Reviewed-on: https://go-review.googlesource.com/20771
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2016-03-16 23:27:19 +00:00
Josh Bleecher Snyder
fb950cd778 cmd/internal/obj: convert Symgrow to a method
Passes toolstash -cmp.

Change-Id: I77a415a4e5d8de7eb902fb0866aaf8783259485a
Reviewed-on: https://go-review.googlesource.com/20770
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 23:25:33 +00:00
James Bardin
5a34472d74 cmd/cgo: add C.CBytes
Add a C.CBytes function to copy a Go byte slice into C memory. This
returns an unsafe.Pointer, since that is what needs to be passed to
C.free, and the data is often opaque bytes anyway.

Fixes #14838

Change-Id: Ic7bc29637eb6f1f5ee409b3898c702a59833a85a
Reviewed-on: https://go-review.googlesource.com/20762
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-16 23:22:10 +00:00
Austin Clements
3e54ca9a46 cmd/compile: omit write barrier when assigning global function
Currently we generate write barriers when the right side of an
assignment is a global function. This doesn't fall into the existing
case of storing an address of a global because we haven't lowered the
function to a pointer yet.

This write barrier is unnecessary, so eliminate it.

Fixes #13901.

Change-Id: Ibc10e00a8803db0fd75224b66ab94c3737842a79
Reviewed-on: https://go-review.googlesource.com/20772
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-16 22:42:45 +00:00
Josh Bleecher Snyder
4e75932cf7 cmd/compile: make sinit consts Go-ish
Passes toolstash -cmp.

Change-Id: Ie11912a16d2cd54500e2f6e84316519b80e7c304
Reviewed-on: https://go-review.googlesource.com/20672
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 22:21:02 +00:00
Josh Bleecher Snyder
e6ed3e8a46 cmd/internal/obj/x86: clean up asm buffer
c2go translated writing and advancing a pointer using slices.
Switch to something more idiomatic.
It is also more efficient, but not enough to matter.

Change-Id: I67709632ac53253615a35365824ae97bbe5458d5
Reviewed-on: https://go-review.googlesource.com/20767
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-16 21:57:15 +00:00
Josh Bleecher Snyder
e248b96d24 cmd/internal/obj/x86: clean up part of span6
Passes toolstash -cmp.

Change-Id: I38eb507de2e9dc2cf01822e420bf31a91fb1b720
Reviewed-on: https://go-review.googlesource.com/20766
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 21:56:57 +00:00
Robert Griesemer
c1a4fe8d57 cmd/compile: remove dead code handling '~' operator
The parser code was not reachable ever since some of the lexer cleanups.
We could recognize '~' in the lexer, complain, and return a '^' instead,
but it's been a few years since Go was new and this may have been a use-
ful error. The lexer complains with "illegal character U+007E '~'" which
is good enough.

For #13244.

Change-Id: Ie3283738486eb6f8462d594f2728ac98333c0520
Reviewed-on: https://go-review.googlesource.com/20768
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-16 21:39:49 +00:00
Josh Bleecher Snyder
826831acf7 cmd/compile: move LSym.RefIdx for better packing
Change-Id: I0516d49ee8381c5e022d77c2fb41515c01c8a631
Reviewed-on: https://go-review.googlesource.com/20764
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-16 20:52:33 +00:00
Josh Bleecher Snyder
31a9e50524 cmd/internal/obj: remove LSym.Etext
Use a local variable instead.

Passes toolstash -cmp.

Change-Id: I9623a40ff0d568f11afd1279b6aaa1c33eda644c
Reviewed-on: https://go-review.googlesource.com/20730
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-16 20:52:21 +00:00
Josh Bleecher Snyder
dd2ba0c7a7 cmd/internal/obj: remove LSym.Next
Instead, use a slice.

Passes toolstash -cmp.

Change-Id: I889fdb4ae997416f907522f549b96506be13bec7
Reviewed-on: https://go-review.googlesource.com/20699
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 20:40:58 +00:00
Josh Bleecher Snyder
61b9315d37 cmd/internal/obj: remove LSym.Value
It is unused.

Passes toolstash -cmp.

Change-Id: I22ae2bb432ce6be377dea43cf018ffccb6e95f37
Reviewed-on: https://go-review.googlesource.com/20698
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 20:40:50 +00:00
Austin Clements
26594c3dfd runtime: use indexes for select lock order
Currently the select lock order is a []*hchan. We're going to need to
refer to things other than the channel itself in lock order shortly,
so switch this to a []uint16 of indexes into the select cases. This
parallels the existing representation for the poll order.

Change-Id: I89262223fe20b4ddf5321592655ba9eac489cda1
Reviewed-on: https://go-review.googlesource.com/20036
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 20:13:05 +00:00
Austin Clements
e4a95b6343 runtime: record channel in sudog
Given a G, there's currently no way to find the channel it's blocking
on. We'll need this information to fix a (probably theoretical) bug in
select and to implement concurrent stack shrinking, so record the
channel in the sudog.

For #12967.

Change-Id: If8fb63a140f1d07175818824d08c0ebeec2bdf66
Reviewed-on: https://go-review.googlesource.com/20035
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 20:13:02 +00:00
Robert Griesemer
bb3b10214d cmd/compile: faster parameter parsing with no OKEY nodes
Step 2 of stream-lining parameter parsing

- do parameter validity checks in parser
- two passes instead of multiple (and theoretically quadratic) passes
  when checking parameters
- removes the need for OKEY and some ONONAME nodes in those passes

This removes allocation of ~123K OKEY (incl. some ONONAME) nodes
out of a total of ~10M allocated nodes when running make.bash, or
a reduction of the number of alloacted nodes by ~1.2%.

Change-Id: I4a8ec578d0ee2a7b99892ac6b92e56f8e0415f03
Reviewed-on: https://go-review.googlesource.com/20748
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
2016-03-16 18:54:31 +00:00
Robert Griesemer
9f301643bd cmd/compile: factor parameter parsing
Step 1 of streamlining parameter parsing.

Change-Id: If9fd38295ccc08aafc7f1d26188d0926dd73058b
Reviewed-on: https://go-review.googlesource.com/20747
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 15:56:36 +00:00
Todd Neal
c8b148e7a5 cmd/compile: fold constants from lsh/rsh/lsh and rsh/lsh/rsh
Fixes #14825

Change-Id: Ib44d80579a55c15d75ea2ad1ef54efa6ca66a9a6
Reviewed-on: https://go-review.googlesource.com/20745
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 11:40:20 +00:00
Aliaksandr Valialkin
fee86e4aa8 cmd/vet: added some missing copylock checks
Fixes #14664

Change-Id: I8bda2435857772f590859808904c48d768b87d46
Reviewed-on: https://go-review.googlesource.com/20254
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-16 05:12:48 +00:00
Todd Neal
763afe13b9 cmd/compile: change logging of spills for regalloc to Warnl format
Change-Id: I01c000ff3f6dc6b0ed691e289eeef0fa61500337
Reviewed-on: https://go-review.googlesource.com/20744
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-16 02:50:13 +00:00
Todd Neal
8edb72587f cmd/compile: add logging to critical and phielim
Change-Id: Ieefeceea40bd29657fd519368b0920dad8443844
Reviewed-on: https://go-review.googlesource.com/20712
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-15 22:53:12 +00:00
Keith Randall
5305a329d8 cmd/compile: turn off SSA internal consistency checks
They've been on for a few weeks of general use and nothing
has tripped up on them yet.

Makes the compiler ~18% faster.

Change-Id: I42d7bbc0581597f9cf4fb28989847814c81b08a2
Reviewed-on: https://go-review.googlesource.com/20741
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-15 22:25:48 +00:00
Matthew Dempsky
63142027de cmd: collapse internal/obj/fmt.go into compile/internal/gc/fmt.go
The obj.Fmt* values are only used by gc/fmt.go, so just move them
there. Also, add comments documenting the correspondance between
FmtFoo names and their flag characters to make understanding the
existing documentation slightly less confusing.

While here, add a new FmtFlag named type to represent these values.

Change-Id: I9631214b892557d094823f1ac575d0c43a84007b
Reviewed-on: https://go-review.googlesource.com/20717
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-15 22:08:05 +00:00
Wedson Almeida Filho
8e7072ca83 sync: new Cond implementation
Change Cond implementation to use a notification list such that waiters
can first register for a notification, release the lock, then actually
wait. Signalers never have to park anymore.

This is intended to address an issue in the previous implementation
where Broadcast could fail to signal all waiters.

Results of the existing benchmark are below.

                                          Original          New  Diff
BenchmarkCond1-48        2000000               745 ns/op    755 +1.3%
BenchmarkCond2-48        1000000              1545 ns/op   1532 -0.8%
BenchmarkCond4-48         300000              3833 ns/op   3896 +1.6%
BenchmarkCond8-48         200000             10049 ns/op  10257 +2.1%
BenchmarkCond16-48        100000             21123 ns/op  21236 +0.5%
BenchmarkCond32-48         30000             40393 ns/op  41097 +1.7%

Fixes #14064

Change-Id: I083466d61593a791a034df61f5305adfb8f1c7f9
Reviewed-on: https://go-review.googlesource.com/18892
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Caleb Spare <cespare@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-15 22:01:20 +00:00
David Crawshaw
f2772a4935 cmd/compile: compute second method type at runtime
The type information for a method includes two variants: a func
without the receiver, and a func with the receiver as the first
parameter. The former is used as part of the dynamic interface
checks, but the latter is only returned as a type in the
reflect.Method struct.

Instead of computing it at compile time, construct it at run time
with reflect.FuncOf.

Using cl/20701 as a baseline,

	cmd/go: -480KB, (4.4%)
	jujud:  -5.6MB, (7.8%)

For #6853.

Change-Id: I1b8c73f3ab894735f53d00cb9c0b506d84d54e92
Reviewed-on: https://go-review.googlesource.com/20709
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-15 19:57:40 +00:00
Matthew Dempsky
1b9f168f73 cmd/compile: use int for field index
All of a struct's fields have to fit into memory anyway, so index them
with int instead of int64.  This also makes it nicer for
cmd/compile/internal/gc to reuse the same NumFields function.

Change-Id: I210be804a0c33370ec9977414918c02c675b0fbe
Reviewed-on: https://go-review.googlesource.com/20691
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-15 19:56:43 +00:00
David Crawshaw
d06b0db5bd cmd/link: when pruning methods also prune funcType
Remove method type information for pruned methods from any program
that does not reflect on methods. This can be a significant saving:

	addr2line: -310KB (8.8%)

A future update might want to consider a more aggressive variant of
this: setting the Type and Func fields of reflect.Method to nil for
unexported methods. That would shrink cmd/go by 2% and jujud by 2.6%
but could be considered an API change. So this CL sticks to the
uncontroversial change.

For #6853.

Change-Id: I5d186d9f822dc118ee89dc572c4912a3b3c72577
Reviewed-on: https://go-review.googlesource.com/20701
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-15 19:41:17 +00:00
Keith Randall
41f9f6f471 cmd/compile: fix load-combining
Make sure symbol gets carried along by load-combining rule.
Add the new load into the right block where we know that
mem is live.

Use auxInt field to carry i along instead of an explicit ADDQ.

Incorporate LEA ops into MOVBQZX and friends.

Change-Id: I587f7c6120b98fd2a0d48ddd6ddd13345d4421b4
Reviewed-on: https://go-review.googlesource.com/20732
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-15 19:18:13 +00:00
Matthew Dempsky
f6fab93a46 cmd/compile: make Type.Field stricter about bounds checking
Turns out there were only two call sites that expected
t.Field(t.NumFields()) to return nil.

Change-Id: I4679988d38ee9d7c9d89883537a17046717b2a77
Reviewed-on: https://go-review.googlesource.com/20731
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-15 18:46:03 +00:00
Dave Cheney
cea5d26aa2 cmd/compile/internal/gc: remove Thearch.Linkarchinit
Change-Id: I8e990204c7a1e65d6b8e4262f6b5b9bd0cb3540c
Reviewed-on: https://go-review.googlesource.com/20725
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-15 15:29:39 +00:00
Dave Cheney
70090654de cmd/compile/internal/gc: tidy plive.go
Make boolean looking things boolean.

Change-Id: I8d1c0a32b471412b25a72908c7da6458d7bbe65b
Reviewed-on: https://go-review.googlesource.com/20723
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-15 15:27:21 +00:00
Shahar Kohanim
3648d2d4cd cmd/link, cmd/compile: Add symbol references to object file.
Symbols in the object file currently refer to each other using symbol name
and version. Referring to the same symbol many times in an object file takes
up space and causes redundant map lookups. Instead write out a list of unique
symbol references and have symbols refer to each other using indexes into this
list.

Credit to Michael Hudson-Doyle for kicking this off.

Reduces pkg/linux_amd64 size by 30% from 61MB to 43MB

name       old s/op   new s/op   delta
LinkCmdGo  0.74 ± 3%  0.63 ± 4%  -15.22%  (p=0.000 n=20+20)
LinkJuju   6.38 ± 6%  5.73 ± 6%  -10.16%  (p=0.000 n=20+19)

Change-Id: I7e101a0c80b8e673a3ba688295e6f80ea04e1cfb
Reviewed-on: https://go-review.googlesource.com/20099
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-15 13:00:07 +00:00
Dave Cheney
ac47f66abc cmd/compile/internal: clean up galign.go constants
Move the C header style architecture constants to the per arch Main
methods.

Change-Id: Ie7ff39baa275ceaa6680e7d16441ca9f0aa12597
Reviewed-on: https://go-review.googlesource.com/20722
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-15 07:13:04 +00:00
Dave Cheney
04f23b6428 cmd/internal/obj: remove dead code
Partial automatic cleanup driven by Dominik Honnef's unused tool.

As _lookup now only has one caller, merge it into the caller and remove
the conditional create logic.

Change-Id: I2ea354d9d4b32a19905271eca74725231b6d8a93
Reviewed-on: https://go-review.googlesource.com/20589
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-15 06:02:13 +00:00
Josh Bleecher Snyder
11a80860ad cmd/compile: move testdclstack out of the xdcl_list loop
This is a band-aid, but it fixes the problem
until a deeper fix is in place.

Testing with genpkg -n 50000, I see:

Before:

      154.67 real       184.66 user         3.15 sys

After:

       61.82 real        96.99 user         2.17 sys


Fixes #14781.

Change-Id: I24c7822d60c289bdd6a18a7840b984954c95f7d4
Reviewed-on: https://go-review.googlesource.com/20696
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-15 04:15:41 +00:00
Jeremy Jackins
80f2aff9ef cmd/compile: clean up C-style variable declarations in plive.go
Change-Id: I928f51a1fe4830a81d4f5d3eb572785e06a75b77
Reviewed-on: https://go-review.googlesource.com/20581
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-15 00:57:54 +00:00
Robert Griesemer
eb4d1be285 cmd/compile: keep variable numbering for inlineable exported functions
Another step towards hooking up exported inlined function bodies.

Change-Id: Ib8094b03ac7970fee0e51b5826b5f8aa232e23fb
Reviewed-on: https://go-review.googlesource.com/20605
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
2016-03-14 21:56:25 +00:00
Matthew Dempsky
2e9369067b cmd/compile: replace TFIELD kind with separate Field type
Allows removing a bunch of unnecessary fields.

Passes toolstash/buildall.

Change-Id: Iec2492920e1c3ef352a9bf4296c74a55d9cc9ad6
Reviewed-on: https://go-review.googlesource.com/20677
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-14 21:30:41 +00:00
Matthew Dempsky
2a46b08a02 cmd/dist: build bootstrap toolchain with -l
Workaround Go 1.4 compiler bugs.  See discussion at:
https://groups.google.com/d/msg/golang-dev/Ss7mCKsvk8w/Gsq7VYI0AwAJ

Change-Id: I842335fddffb67a6e21c000fe5bef258ea61c77a
Reviewed-on: https://go-review.googlesource.com/20690
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-14 21:30:33 +00:00
Matthew Dempsky
c278f9302e cmd/compile: stop storing TFIELD types in Node.Type
Currently, the only use for this is on the Left side of OKEY nodes
within struct literals.  esc and fmt only care so they can recognize
that the ONAME nodes are actually field names, which need special
handling.

sinit additionally needs to know the field's offset within the struct,
which we can provide via Xoffset.

Passes toolstash/buildall.

Change-Id: I362d965e161f4d80fcd9c9bae0dfacc657dc0b29
Reviewed-on: https://go-review.googlesource.com/20676
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-14 21:12:29 +00:00
Josh Bleecher Snyder
9bffcf382b cmd/compile: minor cleanup in sinit.go
Passes toolstash -cmp.

Change-Id: Id16009ef3ef1173eafe0f0c578dbf325b61aab3c
Reviewed-on: https://go-review.googlesource.com/20674
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-14 21:03:33 +00:00
Matthew Dempsky
0d2e92c2ca cmd/compile: add Fields field to Type
Switch TSTRUCT and TINTER to use Fields instead of Type, which wrings
out the remaining few direct uses of the latter.

Preparation for converting fields to use a separate "Field" type.

Passes toolstash/buildall.

Change-Id: I5a2ea7e159d0dde1be2c9afafc10a8f739d95743
Reviewed-on: https://go-review.googlesource.com/20675
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-14 20:44:45 +00:00
Josh Bleecher Snyder
7971864267 cmd/compile: simplify InitPlan
Passes toolstash -cmp.

Change-Id: Iaa0d78c2552efb29e67f6c99c7287f8566027add
Reviewed-on: https://go-review.googlesource.com/20673
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-14 20:44:02 +00:00
Josh Bleecher Snyder
e59c1729ba cmd/compile: convert data siz to int
Follow-up to CL 20645.

Passes toolstash -cmp.

Change-Id: Idc63c41b2be2d52e3a6ac59b3a12eb41aa2efbed
Reviewed-on: https://go-review.googlesource.com/20670
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-14 20:22:21 +00:00
Josh Bleecher Snyder
57faad6677 cmd/compile: fix CTNIL static data comments
Change-Id: I434f881c10dec41a802641db8873abf1353beba2
Reviewed-on: https://go-review.googlesource.com/20671
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-14 19:55:30 +00:00
Josh Bleecher Snyder
a0232ea0dd cmd/compile: allow deduplication of long strings
String symbols' names used to appear in the final binary.
Using a string's contents as it's symbol's name
was a thus a bad idea if the string's name was long.
Recent improvements by crawshaw have changed that.

Instead of placing long strings behind opaque names
in local packages, place them in the global string
package and make them content-addressable.
Symbol names still occur in the object files,
so use a hash to avoid needless length there.

Reduces the size of cmd/go by 30k.

Change-Id: Ifdbbaf47bf44352418c90ddd903d5106e48db4f1
Reviewed-on: https://go-review.googlesource.com/20524
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-14 19:54:58 +00:00
Alexandru Moșoi
13f74db304 cmd/compile: fix no-opt build after moving decomposing user functions
decompose-builtin pass requires an opt pass, but -N disables
late-opt, the only opt pass (out of two) that happens
after decompose-builtin.  This CL enables both 'opt' and 'late opt'
passes. The extra compile time for 'late opt' in negligible
since most rewrites were already done in the first 'opt'
(also measured before). We should put some effort in splitting the
generic rules into required and optional.

Also update generic.rules comments about lowering
of StringMake and SliceMake.

Tested with GO_GCFLAGS=-N ./all.bash

Change-Id: I92999681aaa02587b6dc6e32ce997a91f1fc9499
Reviewed-on: https://go-review.googlesource.com/20682
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-14 18:44:10 +00:00
Michael Pratt
a4e31d42ee cmd/compile: remove amd64 code from package gc and the core gen tool
Parts of the SSA compiler in package gc contain amd64-specific code,
most notably Prog generation. Move this code into package amd64, so that
other architectures can be added more easily.

In package gc, this change is just moving code. There are no functional
changes or even any larger structural changes beyond changing function
names (mostly for export).

In the cmd/compile/internal/ssa/gen tool, more information is included
in arch to remove the AMD64-specific behavior in the main portion of the
tool. The generated opGen.go is identical.

Change-Id: I8eb37c6e6df6de1b65fa7dab6f3bc32c29daf643
Reviewed-on: https://go-review.googlesource.com/20609
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-14 16:59:03 +00:00
Todd Neal
98b88de56f cmd/compile: change the type of ssa Warnl line number
Line numbers are always int32, so the Warnl function should take the
line number as an int32 as well.  This matches gc.Warnl and removes
a cast every place it's used.

Change-Id: I5d6201e640d52ec390eb7174f8fd8c438d4efe58
Reviewed-on: https://go-review.googlesource.com/20662
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-14 11:04:40 +00:00
Matthew Dempsky
2dcbbbd193 cmd/internal/obj, cmd/asm: get rid of obj.ADATA
Just recognize "DATA" as a special pseudo op word in the assembler
directly.

Change-Id: I508e111fd71f561efa600ad69567a7089a57adb2
Reviewed-on: https://go-review.googlesource.com/20648
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-14 05:13:47 +00:00
Matthew Dempsky
edde955d7f cmd/internal/obj: support arbitrarily sized string data
Updates #14786.

Change-Id: I5fe889886f772167386cd10390ac50abc1383937
Reviewed-on: https://go-review.googlesource.com/20607
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-03-14 05:13:31 +00:00
Josh Bleecher Snyder
4f753e77f1 cmd/all: stop generating ADATA Progs
The only remaining place that generated ADATA
Prog was the assembler. Stop, and delete some
now-dead code.

Passes toolstash -cmp.

Change-Id: I26578ff1b4868e98562b44f69d909c083e96f8d5
Reviewed-on: https://go-review.googlesource.com/20646
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-14 02:22:49 +00:00
Josh Bleecher Snyder
7c18f8cdc3 cmd/compile: write some static data directly
Instead of generating ADATA instructions for
static data, write that static data directly
into the linker sym.
This is considerably more efficient.
The assembler still generates
ADATA instructions, so the ADATA machinery
cannot be dismantled yet. (Future work.)
Skipping ADATA has a significant impact
compiling the unicode package, which has lots
of static data.

name     old time/op    new time/op    delta
Unicode     227ms ±10%     192ms ± 4%  -15.61%  (p=0.000 n=29+30)

name     old alloc/op   new alloc/op   delta
Unicode    51.0MB ± 0%    45.8MB ± 0%  -10.29%  (p=0.000 n=30+30)

name     old allocs/op  new allocs/op  delta
Unicode      610k ± 0%      578k ± 0%   -5.29%  (p=0.000 n=30+30)

This does not pass toolstash -cmp, because
this changes the order in which some relocations
get added, and thus it changes the output from
the compiler. It is not worth the execution time
to sort the relocs in the normal case.

However, compiling with -S -v generates identical
output if (1) you suppress printing of ADATA progs
in flushplist and (2) you suppress printing of
cpu timing. It is reasonable to suppress printing
the ADATA progs, since the data itself is dumped
later. I am therefore fairly confident that all
changes are superficial and non-functional.

Fixes #14786, although there's more to do
in general.

Change-Id: I8dfabe7b423b31a30e516cfdf005b62a2e9ccd82
Reviewed-on: https://go-review.googlesource.com/20645
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-14 02:21:43 +00:00
Matthew Dempsky
d1341d6cf3 cmd/compile, runtime: eliminate growslice_n
Fixes #11419.

Change-Id: I7935a253e3e96191a33f5041bab203ecc5f0c976
Reviewed-on: https://go-review.googlesource.com/20647
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-13 23:34:31 +00:00
Alexandru Moșoi
8ec80176d4 cmd/compile: move decompose builtin closer to late opt
* Shaves about 10k from pkg/tools/linux_amd64.
* Was suggested by drchase before
* Found by looking at ssa output of #14758

Change-Id: If2c4ddf3b2603d4dfd8fb4d9199b9a3dcb05b17d
Reviewed-on: https://go-review.googlesource.com/20570
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-13 22:12:01 +00:00
Josh Bleecher Snyder
fdc04223c5 cmd/compile: clean up savedata
Simplify function signature.
Remove unused Ctxt field Enforce_data_order.

Passes toolstash -cmp.

Change-Id: I5caa270ca9ae725708fe415b2c978b5f40780255
Reviewed-on: https://go-review.googlesource.com/20644
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-13 21:11:27 +00:00
Josh Bleecher Snyder
e8fab405cb cmd/compile: minor cleanup
Passes toolstash -cmp.

Change-Id: Ib8c76081956e1d4eecef16b82bc8d527d7849d7e
Reviewed-on: https://go-review.googlesource.com/20643
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-13 21:06:25 +00:00
Egon Elbre
69f49e1cbc cmd/pprof: fix crash with invalid source
pprof crashed when running with:

     go tool pprof %INVALID

Change-Id: I47c2a4da7273e3a97a833f320a650b8c6b59d6b9
Reviewed-on: https://go-review.googlesource.com/20632
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-13 20:38:16 +00:00
Josh Bleecher Snyder
af1c29c1c1 cmd/internal/obj: sort relocs by off when printing
This makes the output of compiling with -S more
stable in the face of unimportant variation in the
order in which relocs are generated.
It is also more pleasant to read the relocs when
they are sorted.

Also, do some minor cleanup.

For #14786

Change-Id: Id92020b13fd21777dfb5b29c2722c3b2eb27001b
Reviewed-on: https://go-review.googlesource.com/20641
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-13 20:31:40 +00:00
Matthew Dempsky
a2a48069fe cmd/compile: rework how fieldtrack is implemented
Shrinks gc.Type and gc.Func slightly.

Passes "GOEXPERIMENT=fieldtrack ./all.bash" and "go test -a
-toolexec='toolstash -cmp' -ldflags=-k=rsc.io/tmp/fieldtrack.tracked
rsc.io/tmp/fieldtrack".

Change-Id: I785fe8a18eb830d9867d34247e4cd41a6a7921d4
Reviewed-on: https://go-review.googlesource.com/20557
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-13 16:58:00 +00:00
Todd Neal
f6ceed2cab cmd/compile: const folding for float32/64
Split the auxFloat type into 32/64 bit versions and perform checking for
exactly representable float32 values.  Perform const folding on
float32/64.  Comment out some const negation rules that the frontend
already performs.

Change-Id: Ib3f8d59fa8b30e50fe0267786cfb3c50a06169d2
Reviewed-on: https://go-review.googlesource.com/20568
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-13 13:32:41 +00:00