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

8613 Commits

Author SHA1 Message Date
Cherry Zhang
310a40b4f2 cmd/compile: start MIPS64 port of SSA backend
Fib with all int and float types run correctly.
*, /, shifts, Zero, Move not implemented yet. No optimization yet.

Updates #16359.

Change-Id: I4b0412954d5fd4c13a5fcddd8689ed8ac701d345
Reviewed-on: https://go-review.googlesource.com/27404
Reviewed-by: David Chase <drchase@google.com>
2016-08-22 16:30:38 +00:00
Josh Bleecher Snyder
e4cae432d6 cmd/compile: add inline explainer
When compiling with -m -m, this adds output
for every non-inlined function explaining why
it was not inlined.

Change-Id: Icb59ae912a835c996e6b3475b163ee5125113001
Reviewed-on: https://go-review.googlesource.com/22782
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-22 16:16:35 +00:00
Josh Bleecher Snyder
ef6fde26e5 cmd/vet: handle multiple arches in asm build directives
If a build directive contains multiple arches,
try to match the build context.

Updates #11041

Change-Id: I03b5d7bfb29d1ff6c7d36a9d7c7fabfcc1d871c1
Reviewed-on: https://go-review.googlesource.com/27158
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:43:16 +00:00
Josh Bleecher Snyder
863ca99415 cmd/vet: fix mips64le arch name in asmdecl check
Updates #11041

Change-Id: Ic6df8ef25b7cf280db523950cd3640b060ad1a9b
Reviewed-on: https://go-review.googlesource.com/27157
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:42:59 +00:00
Josh Bleecher Snyder
f410a668ee cmd/vet: improve error message for cross-package assembly
bytes.Compare has its go prototype in package bytes,
but its implementation in package runtime.
vet used to complain that the prototype was missing.
Now instead:

runtime/asm_amd64.s:1483: [amd64] cannot check cross-package assembly function: Compare is in package bytes

Updates #11041

Change-Id: Ied44fac10d0916d7a34e552c02d052e16fca0c8c
Reviewed-on: https://go-review.googlesource.com/27153
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:42:45 +00:00
Josh Bleecher Snyder
0952a15cd1 cmd/vet: clean up printing errors with no position
Before:

: runtime/asm_amd64.s:345: [amd64] morestack: use of 8(SP) points beyond argument frame

After:

runtime/asm_amd64.s:345: [amd64] morestack: use of 8(SP) points beyond argument frame

Updates #11041

Change-Id: Ic87a6d1a2a7b2a8bf737407bc981b159825c84f2
Reviewed-on: https://go-review.googlesource.com/27152
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:42:30 +00:00
Josh Bleecher Snyder
4af1148079 cmd/vet: improve asmdecl parameter handling
The asmdecl check had hand-rolled code that
calculated the size and offset of parameters
based only on the AST.
It included a list of known named types.

This CL changes asmdecl to use go/types instead.
This allows us to easily handle named types.
It also adds support for structs, arrays,
and complex parameters.

It improves the default names given to unnamed
parameters. Previously, all anonymous arguments were
called "unnamed", and the first anonymous return
argument was called "ret".
Anonymous arguments are now called arg, arg1, arg2,
etc., depending on the index in the argument list.
Return arguments are ret, ret1, ret2.

This CL also fixes a bug in the printing of
composite data type sizes.

Updates #11041

Change-Id: I1085116a26fe6199480b680eff659eb9ab31769b
Reviewed-on: https://go-review.googlesource.com/27150
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:42:06 +00:00
Michael Matloob
fa8a28d559 cmd/link: turn some globals into flag pointer variables
This moves many of the flag globals into main and assigns them
to their flag.String/Int64/... directly.

Updates #16818

Change-Id: Ibbff44a273bbc5cb7228e43f147900ee8848517f
Reviewed-on: https://go-review.googlesource.com/27473
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-22 14:09:05 +00:00
Michael Hudson-Doyle
82c1e22e13 cmd/link: make listsort less generic
It's always called with the same arguments now.

