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

8688 Commits

Author SHA1 Message Date
Ian Lance Taylor
db1fef7b2a cmd/go: for -msan build runtime/cgo with -fsanitize=memory
The go tool used to avoid passing -fsanitize=memory when building
runtime/cgo. That was originally to avoid an msan error, but that error
was fixed anyhow for issue #13815. And building runtime/cgo with
-fsanitize=memory corrects the handling of the context traceback
function when the traceback function itself is built with
-fsanitize=memory.

Change-Id: I4bf5c3d21de6b2eb540600435ae47f5820d17464
Reviewed-on: https://go-review.googlesource.com/24855
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-29 22:49:16 +00:00
Aliaksandr Valialkin
bd9aa9811d cmd/vet: check for copying of array of locks
Updates #14664

Change-Id: I1f7b1116cfe91466816c760f136ce566da3e80a9
Reviewed-on: https://go-review.googlesource.com/24340
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-29 21:56:31 +00:00
Aliaksandr Valialkin
c9fbe0f293 cmd/vet: properly handle indexed arguments in printf
Fixes #15884

Change-Id: I33d98db861d74e3c37a546efaf83ce6f2f76d335
Reviewed-on: https://go-review.googlesource.com/24391
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-29 21:56:04 +00:00
Ethan Miller
4955147291 math/big: add assembly implementation of arith for ppc64{le}
The existing implementation used a pure go implementation, leading to slow
cryptographic performance.

Implemented mulWW, subVV, mulAddVWW, addMulVVW, and bitLen for
ppc64{le}.
Implemented divWW for ppc64le only, as the DIVDEU instruction is only
available on Power8 or newer.

benchcmp output:

benchmark                         old ns/op     new ns/op     delta
BenchmarkSignP384                 28934360      10877330      -62.41%
BenchmarkRSA2048Decrypt           41261033      5139930       -87.54%
BenchmarkRSA2048Sign              45231300      7610985       -83.17%
Benchmark3PrimeRSA2048Decrypt     20487300      2481408       -87.89%

Fixes #16621

Change-Id: If8b68963bb49909bde832f2bda08a3791c4f5b7a
Reviewed-on: https://go-review.googlesource.com/26951
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <munday@ca.ibm.com>
2016-08-29 21:03:21 +00:00
Robert Griesemer
0a7c73b5db cmd/compile: use printer in typefmt, Tconv
Change-Id: Ib3ac0177761af1edea6b7951ffbbea042fb836d2
Reviewed-on: https://go-review.googlesource.com/28055
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-29 21:01:20 +00:00
Kevin Burke
d3134b6450 cmd/compile: document more Node fields
Change-Id: Ic8d37e5612b68bc73c4b50b59db54d8966b69838
Reviewed-on: https://go-review.googlesource.com/27326
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-29 20:52:56 +00:00
Martin Möhrmann
e6f9f39ce5 cmd/compile: generate makeslice calls with int arguments
Where possible generate calls to runtime makeslice with int arguments
during compile time instead of makeslice with int64 arguments.

This eliminates converting arguments for calls to makeslice with
int64 arguments for platforms where int64 values do not fit into
arguments of type int.

godoc 386 binary shrinks by approximately 12 kilobyte.

amd64:
name         old time/op  new time/op  delta
MakeSlice-2  29.8ns ± 1%  29.8ns ± 1%   ~     (p=1.000 n=24+24)

386:
name         old time/op  new time/op  delta
MakeSlice-2  52.3ns ± 0%  45.9ns ± 0%  -12.17%  (p=0.000 n=25+22)

Fixes  #15357

Change-Id: Icb8701bb63c5a83877d26c8a4b78e782ba76de7c
Reviewed-on: https://go-review.googlesource.com/27851
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-08-29 18:25:33 +00:00
Robert Griesemer
595cebb055 cmd/compile: remove ignored bool from exported ODCL nodes
This shortens the export format by 1 byte for each exported ODCL
node in inlined function bodies.

Maintain backward compatibility by updating format version and
continue to accept older format.