Maybe the real fix is to make Symbol.Sub a slice but that requires a bit more
brain.

Change-Id: I1326d34a0a327554be6d54f9bd402ea328224766
Reviewed-on: https://go-review.googlesource.com/27416
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-08-22 01:55:12 +00:00
Josh Bleecher Snyder
a3765723c6 cmd/compile: remove inl escape analysis hack
Relevant issues: #5056, #9537, and #11053.
Their tests all pass.

Change-Id: Ibbe05982ed5f332149ffd2cb6a232b8d677c4454
Reviewed-on: https://go-review.googlesource.com/27464
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 23:19:23 +00:00
Josh Bleecher Snyder
3c55ee6420 cmd/compile: refactor out method-called-as-function check
Change-Id: I417aae8622d7d363863704594680bd2502a09049
Reviewed-on: https://go-review.googlesource.com/27463
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 23:19:16 +00:00
Josh Bleecher Snyder
376d9665a8 cmd/compile: don’t consider recursive calls for inlining
We will never inline recursive calls.
Rather than simulate the recursion until we hit
the complexity ceiling, just bail early.

Also, remove a pointless n.Op check.
visitBottomUp guarantees that n will be an
ODCLFUNC, and caninl double-checks it.

Change-Id: Ifa48331686b24289d34e68cf5bef385f464b6b92
Reviewed-on: https://go-review.googlesource.com/27462
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 23:18:50 +00:00
Josh Bleecher Snyder
d1faf3879e cmd/compile: don’t generate pointless gotos during inlining
Their only purpose in life was to suppress an error.
Suppress that error explicitly instead by reusing
an existing, aptly named Node field.

This generates fewer blocks during ssa construction.

name       old alloc/op     new alloc/op     delta
Template       47.5MB ± 0%      47.2MB ± 0%  -0.72%        (p=0.000 n=15+15)
Unicode        36.8MB ± 0%      36.8MB ± 0%    ~           (p=0.775 n=15+15)
GoTypes         143MB ± 0%       142MB ± 0%  -1.03%        (p=0.000 n=15+14)
Compiler        686MB ± 0%       674MB ± 0%  -1.75%        (p=0.000 n=15+15)

name       old allocs/op    new allocs/op    delta
Template         446k ± 0%        445k ± 0%  -0.20%        (p=0.000 n=15+15)
Unicode          355k ± 0%        355k ± 0%    ~           (p=0.235 n=13+15)
GoTypes         1.36M ± 0%       1.36M ± 0%  -0.41%        (p=0.000 n=13+15)
Compiler        5.77M ± 0%       5.70M ± 0%  -1.16%        (p=0.000 n=15+15)


Change-Id: I5f14afb833c9d355688d9a229eb820e95c7657bf
Reviewed-on: https://go-review.googlesource.com/27461
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 23:18:33 +00:00
Michael Matloob
16e3ce2785 cmd/link/internal/ld: rename pobj.go to main.go
The only thing pobj contains is the Ldmain function.

Updates #16818

Change-Id: Id114bdb264cb5ea2f372eb2166201f1f8eb99445
Reviewed-on: https://go-review.googlesource.com/27472
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-21 23:00:44 +00:00
Michael Matloob
0a15d95091 cmd/link: use standard library flag package where possible
The obj library's flag functions are (mostly) light wrappers
around the standard library flag package. Use the flag package
directly where possible.

Most uses of the 'count'-type flags (except for -v) only check
against 0, so they can safely be replaced by bools. Only -v
and the flagfns haven't been replaced.

Debug has been turned into a slice of bools rather than ints.
There was a copy of the -v verbosity in ctxt.Debugvlog, so don't use
Debug['v'] and just use ctxt.Debugvlog.

Updates #16818

Change-Id: Icf6473a4823c9d35513bbd0c34ea02d5676d782a
Reviewed-on: https://go-review.googlesource.com/27471
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-21 23:00:27 +00:00
Josh Bleecher Snyder
65c5d62420 cmd/vet: re-quote struct tags when printing errors
cmd/link/link_test.go contains several multi-line
struct tags. Going through an unquote/quote cycle
converts `a
b
c` to "a\nb\nc\n".

This keeps all vet error messages for the standard
library on a single line.

Updates #11041

Change-Id: Ifba1e87297a5174294d1fbf73463fd3db357464f
Reviewed-on: https://go-review.googlesource.com/27129
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-21 22:47:03 +00:00
Josh Bleecher Snyder
6ad76718cf cmd/vet: don't treat trailing % as possible formatting directive
Eliminates the following false positive:

cmd/go/go_test.go:1916: possible formatting directive in Error call

The line in question:

tg.t.Error("some coverage results are 0.0%")

Updates #11041

Change-Id: I3b7611fa3e0245714a19bd5388f21e39944f5296
Reviewed-on: https://go-review.googlesource.com/27128
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-21 22:45:38 +00:00
Michael Hudson-Doyle
8e90b9026b cmd/link: remove references to LSym (now Symbol)
Mostly comments but some derived names too.

Change-Id: I1e01dccca98de6688e1426c7a9309f6fd6a1e368
Reviewed-on: https://go-review.googlesource.com/27415
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 22:43:20 +00:00
Michael Hudson-Doyle
85072d5f75 cmd/link: remove Symbol.Next
Bye bye one more class of linked list manipulation!

Change-Id: I2412b224c847dd640f9253125d30cd5f911ce00c
Reviewed-on: https://go-review.googlesource.com/27414
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-08-21 22:17:24 +00:00
Michael Matloob
64f5023e6f cmd/link: remove global Bso variable
Bso is already a member on ld.Link. Use that instead of
the global.

Updates #16818

Change-Id: Icfc0f6cb1ff551e8129253fb6b5e0d6a94479f51
Reviewed-on: https://go-review.googlesource.com/27470
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 18:51:21 +00:00
Michael Matloob
4338e5a891 cmd/link/internal: remove global Ctxt variable
This change threads the *ld.Link Ctxt variable through
code in arch-specific packages. This removes all remaining
uses of Ctxt, so remove the global variable too.

This CL continues the work in golang.org/cl/27408

Updates #16818

Change-Id: I5f4536847a1825fd0b944824e8ae4e122ec0fb78
Reviewed-on: https://go-review.googlesource.com/27459
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 18:18:39 +00:00
Martin Möhrmann
6a393dc64f cmd/compile: fix compilation of math.Sqrt when used as a statement
Fixes #16804

Change-Id: I669c2c24d3135cd35e15a464894ac66945847d0c
Reviewed-on: https://go-review.googlesource.com/27437
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 16:49:48 +00:00
Michael Matloob
2f783c3458 cmd/link/internal: thread *ld.Link through calls
Ctxt is a global defined in cmd/link/internal/ld of type *ld.Link.
Start threading a *ld.Link through function calls instead of
relying on the global variable.

Ctxt is still used as a global by the architecture-specific packages,
but I plan to fix that in a subsequent CL.

Change-Id: I77a3a58bd396fafd959fa1d8b1c83008a9f5a7fb
Reviewed-on: https://go-review.googlesource.com/27408
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-08-21 15:56:43 +00:00
Michael Matloob
a072fc2e67 cmd/link/internal: rename LSym to Symbol, and add a doc comment.
I'd also like to document some of its fields, but I don't know
what they are.

Change-Id: I87d341e255f785d351a8a73e645be668e02b2689
Reviewed-on: https://go-review.googlesource.com/27399
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-19 22:10:04 +00:00
Brad Fitzpatrick
a25a7ad703 cmd/internal/obj: update Bool2int to the form optimized by the compiler
As of https://golang.org/cl/22711 the compiler optimizes this form.

Updates #6011