Change-Id: I549bb3ade90bc0f146decf8016d5c9c3f14eb293
Reviewed-on: https://go-review.googlesource.com/27999
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-29 18:07:47 +00:00
Emmanuel Odeke
7c04633e0c all: fix obsolete inferno-os links
Fixes #16911.

Fix obsolete inferno-os links, since code.google.com shutdown.
This CL points to the right files by replacing
http://code.google.com/p/inferno-os/source/browse
with
https://bitbucket.org/inferno-os/inferno-os/src/default

To implement the change I wrote and ran this script in the root:
$ grep -Rn 'http://code.google.com/p/inferno-os/source/browse' * \
| cut -d":" -f1 | while read F;do perl -pi -e \
's/http:\/\/code.google.com\/p\/inferno-os\/source\/browse/https:\/\/bitbucket.org\/inferno-os\/inferno-os\/src\/default/g'
$F;done

I excluded any cmd/vendor changes from the commit.

Change-Id: Iaaf828ac8f6fc949019fd01832989d00b29b6749
Reviewed-on: https://go-review.googlesource.com/27994
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-29 04:54:42 +00:00
Cherry Zhang
2f679d74e6 cmd/compile: fix load int32 to FP register on big-endian MIPS64
Fixes #16903.

Change-Id: I1f6fcd57e14b2b62e208b7bb3adccd5fd7f8bdbc
Reviewed-on: https://go-review.googlesource.com/27933
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2016-08-28 21:38:09 +00:00
Keith Randall
0c6c3d1de7 cmd/compile: fix noopt build
Atomic add rules were depending on CSE to combine duplicate atomic ops.
With -N, CSE doesn't run.

Redo the rules for atomic add so there's only one atomic op.
Introduce an add-to-first-part-of-tuple pseudo-ops to make the atomic add result correct.

Change-Id: Ib132247051abe5f80fefad6c197db8df8ee06427
Reviewed-on: https://go-review.googlesource.com/27991
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-08-28 18:54:52 +00:00
Keith Randall
84aac622a4 cmd/compile: intrinsify the rest of runtime/internal/atomic for amd64
Atomic swap, add/and/or, compare and swap.

Also works on amd64p32.

Change-Id: Idf2d8f3e1255f71deba759e6e75e293afe4ab2ba
Reviewed-on: https://go-review.googlesource.com/27813
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-08-28 16:31:08 +00:00
Robert Griesemer
0d23c28526 cmd/compile: make dumpdepth a global again
Fixes indenting in debug output like -W.

Change-Id: Ia16b0bad47428cee71fe036c297731e841ec9ca0
Reviewed-on: https://go-review.googlesource.com/27924
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-27 00:08:36 +00:00
Matthew Dempsky
57331b79da Revert "cmd/compile: use printer in typefmt, Tconv"
This reverts commit 8fb0893307.

Broke go/ast tests.

Change-Id: I5c314cb29731d4bc3a0873af8ebfe376f5faba8a
Reviewed-on: https://go-review.googlesource.com/27923
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-26 23:40:33 +00:00
Robert Griesemer
8fb0893307 cmd/compile: use printer in typefmt, Tconv
Change-Id: I9e99289070d63a2509aec1e91b9dd7437a08af5e
Reviewed-on: https://go-review.googlesource.com/27921
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-26 23:21:41 +00:00
Robert Griesemer
71d2b42bf6 cmd/compile: use printer in exprfmt
Change-Id: I7376c3bb55529a575e74985c2d7f0cf07c8996e7
Reviewed-on: https://go-review.googlesource.com/27920
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-26 23:20:13 +00:00
Josh Bleecher Snyder
a46ea90705 go/build: don't alter InstallSuffix for default compile options
Fixes #16378.