Change-Id: Ibc6c529dfa24d42f4aab78ebd6722e1d72cb6038
Reviewed-on: https://go-review.googlesource.com/27395
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-19 03:33:36 +00:00
Matthew Dempsky
70544c91ff cmd/compile/internal/syntax: match old parser errors and line numbers
This makes a bunch of changes to package syntax to tweak line numbers
for AST nodes. For example, short variable declaration statements are
now associated with the location of the ":=" token, and function calls
are associated with the location of the final ")" token. These help
satisfy many unit tests that assume the old parser's behavior.

Because many of these changes are questionable, they're guarded behind
a new "gcCompat" const to make them easy to identify and revisit in
the future.

A handful of remaining tests are too difficult to make behave
identically. These have been updated to execute with -newparser=0 and
comments explaining why they need to be fixed.

all.bash now passes with both the old and new parsers.

Change-Id: Iab834b71ca8698d39269f261eb5c92a0d55a3bf4
Reviewed-on: https://go-review.googlesource.com/27199
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-19 01:10:21 +00:00
Matthew Dempsky
2ff463948c cmd/compile/internal/gc: use new AST parser
Introduce a new noder type to transform package syntax's AST into gc's
Node tree. Hidden behind a new -newparser flag.

Change-Id: Id0e862ef6196c41533876afc4ec289e21d422d18
Reviewed-on: https://go-review.googlesource.com/27198
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-19 01:10:12 +00:00
Matthew Dempsky
117793624b cmd/compile/internal/syntax: expose additional information for gc
gc needs access to line offsets for Nodes. It also needs access to the
end line offset for function bodies so it knows what line number to
use for things like implicit returns and defer executions.

Lastly, include an extra bool to distinguish between simple and full
slice expressions. This is redundant in valid parse trees, but needed
by gc for producing complete warnings in invalid inputs.

Change-Id: I64baf334a35c72336d26fa6755c67eb9d6f4e93c
Reviewed-on: https://go-review.googlesource.com/27196
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-19 01:09:52 +00:00
Josh Bleecher Snyder
794442375d cmd/vet: allow large shifts of constants
Large shifts of constants are frequently
used for fancy 32/64 bit detection.

This removes 14 false positives from the
standard library.

Updates #11041

Change-Id: Ib39346e5c161da04c38a6a3067932ef43bf74f2d
Reviewed-on: https://go-review.googlesource.com/27155
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-18 23:39:37 +00:00
Matthew Dempsky
36f61ed7ed cmd/dist: build cmd/compile/internal/syntax
Change-Id: Ie6dd2318e031be445c0b1ae65d4c78723d5a1167
Reviewed-on: https://go-review.googlesource.com/27197
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-18 21:33:53 +00:00
Robert Griesemer
c8683ff797 cmd/compile/internal/syntax: fast Go syntax trees, initial commit.
Syntax tree nodes, scanner, parser, basic printers.

Builds syntax trees for entire Go std lib at a rate of ~1.8M lines/s
in warmed up state (MacMini, 2.3 GHz Intel Core i7, 8GB RAM):

$ go test -run StdLib -fast
parsed 1074617 lines (2832 files) in 579.66364ms (1853863 lines/s)
allocated 282.212Mb (486.854Mb/s)
PASS

Change-Id: Ie26d9a7bf4e5ff07457aedfcc9b89f0eba72ae3f
Reviewed-on: https://go-review.googlesource.com/27195
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-18 21:33:38 +00:00
Cherry Zhang
a7277e5494 cmd/compile: compare size in dead store elimination
Only remove stores that is shadowed by another store with same or
larger size. Normally we don't need this check because we did check
the types, but unsafe pointer casting can get around it.

Fixes #16769.

Change-Id: I3f7c6c57807b590a2f735007dec6c65a4fa01a34
Reviewed-on: https://go-review.googlesource.com/27320
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-18 16:38:56 +00:00
David Chase
5b9ff11c3d cmd/compile: ppc64le working, not optimized enough
This time with the cherry-pick from the proper patch of
the old CL.

Stack size increased.
Corrected NaN-comparison glitches.
Marked g register as clobbered by calls.
Fixed shared libraries.

live_ssa.go still disabled because of differences.
Presumably turning on more optimization will fix
both the stack size and the live_ssa.go glitches.

Enhanced debugging output for shared libs test.

Rebased onto master.

Updates #16010.

Change-Id: I40864faf1ef32c118fb141b7ef8e854498e6b2c4
Reviewed-on: https://go-review.googlesource.com/27159
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-08-18 16:34:47 +00:00
Brad Fitzpatrick
dea6dab40c cmd/yacc: remove go tool yacc
It is no longer used by Go.

It's now moved to golang.org/x/tools/cmd/goyacc for anybody who needs it.

Fixes #11229

Change-Id: Ia431d5a380c7ff784a2050dee2f5bc8acee015da
Reviewed-on: https://go-review.googlesource.com/27325
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-18 16:15:23 +00:00
Michael Matloob
795ad07b3b cmd: generate DWARF for functions in compile instead of link.
This is a copy of golang.org/cl/22092 by Ryan Brown.

Here's his original comment:
On my machine this increases the average time for 'go build cmd/go' from
2.25s to 2.36s. I tried to measure compile and link separately but saw
no significant change.

Change-Id: If0d2b756d52a0d30d4eda526929c82794d89dd7b
Reviewed-on: https://go-review.googlesource.com/25311
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-18 15:06:27 +00:00
Josh Bleecher Snyder
11e93aa24a cmd/vet: allow any printf verb with any interface
fmt treats interfaces as being transparent.
As a result, we cannot say with confidence
that any particular verb is wrong.

This fixes the following vet false positives
in the standard library:

database/sql/sql_test.go:210: arg dep for printf verb %p of wrong type: sql.finalCloser
fmt/fmt_test.go:1663: arg nil for printf verb %s of wrong type: untyped nil
go/ast/commentmap.go:328: arg node for printf verb %p of wrong type: ast.Node
net/http/transport_test.go:120: arg c for printf verb %p of wrong type: net.Conn
net/http/httptest/server.go:198: arg c for printf verb %p of wrong type: net.Conn
net/http/httputil/dump_test.go:258: arg body for printf verb %p of wrong type: io.Reader
reflect/set_test.go:81: arg x for printf verb %p of wrong type: io.Writer
reflect/set_test.go:141: arg bb for printf verb %p of wrong type: io.Reader

Updates #11041
Updates #16314

Change-Id: I76df01abb3c34a97b6960f551bed9c1c91377cfc
Reviewed-on: https://go-review.googlesource.com/27127
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-18 02:01:25 +00:00
Cherry Zhang
3d5cf72ca9 cmd/compile: CSE copied tuple selectors
In CSE if a tuple generator is CSE'd to a different block, its
selectors are copied to the same block. In this case, also CES
the copied selectors.

Test copied from Keith's CL 27202.

Fixes #16741.

Change-Id: I2fc8b9513d430f10d6104275cfff5fb75d3ef3d9
Reviewed-on: https://go-review.googlesource.com/27236
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-17 21:03:26 +00:00
Josh Bleecher Snyder
2b8e143dc3 cmd/vet: infer asm arch from build context
If we cannot infer the asm arch from the filename
or the build tags, assume that it is the
current build arch. Assembly files with no
restrictions ought to be usable on all arches.

Updates #11041

Change-Id: I0ae807dbbd5fb67ca21d0157fe180237a074113a
Reviewed-on: https://go-review.googlesource.com/27151
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-17 20:49:59 +00:00
Josh Bleecher Snyder
752e161587 cmd/vet: allow ^& uintptr arithmetic
The unsafe.Pointer check allows adding to
and subtracting from uintptrs in order to do
arithmetic.