Change-Id: I99a064f1afec78fb63cb3719061d20be0f21d45d
Reviewed-on: https://go-review.googlesource.com/24930
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-08-26 23:01:37 +00:00
Robert Griesemer
87061054e7 cmd/compile: use printer in stmtfmt, hconv
Change-Id: If11d328101a82de5ead04159d3085e3d59869283
Reviewed-on: https://go-review.googlesource.com/27919
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-26 22:52:24 +00:00
Robert Griesemer
62a296cd54 cmd/compile: use printer in sconv, symfmt
Change-Id: Iec33775ff5a786f6c52024d592f634231acf91c0
Reviewed-on: https://go-review.googlesource.com/27918
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-26 22:51:08 +00:00
Robert Griesemer
73be5d82d4 cmd/compile: use printer in vconv
Change-Id: Ib30ed686448c4c0a5777cdf1d505ea06eb8b2a47
Reviewed-on: https://go-review.googlesource.com/27917
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-26 22:39:03 +00:00
Robert Griesemer
dc2a0d59a2 cmd/compile: introduce printer for internal formatting; use in jconv
Starting point for uniform use of printer in fmt.go.
It provides a hook to store additional state (and
remove global variables) and should also be more
efficient and cleaner than the mix of string concatenation
and bytes.Buffer use we have now.