Some code needs to round uintptrs.
Allow &^ for that purpose.

Updates #11041

Change-Id: Ib90dd2954bb6c78427058271e13f2ce4c4af38fb
Reviewed-on: https://go-review.googlesource.com/27156
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-17 20:48:57 +00:00
Cherry Zhang
659dd4f1d7 cmd/compile: add more ARM64 optimizations
- Use machine instructions for uint64<->float conversions
- Do not enforce alignment on Zero/Move
	ARM64 supports unaligned load/stores, but only aligned offset
	or small offset can be encoded into instructions.
- Do combined loads

Change-Id: Iffca7dd0f13070b17b784861ce5a30af584680eb
Reviewed-on: https://go-review.googlesource.com/27086
Reviewed-by: David Chase <drchase@google.com>
2016-08-17 18:44:39 +00:00
Robert Griesemer
f542576b9e cmd/compile: add compiler phase timing
Timings is a simple data structure that collects times of labeled
Start/Stop events describing timed phases, which later can be written
to a file.

Adjacent phases with common label prefix are automatically collected
in a group together with the accumulated phase time.

Timing data can be appended to a file in benchmark data format
using the new -bench flag:

$ go build -gcflags="-bench=/dev/stdout" -o /dev/null go/types
commit: devel +8847c6b Mon Aug 15 17:51:53 2016 -0700
goos: darwin
goarch: amd64
BenchmarkCompile:go/types:fe:init              1       663292 ns/op      0.07 %
BenchmarkCompile:go/types:fe:loadsys           1      1337371 ns/op      0.14 %
BenchmarkCompile:go/types:fe:parse             1     47008869 ns/op      4.91 %    10824 lines    230254 lines/s
BenchmarkCompile:go/types:fe:typecheck:top1    1      2843343 ns/op      0.30 %
BenchmarkCompile:go/types:fe:typecheck:top2    1       447457 ns/op      0.05 %
BenchmarkCompile:go/types:fe:typecheck:func    1     15119595 ns/op      1.58 %      427 funcs     28241 funcs/s
BenchmarkCompile:go/types:fe:capturevars       1        56314 ns/op      0.01 %
BenchmarkCompile:go/types:fe:inlining          1      9805767 ns/op      1.02 %
BenchmarkCompile:go/types:fe:escapes           1     53598646 ns/op      5.60 %
BenchmarkCompile:go/types:fe:xclosures         1       199302 ns/op      0.02 %
BenchmarkCompile:go/types:fe:subtotal          1    131079956 ns/op     13.70 %
BenchmarkCompile:go/types:be:compilefuncs      1    692009428 ns/op     72.33 %      427 funcs       617 funcs/s
BenchmarkCompile:go/types:be:externaldcls      1        54591 ns/op      0.01 %
BenchmarkCompile:go/types:be:dumpobj           1    133478173 ns/op     13.95 %
BenchmarkCompile:go/types:be:subtotal          1    825542192 ns/op     86.29 %
BenchmarkCompile:go/types:unaccounted          1       106101 ns/op      0.01 %
BenchmarkCompile:go/types:total                1    956728249 ns/op    100.00 %

For #16169.

Change-Id: I93265fe0cb08e47cd413608d0824c5dd35ba7899
Reviewed-on: https://go-review.googlesource.com/24462
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-17 17:27:04 +00:00
Matthew Dempsky
73fdba2601 cmd/compile/internal/s390x: cleanup betypeinit
The Width{int,ptr,reg} assignments are no longer necessary since
golang.org/cl/21623. The other arch's betypeinit functions were
cleaned up, but apparently this one was missed.

Change-Id: I1c7f074d7864a561659c1f98aef604f57f285fd0
Reviewed-on: https://go-review.googlesource.com/27272
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-17 16:24:22 +00:00
Josh Bleecher Snyder
1a7fc7b3a7 cmd/compile: handle e == T comparison more efficiently
Instead of making a runtime call, compare types and values.