Change-Id: I72de14b01850cca32d407a1cb16c894179ea8848
Reviewed-on: https://go-review.googlesource.com/27916
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-26 22:38:36 +00:00
Robert Griesemer
c85b77c22b cmd/compile: reintroduce support for version 0 export format
The Go1.7 export format didn't encode the field package for
blank struct fields (#15514). Re-introduce support for that
format so we can read it w/o error.

For #16881.

Change-Id: Ib131d41aac56dbf970aab15ae7e75ef3944b412d
Reviewed-on: https://go-review.googlesource.com/27912
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-26 22:11:08 +00:00
David Crawshaw
8f3c8a33fa cmd/link: make DynlinkingGo a method
This will allow it to depend on whether plugin.Open is a symbol to be
linked in.

Change-Id: Ie9aa4216f2510fe8b10bc4665c8b19622b7122ea
Reviewed-on: https://go-review.googlesource.com/27819
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-26 20:06:58 +00:00
Cherry Zhang
7f27f1dfdd cmd/compile: add MIPS64 optimizations, SSA on by default
Add the following optimizations:
- fold constants
- fold address into load/store
- simplify extensions and conditional branches
- remove nil checks

Turn on SSA on MIPS64 by default, and toggle the tests.

Fixes #16359.

Change-Id: I7f1e38c2509e22e42cd024e712990ebbe47176bd
Reviewed-on: https://go-review.googlesource.com/27870
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-26 19:45:06 +00:00
Michael Munday
d2dd0dfda8 cmd/internal/obj/s390x: add FIDBR and FIEBR instructions
FIDBR and FIEBR can be used for floating-point to integer rounding.
The relevant functions (Ceil, Floor and Trunc) will be updated
in a future CL.

Change-Id: I5952d67ab29d5ef8923ff1143e17a8d30169d692
Reviewed-on: https://go-review.googlesource.com/27826
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-26 17:23:16 +00:00
Michael Munday
266b349b2d cmd/internal/obj/s390x: add atomic operation instructions
Adds the following s390x instructions from the interlocked access
facility:

 * LAA(G)  - load and add
 * LAAL(G) - load and add logical
 * LAN(G)  - load and and
 * LAX(G)  - load and exclusive or
 * LAO(G)  - load and or

These instructions can be used for atomic arithmetic/logical
operations. The atomic packages will be updated in future CLs.

Change-Id: Idc850ac6749b3e778fda3da66bcd864f6b1df375
Reviewed-on: https://go-review.googlesource.com/27871
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-26 15:08:58 +00:00
David Crawshaw
14efaa0dc3 cmd/compile: qualify unexported fields of unnamed types
The compiler was canonicalizing unnamed types of the form

	struct { i int }

across packages, even though an unexported field i should not be
accessible from other packages.

The fix requires both qualifying the field name in the string used by
the compiler to distinguish the type, and ensuring the struct's pkgpath
is set in the rtype version of the data when the type being written is
not part of the localpkg.

Fixes #16616

Change-Id: Ibab160b8b5936dfa47b17dbfd48964a65586785b
Reviewed-on: https://go-review.googlesource.com/27791
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-26 11:46:15 +00:00
Robert Griesemer
5a6f973565 cmd/compile: fail gracefully on export format skew
Import errors due to unexpected format are virtually
always due to version skew. Don't panic but report a
good error message (incl. hint that the imported package
needs to be reinstalled) if not in debugFormat mode.

Recognize export data format version and store it so
it can be used to automatically handle minor version
differences. We did this before, but not very well.

No export data format changes.

Manually tested with corrupted export data.

For #16881.

Change-Id: I53ba98ef747b1c81033a914bb61ee52991f35a90
Reviewed-on: https://go-review.googlesource.com/27814
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-26 02:00:34 +00:00
Michael Hudson-Doyle
7c3fc4b8e4 cmd/link: hide funcsym symbols
As far as I can tell, this check has been
non-functional since it was introduced.

This cuts 57k off cmd/go and 70k off cmd/compile.

Based on golang.org/cl/24710 by Josh Bleecher Snyder.

Change-Id: I1162a066971df1a067b50afa1cfa0819a6913574
Reviewed-on: https://go-review.googlesource.com/27830
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-26 01:06:13 +00:00
Josh Bleecher Snyder
f9acd3918e net/http, cmd/compile: minor vet fixes
Updates #11041

Change-Id: Ia0151723e3bc0d163cc687a02bfc5e0285d95ffa
Reviewed-on: https://go-review.googlesource.com/27810
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-25 21:21:59 +00:00
Keith Randall
320ddcf834 cmd/compile: inline atomics from runtime/internal/atomic on amd64
Inline atomic reads and writes on amd64.  There's no reason
to pay the overhead of a call for these.

To keep atomic loads from being reordered, we make them
return a <value,memory> tuple.

Change the meaning of resultInArg0 for tuple-generating ops
to mean the first part of the result tuple, not the second.
This means we can always put the store part of the tuple last,
matching how arguments are laid out.  This requires reordering
the outputs of add32carry and sub32carry and their descendents
in various architectures.

benchmark                    old ns/op     new ns/op     delta
BenchmarkAtomicLoad64-8      2.09          0.26          -87.56%
BenchmarkAtomicStore64-8     7.54          5.72          -24.14%

TBD (in a different CL): Cas, Or8, ...

Change-Id: I713ea88e7da3026c44ea5bdb56ed094b20bc5207
Reviewed-on: https://go-review.googlesource.com/27641
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-08-25 20:09:04 +00:00
Josh Bleecher Snyder
0bc94a8864 cmd/compile: when inlining ==, don’t take the address of the values
This CL reworks walkcompare for clarity and concision.
It also makes one significant functional change.
(The functional change is hard to separate cleanly
from the cleanup, so I just did them together.)
When inlining and unrolling an equality comparison
for a small struct or array, compare the elements like:

a[0] == b[0] && a[1] == b[1]

rather than

pa := &a
pb := &b
pa[0] == pb[0] && pa[1] == pb[1]

The result is the same, but taking the address
and working through the indirect
forces the backends to generate less efficient code.

This is only an improvement with the SSA backend.
However, every port but s390x now has a working
SSA backend, and switching to the SSA backend
by default everywhere is a priority for Go 1.8.
It thus seems reasonable to start to prioritize
SSA performance over the old backend.

Updates #15303


Sample code:

type T struct {
	a, b int8
}

func g(a T) bool {
	return a == T{1, 2}
}


SSA before:

"".g t=1 size=80 args=0x10 locals=0x8
	0x0000 00000 (badeq.go:7)	TEXT	"".g(SB), $8-16
	0x0000 00000 (badeq.go:7)	SUBQ	$8, SP
	0x0004 00004 (badeq.go:7)	FUNCDATA	$0, gclocals·23e8278e2b69a3a75fa59b23c49ed6ad(SB)
	0x0004 00004 (badeq.go:7)	FUNCDATA	$1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0004 00004 (badeq.go:8)	MOVBLZX	"".a+16(FP), AX
	0x0009 00009 (badeq.go:8)	MOVB	AL, "".autotmp_0+6(SP)
	0x000d 00013 (badeq.go:8)	MOVBLZX	"".a+17(FP), AX
	0x0012 00018 (badeq.go:8)	MOVB	AL, "".autotmp_0+7(SP)
	0x0016 00022 (badeq.go:8)	MOVB	$0, "".autotmp_1+4(SP)
	0x001b 00027 (badeq.go:8)	MOVB	$1, "".autotmp_1+4(SP)
	0x0020 00032 (badeq.go:8)	MOVB	$2, "".autotmp_1+5(SP)
	0x0025 00037 (badeq.go:8)	MOVBLZX	"".autotmp_0+6(SP), AX
	0x002a 00042 (badeq.go:8)	MOVBLZX	"".autotmp_1+4(SP), CX
	0x002f 00047 (badeq.go:8)	CMPB	AL, CL
	0x0031 00049 (badeq.go:8)	JNE	70
	0x0033 00051 (badeq.go:8)	MOVBLZX	"".autotmp_0+7(SP), AX
	0x0038 00056 (badeq.go:8)	CMPB	AL, $2
	0x003a 00058 (badeq.go:8)	SETEQ	AL
	0x003d 00061 (badeq.go:8)	MOVB	AL, "".~r1+24(FP)
	0x0041 00065 (badeq.go:8)	ADDQ	$8, SP
	0x0045 00069 (badeq.go:8)	RET
	0x0046 00070 (badeq.go:8)	MOVB	$0, AL
	0x0048 00072 (badeq.go:8)	JMP	61

SSA after:

"".g t=1 size=32 args=0x10 locals=0x0
	0x0000 00000 (badeq.go:7)	TEXT	"".g(SB), $0-16
	0x0000 00000 (badeq.go:7)	NOP
	0x0000 00000 (badeq.go:7)	NOP
	0x0000 00000 (badeq.go:7)	FUNCDATA	$0, gclocals·23e8278e2b69a3a75fa59b23c49ed6ad(SB)
	0x0000 00000 (badeq.go:7)	FUNCDATA	$1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0000 00000 (badeq.go:8)	MOVBLZX	"".a+8(FP), AX
	0x0005 00005 (badeq.go:8)	CMPB	AL, $1
	0x0007 00007 (badeq.go:8)	JNE	25
	0x0009 00009 (badeq.go:8)	MOVBLZX	"".a+9(FP), CX
	0x000e 00014 (badeq.go:8)	CMPB	CL, $2
	0x0011 00017 (badeq.go:8)	SETEQ	AL
	0x0014 00020 (badeq.go:8)	MOVB	AL, "".~r1+16(FP)
	0x0018 00024 (badeq.go:8)	RET
	0x0019 00025 (badeq.go:8)	MOVB	$0, AL
	0x001b 00027 (badeq.go:8)	JMP	20


Change-Id: I120185d58012b7bbcdb1ec01225b5b08d0855d86
Reviewed-on: https://go-review.googlesource.com/22277
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-25 17:51:10 +00:00
Josh Bleecher Snyder
307de6540a cmd/compile/internal/obj/x86: clean up "is leaf?" check
Minor code cleanup. No functional changes.

Change-Id: I2e631b43b122174302a182a1a286c0f873851ce6
Reviewed-on: https://go-review.googlesource.com/24813
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-25 16:36:18 +00:00
Josh Bleecher Snyder
64e152910e cmd/internal/obj/x86: remove pointless NOPs
They are no longer needed by stkcheck.

Fixes #16057

Change-Id: I57cb55de5b7a7a1d31a3da200a3a2d51576b68f5
Reviewed-on: https://go-review.googlesource.com/26667
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-25 15:52:41 +00:00
Cherry Zhang
e71e1fe87e cmd/compile: get MIPS64 SSA working
- implement *, /, %, shifts, Zero, Move.
- fix mistakes in comparison.
- fix floating point rounding.
- handle RetJmp in assembler (which was not handled, as a consequence
  Duff's device was disabled in the old backend.)

all.bash now passes with SSA on.

Updates #16359.

Change-Id: Ia14eed0ed1176b5d800592080c8f53dded7fe73f
Reviewed-on: https://go-review.googlesource.com/27592
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-25 12:53:36 +00:00
Dave Cheney
e90ae90b7a cmd/{asm,compile/internal}: delete dead code
Delete unused fields, methods, vars, and funcs. Spotted by
honnef.co/go/unused.

Change-Id: I0e65484bbd916e59369c4018be46f120b469d610
Reviewed-on: https://go-review.googlesource.com/27731
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-25 12:20:29 +00:00
Josh Bleecher Snyder
6286188986 cmd/compile: optimize integer "in range" expressions
Use unsigned comparisons to reduce from
two comparisons to one for integer "in range"
checks, such as a <= b && b < c.
We already do this for bounds checks.
Extend it to user code.

This is much easier to do in the front end than SSA.
A back end optimization would be more powerful,
but this is a good start.

This reduces the power of some of SSA prove
inferences (#16653), but those regressions appear
to be rare and not worth holding this CL for.

Fixes #15844.
Fixes #16697.

strconv benchmarks:

name                          old time/op  new time/op   delta
Atof64Decimal-8               41.4ns ± 3%   38.9ns ± 2%   -5.89%  (p=0.000 n=24+25)
Atof64Float-8                 48.5ns ± 0%   46.8ns ± 3%   -3.64%  (p=0.000 n=20+23)
Atof64FloatExp-8              97.7ns ± 4%   93.5ns ± 1%   -4.25%  (p=0.000 n=25+20)
Atof64Big-8                    187ns ± 8%    162ns ± 2%  -13.54%  (p=0.000 n=24+22)
Atof64RandomBits-8             250ns ± 6%    233ns ± 5%   -6.76%  (p=0.000 n=25+25)
Atof64RandomFloats-8           160ns ± 0%    152ns ± 0%   -5.00%  (p=0.000 n=21+22)
Atof32Decimal-8               41.1ns ± 1%   38.7ns ± 2%   -5.86%  (p=0.000 n=24+24)
Atof32Float-8                 46.1ns ± 1%   43.5ns ± 3%   -5.63%  (p=0.000 n=21+24)
Atof32FloatExp-8               101ns ± 4%    100ns ± 2%   -1.59%  (p=0.000 n=24+23)
Atof32Random-8                 136ns ± 3%    133ns ± 3%   -2.83%  (p=0.000 n=22+22)
Atoi-8                        33.8ns ± 3%   30.6ns ± 3%   -9.51%  (p=0.000 n=24+25)
AtoiNeg-8                     31.6ns ± 3%   29.1ns ± 2%   -8.05%  (p=0.000 n=23+24)
Atoi64-8                      48.6ns ± 1%   43.8ns ± 1%   -9.81%  (p=0.000 n=20+23)
Atoi64Neg-8                   47.1ns ± 4%   42.0ns ± 2%  -10.83%  (p=0.000 n=25+25)
FormatFloatDecimal-8           177ns ± 9%    178ns ± 6%     ~     (p=0.460 n=25+25)
FormatFloat-8                  282ns ± 6%    282ns ± 3%     ~     (p=0.954 n=25+22)
FormatFloatExp-8               259ns ± 7%    255ns ± 6%     ~     (p=0.089 n=25+24)
FormatFloatNegExp-8            253ns ± 6%    254ns ± 6%     ~     (p=0.941 n=25+24)
FormatFloatBig-8               340ns ± 6%    341ns ± 8%     ~     (p=0.600 n=22+25)
AppendFloatDecimal-8          79.4ns ± 0%   80.6ns ± 6%     ~     (p=0.861 n=20+25)
AppendFloat-8                  175ns ± 3%    174ns ± 0%     ~     (p=0.722 n=25+20)
AppendFloatExp-8               142ns ± 4%    142ns ± 2%     ~     (p=0.948 n=25+24)
AppendFloatNegExp-8            137ns ± 2%    138ns ± 2%   +0.70%  (p=0.001 n=24+25)
AppendFloatBig-8               218ns ± 3%    218ns ± 4%     ~     (p=0.596 n=25+25)
AppendFloatBinaryExp-8        80.0ns ± 4%   78.0ns ± 1%   -2.43%  (p=0.000 n=24+21)
AppendFloat32Integer-8        82.3ns ± 3%   79.3ns ± 4%   -3.69%  (p=0.000 n=24+25)
AppendFloat32ExactFraction-8   143ns ± 2%    143ns ± 0%     ~     (p=0.177 n=23+19)
AppendFloat32Point-8           175ns ± 3%    175ns ± 3%     ~     (p=0.062 n=24+25)
AppendFloat32Exp-8             139ns ± 2%    137ns ± 4%   -1.05%  (p=0.001 n=24+24)
AppendFloat32NegExp-8          134ns ± 0%    137ns ± 4%   +2.06%  (p=0.000 n=22+25)
AppendFloat64Fixed1-8         97.8ns ± 0%   98.6ns ± 3%     ~     (p=0.711 n=20+25)
AppendFloat64Fixed2-8          110ns ± 3%    110ns ± 5%   -0.45%  (p=0.037 n=24+24)
AppendFloat64Fixed3-8          102ns ± 3%    102ns ± 3%     ~     (p=0.684 n=24+24)
AppendFloat64Fixed4-8          112ns ± 3%    110ns ± 0%   -1.43%  (p=0.000 n=25+18)
FormatInt-8                   3.18µs ± 4%   3.10µs ± 6%   -2.54%  (p=0.001 n=24+25)
AppendInt-8                   1.81µs ± 5%   1.80µs ± 5%     ~     (p=0.648 n=25+25)
FormatUint-8                   812ns ± 6%    816ns ± 6%     ~     (p=0.777 n=25+25)
AppendUint-8                   536ns ± 4%    538ns ± 3%     ~     (p=0.798 n=20+22)
Quote-8                        605ns ± 6%    602ns ± 9%     ~     (p=0.573 n=25+25)
QuoteRune-8                   99.5ns ± 8%  100.2ns ± 7%     ~     (p=0.432 n=25+25)
AppendQuote-8                  361ns ± 3%    363ns ± 4%     ~     (p=0.085 n=25+25)
AppendQuoteRune-8             23.3ns ± 3%   22.4ns ± 2%   -3.79%  (p=0.000 n=25+24)
UnquoteEasy-8                  146ns ± 4%    145ns ± 5%     ~     (p=0.112 n=24+24)
UnquoteHard-8                  804ns ± 6%    771ns ± 6%   -4.10%  (p=0.000 n=25+24)

Change-Id: Ibd384e46e90f1cfa40503c8c6352a54c65b72980
Reviewed-on: https://go-review.googlesource.com/27652
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-25 03:49:16 +00:00
Dave Cheney
d61c07ffd8 cmd/link/internal, cmd/internal/obj: introduce ctxt.Logf
Replace the various calls to Fprintf(ctxt.Bso, ...) with a helper,
ctxt.Logf. This also addresses the various inconsistent flushing of
ctxt.Bso.

Because we have two Link structures, add Link.Logf in both places.

Change-Id: I23093f9b9b3bf33089a0ffd7f815f92dcd1a1fa1
Reviewed-on: https://go-review.googlesource.com/27730
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-25 03:34:06 +00:00
Dave Cheney
5f94ff4c87 cmd/link/internal/ld: move ld.Cpos to coutbuf.Offset
This change moves the ld.Cpos function to a method on coutbuf. This is
part of a larger change that makes ld.outbuf look more like a bio.Buf in
an effort to eventually replace the former with the latter.

Change-Id: I506f7131935a2aa903fa302a0fab0c5be50220fd
Reviewed-on: https://go-review.googlesource.com/27578
Run-TryBot: Dave Cheney <dave@cheney.net>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-25 02:57:48 +00:00
Dave Cheney
3167ff7ca9 cmd/internal/*: only call ctx.Bso.Flush when something has been written
In many places where ctx.Bso.Flush is used as the target for some debug
logging, ctx.Bso.Flush is called unconditionally. In the majority of
cases where debug logging is not enabled, this means Flush is called
many times when there is nothing to be flushed (it will be called anyway
when ctx.Bso is eventually closed), sometimes in a loop.

Avoid this by moving the ctx.Bso.Flush call into the same condition
block as the debug print. This pattern was previously applied
sporadically.

Change-Id: I0444cb235cc8b9bac51a59b2e44e59872db2be06
Reviewed-on: https://go-review.googlesource.com/27579
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-25 01:31:17 +00:00
Matthew Dempsky
1472221a77 cmd/go: refactor cgo logic
Extract "cgo -dynimport" and "ld -r" logic into separate helper
methods to make (*builder).cgo somewhat more manageable.

Fixes #16650.

Change-Id: I3e4d77ff3791528b1233467060d3ea83cb854acb
Reviewed-on: https://go-review.googlesource.com/27270
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-08-25 00:19:32 +00:00
Josh Bleecher Snyder
9741d83cea cmd/asm, go/build: invoke cmd/asm only once per package
Prior to this CL, cmd/go invoked cmd/asm once
for every assembly file.
The exec and cmd/asm startup overhead dwarfed
the actual time spent assembling.
This CL adds support to cmd/asm to process
multiple input files and uses it in cmd/go.

This cuts 10% off the wall time for 'go build -a math'.

Fixes #15680

Change-Id: I12d2ee2c817207954961dc8f37b8f2b09f835550
Reviewed-on: https://go-review.googlesource.com/27636
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-24 22:31:34 +00:00
Josh Bleecher Snyder
9d4623fe43 cmd/compile: handle OCONV[NOP] in samesafeexpr
This increases the effectiveness of the
"integer-in-range" CL that follows.

Change-Id: I23b7b6809f0b2c25ed1d59dd2d5429c30f1db89c
Reviewed-on: https://go-review.googlesource.com/27651
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-24 22:31:16 +00:00
Robert Griesemer
78bc418f1d cmd/compile: remove unused importimport function
Functionality is present in bimport.go in slightly modified form.

Change-Id: I6be79d91588873e6ba70d6ab07ba2caa12346dfc
Reviewed-on: https://go-review.googlesource.com/27672
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-24 20:28:21 +00:00
Keith Randall
a99f812cba cmd/objdump: implement objdump of .o files
Update goobj reader so it can provide all the information
necessary to disassemble .o (and .a) files.

Grab architecture of .o files from header.

.o files have relocations in them.  This CL also contains a simple
mechanism to disassemble relocations and add relocation info as an extra
column in the output.

Fixes #13862

Change-Id: I608fd253ff1522ea47f18be650b38d528dae9054
Reviewed-on: https://go-review.googlesource.com/24818
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-24 17:36:59 +00:00
Josh Bleecher Snyder
5bddca64a8 cmd/compile: minor cleanup in mapinit
Change-Id: I7d58d200f7e8b2c0a6e35371da0dafd9b44e9057
Reviewed-on: https://go-review.googlesource.com/26757
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-24 01:37:44 +00:00
Josh Bleecher Snyder
41943d9639 cmd/compile: convert getdyn int arg to bool
Passes toolstash -cmp.

Change-Id: I5b893b8b82b358534fd85542f05e3aa7e666bcd3
Reviewed-on: https://go-review.googlesource.com/26752
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-24 01:07:35 +00:00
Josh Bleecher Snyder
67bcee8d98 cmd/compile: convert Dodata to a bool, rename to IsStatic
Passes toolstash -cmp.

Change-Id: I2c204ec14b0a72b592fb336acdd4dff55650f7f6
Reviewed-on: https://go-review.googlesource.com/26751
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-24 00:56:54 +00:00
Josh Bleecher Snyder
a301b329e5 cmd/compile: simplify isglobal
Passes toolstash -cmp.

Change-Id: I16ec0c11096bf4c020cf41392effeb67436f32ba
Reviewed-on: https://go-review.googlesource.com/26750
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-24 00:52:58 +00:00
Jess Frazelle
c6e0c49b41 cmd/go: updates go get to return exit status 0 for test file only pkgs
Updates the behavior of `go get` to return exit status 0 when a
requested package only contains test files.

Fixes #15093

Change-Id: I76b80517d58748090f5e8c6f41178361e2d7ca54
Reviewed-on: https://go-review.googlesource.com/23314
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-23 23:49:34 +00:00