Change-Id: Id302083d5a6a5f18e04f36f304f3d290c46976ad
Reviewed-on: https://go-review.googlesource.com/26660
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-17 01:12:23 +00:00
Josh Bleecher Snyder
615a52b95b cmd/compile: inline x, ok := y.(T) where T is a scalar
When T is a scalar, there are no runtime calls
required, which makes this a clear win.

encoding/binary:
WriteInts-8                958ns ± 3%     864ns ± 2%   -9.80%  (p=0.000 n=15+15)

This also considerably shrinks a core fmt
routine:

Before: "".(*pp).printArg t=1 size=3952 args=0x20 locals=0xf0
After:  "".(*pp).printArg t=1 size=2624 args=0x20 locals=0x98

Unfortunately, I find it very hard to get stable
numbers out of the fmt benchmarks due to thermal scaling.

Change-Id: I1278006b030253bf8e48dc7631d18985cdaa143d
Reviewed-on: https://go-review.googlesource.com/26659
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-17 01:12:01 +00:00
Robert Griesemer
074d6a649c cmd/compile: remove conditional code dealing with two export formats
This removes some scaffolding introduced pre-1.7, introduced to
fix an export format bug, and to minimize conflicts with older
formats. The currently deployed and recognized format is "v1",
so don't worry about other versions. This is a step towards a
better scheme for internal export format versioning.

For #16244.

Change-Id: Ic7cf99dd2a24ad5484cc54aed44fa09332c2cf72
Reviewed-on: https://go-review.googlesource.com/27205
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
2016-08-17 00:57:35 +00:00
Robert Griesemer
f50ced6d73 cmd/compile: remove encoding of safemode bit from export data
Removes the encoding of this bit which was ignored but left behind
for 1.7 to minimize pre-1.7 export format changes. See the issue
for more details.

Fixes #15772.

Change-Id: I46cd7a66ad4c6003b78c64295cf3bda503ebf2dd
Reviewed-on: https://go-review.googlesource.com/27201
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-16 23:59:38 +00:00
Josh Bleecher Snyder
9b88fac00c cmd/internal/obj: reduce per-architecture opcode space
s390x took up the last available chunk of int16 opcodes.
There are RISC-V and sparc64 ports in progress out of tree,
and there will likely be other architectures.
Reduce the opcode space to allow more architectures to
fit without increasing to int32.

This is the smallest power of two that accomodates all
existing architectures. All else being equal, smaller is
better--smaller numbers are easier to generate immediates
for and easier on the eyes when debugging.

Change-Id: I4d0824b28913892fbd0579d3f90bea34e44c8946
Reviewed-on: https://go-review.googlesource.com/24223
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2016-08-16 22:53:48 +00:00
Robert Griesemer
b4e9f70412 cmd/compile: remove support for textual export format
Fixes #15323.

Change-Id: I50e996e6fde6b24327cb45dd84da31deef4dcc56
Reviewed-on: https://go-review.googlesource.com/27171
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 22:35:00 +00:00
Keith Randall
5ae8230769 cmd/compile: use shorter versions of zero-extend ops
Only need to zero-extend to 32 bits and we get the top
32 bits zeroed for free.

Only the WQ change actually generates different code.
The assembler did this optimization for us in the other two cases.
But we might as well do it during SSA so -S output more closely
matches the actual generated instructions.

Change-Id: I3e4ac50dc4da124014d4e31c86e9fc539d94f7fd
Reviewed-on: https://go-review.googlesource.com/23711
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-08-16 21:32:21 +00:00
Josh Bleecher Snyder
0cd8faf744 cmd/internal/obj: add opcode space safety check
This CL adds a safety mechanism
for changing the number of opcodes
available per architecture.

A subsequent CL will actually make the change.

Change-Id: I6332ed5514f2f153c54d11b7da0cc8a6be1c8066
Reviewed-on: https://go-review.googlesource.com/24222
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 20:26:16 +00:00