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

7428 Commits

Author SHA1 Message Date
Hyang-Ah Hana Kim
ec3daf0c62 cmd/dist: run testcshared test on linux/386
Change-Id: Iaa0fb133e5fc2078bfaf59ed721fd07a1a713ab3
Reviewed-on: https://go-review.googlesource.com/17075
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-20 04:22:35 +00:00
Hyang-Ah Hana Kim
cbc55971e2 cmd/go, cmd/link: enable -buildmode=c-shared on linux/386
All the heavy lifting was done by Michael Hudson-Doyle.

Change-Id: I176f15581055078854c2ad9a5807c4dcf0f8d8c5
Reviewed-on: https://go-review.googlesource.com/17074
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-20 03:49:13 +00:00
Rob Pike
997ed6fd3b cmd/go: make it clearer that go generate accepts all build flags
Just add one word to clarify that -n -v -x are not the only build flags supported.

Fixes #13237.

Change-Id: I880472639bf2fc1a0751a83041bc7ddd0c9e55f4
Reviewed-on: https://go-review.googlesource.com/17062
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-20 00:28:11 +00:00
Ian Lance Taylor
f2a0fc10c9 cmd/cgo: final docs for pointer passing
Update #12416.

Change-Id: I39eb0d1090c08ef9be9dc38d27abab62672cf664
Reviewed-on: https://go-review.googlesource.com/17064
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-20 00:19:48 +00:00
Ian Lance Taylor
5005a33987 cmd/cgo: put the real C function in the dynamic symbol table
In the past, cgo generated Go code and C code.  The C code was linked
into a shared library.  The Go code was built into an executable that
dynamically linked against that shared library.  C wrappers were
exported from the shared library, and the Go code called them.

It was all a long time ago, but in order to permit C code to call back
into Go, somebody implemented #pragma dynexport (https://golang.org/cl/661043)
to export a Go symbol into the dynamic symbol table.  Then that same
person added code to cgo to recognize //export comments
(https://golang.org/cl/853042).  The //export comments were implemented
by generating C code, to be compiled by GCC, that would refer to C code,
to be compiled by 6c, that would call the Go code.  The GCC code would
go into a shared library.  The code compiled by 6c would be in the Go
executable.  The GCC code needed to refer to the 6c code, so the 6c
function was marked with #pragma dynexport.  The important point here is
that #pragma dynexport was used to expose an internal detail of the
implementation of an exported function, because at the time it was
necessary.

Moving forward to today, cgo no longer generates a shared library and 6c
no longer exists.  It's still true that we have a function compiled by
GCC that refers to a wrapper function now written in Go.  In the normal
case today we are doing an external link, and we use a
//go:cgo_export_static function to make the Go wrapper function visible
to the C code under a known name.

The #pragma dynexport statement has become a //go:cgo_export_dynamic
comment on the Go code.  That comment only takes effect when doing
internal linking.  The comment tells the linker to put the symbol in the
dynamic symbol table.  That still makes sense for the now unusual case
of using internal linking with a shared library.

However, all the changes to this code have carefully preserved the
property that the //go:cgo_export_dynamic comment refers to an internal
detail of the implementation of an exported function.  That was
necessary a long time ago, but no longer makes sense.

This CL changes the code to put the actual C-callable function into the
dynamic symbol table.  I considered dropping the comment entirely, but
it turns out that there is even a test for this, so I preserved it.

Change-Id: I66a7958e366e5974363099bfaa6ba862ca327849
Reviewed-on: https://go-review.googlesource.com/17061
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-20 00:19:07 +00:00
Shenghou Ma
23791ee11d cmd/compile: set log prefix and suppress date
Fixes #13320.

Change-Id: I3a96a6707982629caf89656c479d096891783328
Reviewed-on: https://go-review.googlesource.com/17050
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-11-19 23:55:50 +00:00
Russ Cox
476aa95015 cmd/go: skip TestNoteReading2K on Windows
It's intended primarily as a torture test for OS X.
Apparently Windows can't take it.

Updates fix for #12327.

Change-Id: If2af249ea8e2f55bff8f232dce06172e6fef9f49
Reviewed-on: https://go-review.googlesource.com/17073
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-19 21:22:48 +00:00
Austin Clements
402e37d4a9 cmd/compile: special case nowritebarrierrec for allocm
allocm is a very unusual function: it is specifically designed to
allocate in contexts where m.p is nil by temporarily taking over a P.
Since allocm is used in many contexts where it would make sense to use
nowritebarrierrec, this commit teaches the nowritebarrierrec analysis
to stop at allocm.

Updates #10600.

Change-Id: I8499629461d4fe25712d861720dfe438df7ada9b
Reviewed-on: https://go-review.googlesource.com/17005
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-19 21:17:19 +00:00
Russ Cox
26119179fa cmd/go: fix loading of buildid on OS X executables
This is a bit of a belt-and-suspenders fix.
On OS X, we now parse the Mach-O file to find the __text section,
which is arguably the more proper fix. But it's a bit worrisome to
depend on a name like __text not changing, so we also read more
of the initial file (now 32 kB, up from 8 kB) and scan that too.

Fixes #12327.

Change-Id: I3a201a3dc278d24707109bb3961c3bdd8b8a0b7b
Reviewed-on: https://go-review.googlesource.com/17038
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-19 20:57:16 +00:00
Russ Cox
3ea668a0f2 cmd/dist: rewrite mkdeps.bash to work on OS X
My version of bash doesn't know what 'declare -A' means.

Change-Id: Icf6b0e60ebaea3feaa8661ec0423012f213b53e8
Reviewed-on: https://go-review.googlesource.com/17070
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-19 20:53:50 +00:00
Rob Pike
4d9f68028a cmd/asm: add doc.go
There was no documentation produced by "go doc cmd/asm".
Follow the style set by cmd/compile.

Fixes #13148.

Change-Id: I02e08ce2e7471f855bfafbbecee98ffdb7096995
Reviewed-on: https://go-review.googlesource.com/16997
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-19 20:49:27 +00:00
Russ Cox
8b1b81f463 cmd/compile: fix crash with -race on large expr containing string->[]byte conversion
The assumption is that there are no nested function calls in complex expressions.
For the most part that assumption is true. It wasn't for these calls inserted during walk.
Fix that.

I looked through all the calls to mkcall in walk and these were the only cases
that emitted calls, that could be part of larger expressions (like not delete),
and that were not already handled.

Fixes #12225.

Change-Id: Iad380683fe2e054d480e7ae4e8faf1078cdd744c
Reviewed-on: https://go-review.googlesource.com/17034
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-19 19:54:55 +00:00
Michael Matloob
45c3cf68b0 cmd/compile: identify the runtime pkg using myimportpath
Because there are now multiple packages that compose the runtime
we need to distinguish between the case where a runtime package
is being compiled versus the case the "runtime" package is being
compiled. In golang.org/cl/14204 I mistakenly used
  localpkg.Name == "runtime"
to check against the "runtime" package, but doing this would treat
a package with the path "foo.org/bar/runtime" as the runtime package.
The correct check is
  myimportpath == "runtime"
.

Change-Id: If90e95cef768d91206f2df1c06e27be876722e4e
Reviewed-on: https://go-review.googlesource.com/17059
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-19 19:50:03 +00:00
Ian Lance Taylor
0e2c635788 cmd/cgo, runtime: exported Go functions can't return a Go pointer
Update #12416.

Change-Id: Iccbcb12709d1ca9bea87274f44f93cfcebadb070
Reviewed-on: https://go-review.googlesource.com/17048
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-19 18:28:39 +00:00
Michael Hudson-Doyle
0fbf0955d4 cmd/internal/obj/x86: still use (fake) local exec TLS mode on android/386
golang.org/cl/16383 broke android/386 because by a sort of confluence of hacks
no TLS relocations were emitted at all when Flag_shared != 0. The hack in
runtime/cgo works as well in a PIE executable as it does with a position
dependent one, so the simplest fix is to still emit a R_TLS_LE reloc when goos
== "android".

A real fix is to use something more like the IE model code but loading the
offset from %gs to the thread local storage from a global variable rather than
from a location chosen by the system linker (this is how android/arm works).

Issue #9327.

Change-Id: I9fbfc890ec7fe191f80a595b6cf8e2a1fcbe3034
Reviewed-on: https://go-review.googlesource.com/17049
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-11-19 17:43:37 +00:00
Michael Hudson-Doyle
e8e0d906dc cmd/dist: run testshared on linux/386
Change-Id: I22d40248e83fcad5ab73c0d402183d06e91064c7
Reviewed-on: https://go-review.googlesource.com/16388
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-19 00:23:38 +00:00
Michael Hudson-Doyle
09d7de8d61 cmd/link, runtime: call addmoduledata when dynamically linking on linux/386
Change-Id: If1faa2bba28a4e9a8061693173797c4114a7d699
Reviewed-on: https://go-review.googlesource.com/16387
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-19 00:22:56 +00:00
Robert Griesemer
34cbccd341 cmd/compile/internal/gc: add line numbers for complit elts if needed (addresses TODO)
For #13243.

Change-Id: I802cef3dad5d1236e70d0cd52047008a6a7a311a
Reviewed-on: https://go-review.googlesource.com/17045
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:52:58 +00:00
Robert Griesemer
431c232842 cmd/compile/internal/gc: address TODO (better comment)
For #13243.

Change-Id: I544a8c44971fad126103157575e983ab528309bf
Reviewed-on: https://go-review.googlesource.com/17044
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:26:24 +00:00
Robert Griesemer
fe762b6466 cmd/compile/internal/gc: better error message for parenthesized go/defer exprs
Change-Id: Ie24d56422ae2196198a6c306716fa867c1442d6e
Reviewed-on: https://go-review.googlesource.com/17043
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:26:07 +00:00
Robert Griesemer
5500d46914 cmd/compile/internal/gc: fix incorrect parsing of &(T{}) when followed by {
Handling of &(T{}) assumed that the parser would not introduce ()'s.

Also: Better comments around handling of OPAREN syntax tree optimization.

Fixes #13261.

Change-Id: Ifc5047a0448f5e7d74cd42f6608b87dcc9c2f2fb
Reviewed-on: https://go-review.googlesource.com/17040
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:25:48 +00:00
Robert Griesemer
1a111ea2c7 cmd/compile/internal/gc: fix parsing of <-x (recv op vs recv-only chan)
Also:
- better error messages in some cases
- factored out function to produce syntax error at given line number

Fixes #13273.

Change-Id: I0192a94731cc23444680a26bd0656ef663e6da0b
Reviewed-on: https://go-review.googlesource.com/16992
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:22:56 +00:00
Michael Hudson-Doyle
342f17eaf7 cmd/internal/obj/x86, cmd/link: enable access to global data via GOT when -dynlink on 386
Change-Id: I97504a11291ee60e656efb7704e37387e864d74f
Reviewed-on: https://go-review.googlesource.com/16385
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 21:27:45 +00:00
Michael Hudson-Doyle
cb0393866a cmd/internal/obj/x86: position independent access to global data on 386 when -shared
This works by adding a call to __x86.get_pc_thunk.cx immediately before any
instruction that accesses global data and then assembling the instruction to
use the appropriate offset from CX instead of the absolute address. Some forms
cannot be assembled that way and are rewritten to load the address into CX
first.

-buildmode=pie works now, but is not yet tested.

Fixes #13201 (I think)

Change-Id: I32a8561e7fc9dd4ca6ae3b0e57ad78a6c50bf1f5
Reviewed-on: https://go-review.googlesource.com/17014
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 21:26:42 +00:00
Michael Hudson-Doyle
3c85e1b186 cmd/internal/obj/x86: factor rewriting to use GOT into separate function
I was prodded into doing this in review comments for the ARM version, and it's
going to make shared libs for 386 easier.

Change-Id: Id12de801b1425b8c6b5736fe91b418fc123a4e40
Reviewed-on: https://go-review.googlesource.com/17012
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-18 21:25:55 +00:00
Russ Cox
6bf794a36d cmd/link: link go.o first
Does not fix #12327 but nicer anyway.

Change-Id: I4ad730a4ca833d76957b7571895b3a08a6a530d4
Reviewed-on: https://go-review.googlesource.com/16964
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 19:00:45 +00:00
Russ Cox
918a2644f2 cmd/compile: fix Val vs Opt collision
Fixes #12686.

Change-Id: I7a9f49dbd1f60b1d0240de57787753b425f9548c
Reviewed-on: https://go-review.googlesource.com/17031
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 18:31:27 +00:00
Ian Lance Taylor
921e7dfd06 cmd/dist: don't run internal link tests on arm or darwin/arm64
Change-Id: I373a64fc30dee804d99e106d4627b780e1846917
Reviewed-on: https://go-review.googlesource.com/16999
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-18 17:35:27 +00:00
Ian Lance Taylor
8d2f60f8a8 cmd/link: add -libgcc option
An internal link may need the C compiler support library, libgcc.a.  Add
a -libgcc option to set the name of the compiler support library.  If
-libgcc is not used, run the compiler to find it.  Permit -libgcc=none
to skip using libgcc at all and hope for the best.

Change cmd/dist to not copy libgcc into the distribution.  Add tests to
ensure that all the standard packages that use cgo can be linked in
internal mode without using libgcc.  This ensures that somebody with a
Go installation without a C compiler can build programs.

Change-Id: I8ba35fb87ab0dd20e5cc0166b5f4145b04ce52a4
Reviewed-on: https://go-review.googlesource.com/16993
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-18 02:04:10 +00:00
Michael Hudson-Doyle
3bf61fb2e5 cmd/internal/obj/x86, cmd/link/internal/x86: support IE model TLS on linux/386
This includes the first parts of the general approach to PIC: load PC into CX
whenever it is needed. This is going to lead to large binaries and poor
performance but it's a start and easy to get right.

Change-Id: Ic8bf1d0a74284cca0d94a68cf75024e8ab063b4e
Reviewed-on: https://go-review.googlesource.com/16383
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 01:57:01 +00:00
Michael Hudson-Doyle
61da0e92d0 cmd/compile, cmd/compile/internal/x86: do not let regopt use CX in position independent code
We might be able to do better than this, but it's a start.

Change-Id: I80ebce9094e084a4746039106ccf1ad9c4b8bb7c
Reviewed-on: https://go-review.googlesource.com/16384
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 01:44:32 +00:00
Michael Hudson-Doyle
c8abb02178 cmd/go: enable -buildmode=pie on linux/386
Change-Id: Ie4cdf50fdaf7b368a189a84f4e2aea4cedd5ca7d
Reviewed-on: https://go-review.googlesource.com/17013
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 01:35:54 +00:00
Hyang-Ah Hana Kim
888aadfa60 cmd: enable android/386 build (buildmode=pie by default)
no buildmode=c-shared yet.

Update golang/go#9327.

Change-Id: I9989d954d574807bac105da401c3463607fe8a99
Reviewed-on: https://go-review.googlesource.com/16700
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-17 22:37:26 +00:00
Joe Tsai
07d48993f2 cmd/doc: fix strange indentation artifacts with unexported fields
The NamePos value was not being set, and would default to a value
of zero. This would cause the printing logic to get confused as
to where exactly to place the "Has unexported fields" string.

A trivial package changes from

<
type A struct {
	A int // A
	B int
			// B
	// Has unexported fields.
}
>

to

<
type A struct {
	A int // A
	B int // B
	// Has unexported fields.
}
>

Fixes #12971

Change-Id: I53b7799a1f1c0ad7dcaddff83d9aaeb1d6b7823e
Reviewed-on: https://go-review.googlesource.com/16286
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-11-17 20:51:19 +00:00
Keith Randall
4304fbc4d0 [dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Conflicts:
	src/cmd/compile/internal/gc/racewalk.go
	src/cmd/internal/obj/stack.go
	src/cmd/internal/obj/x86/obj6.go
	src/runtime/stack.go
	test/nilptr3.go
	test/nosplit.go

Change-Id: Ie6053eb1577fd73e8243651f25c0f1fc765ae660
2015-11-16 17:19:42 -08:00
Robert Griesemer
662ab8be31 cmd/compile/internal/gc: add dropped line correction again
The line correction when reporting a missing package clause
was removed before since it wasn't clear that it was needed.
Added it again because of issue 13267.

No explicit test case has been added to test/fixedbugs because
it would require a file that contains a single byte and such a
file doesn't fit the existing test harness. Instead documented
the problematic line in the parser for future reference.

Fixes #13267.

Change-Id: I590fe8f358042aab73acf16c2ed9567872b174f4
Reviewed-on: https://go-review.googlesource.com/16975
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:06:11 +00:00
Robert Griesemer
0133d24c94 cmd/compile/internal/gc: don't ignore EOF in new parser
Fixes #13274.
Fixes #13272.

Change-Id: Ie67a2c4671ee2b49831898fff7677cd65d780942
Reviewed-on: https://go-review.googlesource.com/16972
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:05:39 +00:00
Robert Griesemer
a20556bf56 cmd/compile/internal/gc: correctly use internal call to error reporting
Fixes #13266.

Change-Id: I31da922e0599989e52acf346374c2077b157ebb7
Reviewed-on: https://go-review.googlesource.com/16971
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:05:07 +00:00
Russ Cox
2c11164db5 cmd/compile: fix value range check for complex constants
Fixes #11590.

Change-Id: I4144107334604a2cc98c7984df3b5d4cde3d30af
Reviewed-on: https://go-review.googlesource.com/16920
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:48:47 +00:00
Russ Cox
292ad59291 cmd/compile: do not emit args_stackmap for func _
Fixes #11699.

Change-Id: I01bf506d76260bcdf828bbde52791e328aa441a5
Reviewed-on: https://go-review.googlesource.com/16921
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:38:52 +00:00
Russ Cox
247959d9b8 cmd/compile: reject identifiers beginning with non-ASCII digit
Fixes #11359.

Change-Id: I0fdfa410939f7e42020cbb19d74a67e1cc3cd610
Reviewed-on: https://go-review.googlesource.com/16919
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:38:42 +00:00
Russ Cox
f2eb3de636 cmd/compile: document -trimpath
Fixes #8999.

Change-Id: I1390605bdf908f59b596975ea51eb04bd03bbae0
Reviewed-on: https://go-review.googlesource.com/16918
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:38:34 +00:00
Ian Lance Taylor
9aed0b7e3d cmd/compile: add special case for testing first field of struct variable
The change to the write barrier in https://golang.org/cl/16899 means
that the compiler now emits tests of the first field of a struct.  That
was using a register that was not used before.  This change fixes that
for amd64 by adding a special case for the first field of a struct.

Update #12416.

Change-Id: Ia57baa62cd741592fbeb9be82f1e846be73d6edd
Reviewed-on: https://go-review.googlesource.com/16933
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-16 18:39:40 +00:00
Ian Lance Taylor
be1ef46775 runtime: add optional expensive check for invalid cgo pointer passing
If you set GODEBUG=cgocheck=2 the runtime package will use the write
barrier to detect cases where a Go program writes a Go pointer into
non-Go memory.  In conjunction with the existing cgo checks, and the
not-yet-implemented cgo check for exported functions, this should
reliably detect all cases (that do not import the unsafe package) in
which a Go pointer is incorrectly shared with C code.  This check is
optional because it turns on the write barrier at all times, which is
known to be expensive.

Update #12416.

Change-Id: I549d8b2956daa76eac853928e9280e615d6365f4
Reviewed-on: https://go-review.googlesource.com/16899
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-16 18:39:06 +00:00
Ian Lance Taylor
1860a0fa57 cmd/dist: check more GOOS/GOARCH combinations in mkdeps.bash
The current mkdeps.bash just checks for dependencies for GOOS=windows
with the current GOARCH.  This is not always accurate as some package
imports only happen on specific GOOS/GOARCH combinations.  Check a
selected, easily changed, combination of GOOS/GOARCH values.

This generates a deps.go identical to the one in the repository today.

Fixes #13221.

Change-Id: I96d67d49c8c63641d578acedbb28be807607db65
Reviewed-on: https://go-review.googlesource.com/16882
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-16 18:34:48 +00:00
Rahul Chaudhry
f7c7ed7c41 cmd/go: set buildmode=pie default for android/arm64.
Just like android/arm, android/arm64 refuses to execute non-PIE
binaries. In addition, starting from the M release (Marshmallow),
Android refuses to execute binaries with any text relocations
(this was just a warning in the L release). This makes "-shared"
necessary as well when building executables for Android.

Change-Id: Id8802de5be98ff472fc370f8d22ffbde316aaf1e
Reviewed-on: https://go-review.googlesource.com/16744
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 18:32:57 +00:00
Michael Hudson-Doyle
25a28da080 cmd/dist, cmd/go: run testshared on arm64
And enable PIE in the go tool.

Change-Id: Ibb60ccfe62518cde6e33080bbc78bfcbecff6a4e
Reviewed-on: https://go-review.googlesource.com/14000
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-15 23:41:28 +00:00
Michael Hudson-Doyle
4bae454d68 cmd/link: work around arm64 linker bugs with GOT relocations against local symbols
Change-Id: Ie14530c57720f1af1960ab77686b860e906058c6
Reviewed-on: https://go-review.googlesource.com/16582
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-15 23:40:59 +00:00
Michael Hudson-Doyle
3534e2bef4 cmd/internal/obj, cmd/link: access global data via a GOT in -dynlink mode on arm64
Change-Id: I6ca9406207e40c7c2c661075ccfe57b6600235cf
Reviewed-on: https://go-review.googlesource.com/13997
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-15 23:40:22 +00:00
Michael Hudson-Doyle
7af0839e11 cmd/go, runtime: always use position-independent code to invoke vsyscall helper on linux/386
golang.org/cl/16346 changed the runtime on linux/386 to invoke the vsyscall
helper via a PIC sequence (CALL 0x10(GS)) when dynamically linking. But it's
actually quite easy to make that code sequence work all the time, so do that,
and remove the ugly machinery that passed the buildmode from the go tool to the
assembly.

This means enlarging m.tls so that we can safely access 0x10(GS) (GS is set to
&m.tls + 4, so 0x10(GS) accesses m_tls[5]).

Change-Id: I1345c34029b149cb5f25320bf19a3cdd73a056fa
Reviewed-on: https://go-review.googlesource.com/16796
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-15 06:42:19 +00:00
Didier Spezia
0624fd3f14 cmd/compile: regenerate builtin.go
Following a recent change, file builtin.go is not up-to-date.
Generate it again by running go generate.

Fixes #13203

Change-Id: Ib91c5ccc93665c043da95c7d3783ce5d94e48466
Reviewed-on: https://go-review.googlesource.com/16821
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-14 22:17:20 +00:00
Shenghou Ma
3a96bf0d80 cmd/dist: disable shootout/spectralnorm on linux/mips64 builder
It is too slow with kernel FPU emulator.

Updates #12688.

Change-Id: Ib3a5adfeb46e894550231b14eb0f4fb20aecee11
Reviewed-on: https://go-review.googlesource.com/16922
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-14 21:43:49 +00:00
Ian Lance Taylor
754f707f5f cmd/link, cmd/go, cmd/dist: use copy of libgcc.a for internal linking
Change the linker to use a copy of the C compiler support library,
libgcc.a, when doing internal linking.  This will be used to satisfy any
undefined symbols referenced by host objects.

Change the dist tool to copy the support library into a new directory
tree under GOROOT/pkg/libgcc.  This ensures that libgcc is available
even when building Go programs on a system that has no C compiler.  The
C compiler is required when building the Go installation in the first
place, but is not required thereafter.

Change the go tool to not link libgcc into cgo objects.

Correct the linker handling of a weak symbol in an ELF input object to
not always create a new symbol, but to use an existing symbol if there
is one; this is necessary on freebsd-amd64, where libgcc contains a weak
definition of compilerrt_abort_impl.

Fixes #9510.

Change-Id: I1ab28182263238d9bcaf6a42804e5da2a87d8778
Reviewed-on: https://go-review.googlesource.com/16741
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-14 18:56:17 +00:00
Robert Griesemer
ac658a83c2 cmd/compile/internal/gc: consume at least one token in case of syntax error
Fixes #13248.

TBR: iant

Change-Id: Ic8b10704f945e6daef04bb38a00e249854b4ef19
Reviewed-on: https://go-review.googlesource.com/16930
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-11-14 05:40:52 +00:00
Russ Cox
d8dd9c714b cmd/dist: default to clang, not gcc, on freebsd
Fixes #11380.

Change-Id: I0a284ad2a46826ce82486479ea4e79f0f470292f
Reviewed-on: https://go-review.googlesource.com/16635
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-14 03:35:41 +00:00
Robert Griesemer
12126752cc cmd/compile: associate tracking issue numbers with TODOs
Comment changes only.

Change-Id: Ib365b3cd16af9995cb0a2cce48fbe35d73899438
Reviewed-on: https://go-review.googlesource.com/16898
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-14 01:21:18 +00:00
Robert Griesemer
59dc25730b cmd/compile: cleanup in parser (3)
Factored out functionality of dotname (was inlined in 3 places).

Change-Id: Ica782737c8decbb757465830b25ba87faa9115a4
Reviewed-on: https://go-review.googlesource.com/16897
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-14 01:19:54 +00:00
Robert Griesemer
8d733ecafb cmd/compile: cleanup in parser.go (2)
Inlined fntype, othertype, recvchantype, ptrtype into ntype
and simplified callers. Minor cleanups elsewhere (better names).

Change-Id: I54924969996641a802de00c078b4cd0eabfda8c1
Reviewed-on: https://go-review.googlesource.com/16894
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-14 01:19:31 +00:00
Robert Griesemer
18160e0740 cmd/compile: cleanup in parser.go
Inlined non_dcl_stmt in stmt since it was called only from there.

Change-Id: I616c41332cfd86bbf3493d0ce7b1256384215220
Reviewed-on: https://go-review.googlesource.com/16893
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-14 00:33:27 +00:00
Robert Griesemer
c8bc7f1abd cmd/compile: better syntax error handling for new parser
- better error messages
- better error recovery by advancing to "follow" token after error
- make sure that we make progress after all errors
- minor cleanups

Change-Id: Ie43b8b02799618d70dc8fc227fab3e4e9e0d8e3a
Reviewed-on: https://go-review.googlesource.com/16892
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-14 00:32:57 +00:00
Robert Griesemer
b569b87ca1 cmd/compile/internal/gc: recursive-descent parser
This is a translation of the yacc-based parser with adjustements
to make the grammar work for a recursive-descent parser followed
by cleanups and simplifications.

The yacc actions were mostly literally copied for correctness
with better temporary names.

A few of the syntax tests were adjusted for slightly different
error messages (it is very difficult to match the yacc-based
error messages in all cases, and sometimes the new parser could
produce better errors).

The new parser is enabled by default.
To switch back to the yacc-based parser, set -oldparser.
To hardwire the switch back, uncomment "oldparser = 1" in lex.go.

- passes all.bash
- ~18% reduced parse time per file on average for make.bash
- ~3% reduced compile time for building cmd/compile

Change-Id: Icb5651bb9d8b9f66261762d2c94a03793050d4ce
Reviewed-on: https://go-review.googlesource.com/16665
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-13 14:53:57 +00:00
Ian Lance Taylor
b5c1b5d7a0 cmd/go: fix build -n when adding to archive with gc toolchain
Fix the output of build -n when adding to an existing archive with the
gc toolchain by observing that we are, now, always doing that.  When
using the gc toolchain the archive is now always created by the Go
compiler, and never by the pack command.

No test because we have not historically tested build -n output.

Fixes #13118.

Change-Id: I3a5c43cf45169fa6c9581e4741309c77d2b6e58b
Reviewed-on: https://go-review.googlesource.com/16761
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-13 14:23:27 +00:00
David Crawshaw
9958a7b563 Revert "cmd/internal/obj/arm64, cmd/link: use two instructions rather than three for loads from memory"
This reverts commit 3a9bc571b0.

Breaks darwin/arm64.

Change-Id: Ib958beacabca48020a6a47332fbdec99d994060b
Reviewed-on: https://go-review.googlesource.com/16906
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2015-11-13 11:40:10 +00:00
Shenghou Ma
2a031e6a2a cmd/internal/obj/arm64: rewrite branches that are too far
Fixes #12540.

Change-Id: I7893fdc023145b0aca4b4c7df7e08e47edcf5bba
Reviewed-on: https://go-review.googlesource.com/16902
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-13 03:40:58 +00:00
Shenghou Ma
d42cc10283 cmd/dist: set timeout for go1 benchmark too
so that GO_TEST_TIMEOUT_SCALE can be applied too.
It's for the mips64 builder, which is so slow that the
go1 benchmark can't finish startup within 10 minutes.

Change-Id: I1b824eb0649460101b294fb442da784e872403e7
Reviewed-on: https://go-review.googlesource.com/16901
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-13 02:34:53 +00:00
Michael Hudson-Doyle
37ac54dc2b cmd/dist: run testshared on linux/ppc64le
Change-Id: I4d079d29408e5344701056c88882cfd3b3857478
Reviewed-on: https://go-review.googlesource.com/15973
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
2015-11-13 00:53:54 +00:00
Michael Hudson-Doyle
1ccefcd1b8 cmd/link, runtime: implement & call addmoduledata on ppc64le
Change-Id: I3980d82c7df95e69522c3d2c90311f89c6fef0e1
Reviewed-on: https://go-review.googlesource.com/15972
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-13 00:51:45 +00:00
Michael Hudson-Doyle
64fbca41c8 cmd/internal/obj/ppc64: avoid calling morestack via a PLT when dynamically linking
Change-Id: Ie79f72786b1d7154f1910e717a0faf354b913b89
Reviewed-on: https://go-review.googlesource.com/15970
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-13 00:36:22 +00:00
Michael Hudson-Doyle
2ac993107f cmd/internal/obj, cmd/link: access global data via GOT when dynlinking on ppc64le
Change-Id: I79c60241df6c785f35371e70c777a7bd6e93571c
Reviewed-on: https://go-review.googlesource.com/15968
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-13 00:25:21 +00:00
Michael Hudson-Doyle
9a476028c0 cmd/go, cmd/link: enable -buildmode=shared on linux/ppc64le
Change-Id: Ifba76413b8aa78a221385bf505b92a3a5fbc3d24
Reviewed-on: https://go-review.googlesource.com/16713
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-12 23:58:52 +00:00
Michael Hudson-Doyle
a35c85c0cc cmd/internal/obj, runtime: implement IE model TLS on ppc64le
This requires changing the tls access code to match the patterns documented in
the ABI documentation or the system linker will "optimize" it into ridiculousness.

With this change, -buildmode=pie works, although as it is tested in testshared,
the tests are not run yet.

Change-Id: I1efa6687af0a5b8db3385b10f6542a49056b2eb3
Reviewed-on: https://go-review.googlesource.com/15971
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 23:50:27 +00:00
Michael Hudson-Doyle
bd329d47d9 cmd/internal/obj, cmd/link: generate position independent loads of static data
Change-Id: I0a8448c2b69f5cfa6f099d772f5eb3412f853045
Reviewed-on: https://go-review.googlesource.com/15969
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 23:33:12 +00:00
Michael Hudson-Doyle
368d548417 cmd/compile, cmd/link, runtime: on ppc64x, maintain the TOC pointer in R2 when compiling PIC
The PowerPC ISA does not have a PC-relative load instruction, which poses
obvious challenges when generating position-independent code. The way the ELFv2
ABI addresses this is to specify that r2 points to a per "module" (shared
library or executable) TOC pointer. Maintaining this pointer requires
cooperation between codegen and the system linker:

 * Non-leaf functions leave space on the stack at r1+24 to save the TOC pointer.
 * A call to a function that *might* have to go via a PLT stub must be followed
   by a nop instruction that the system linker can replace with "ld r1, 24(r1)"
   to restore the TOC pointer (only when dynamically linking Go code).
 * When calling a function via a function pointer, the address of the function
   must be in r12, and the first couple of instructions (the "global entry
   point") of the called function use this to derive the address of the TOC
   for the module it is in.
 * When calling a function that is implemented in the same module, the system
   linker adjusts the call to skip over the instructions mentioned above (the
   "local entry point"), assuming that r2 is already correctly set.

So this changeset adds the global entry point instructions, sets the metadata so
the system linker knows where the local entry point is, inserts code to save the
TOC pointer at 24(r1), adds a nop after any call not known to be local and copes
with the odd non-local code transfer in the runtime (e.g. the stuff around
jmpdefer). It does not actually compile PIC yet.

Change-Id: I7522e22bdfd2f891745a900c60254fe9e372c854
Reviewed-on: https://go-review.googlesource.com/15967
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 23:18:58 +00:00
Michael Hudson-Doyle
c83c806535 cmd/internal/obj, cmd/link, runtime: use a larger stack frame on ppc64
The larger stack frames causes the nosplit stack to overflow so the next change
increases the stackguard.

Change-Id: Ib2b4f24f0649eb1d13e3a58d265f13d1b6cc9bf9
Reviewed-on: https://go-review.googlesource.com/15964
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 22:32:37 +00:00
Michael Hudson-Doyle
c1b6e392f5 cmd/internal/obj, cmd/link, runtime: increase stack limit to accommodate larger frames on ppc64x
Larger stack frames mean nosplit functions use more stack and so the limit
needs to increase.

The change to test/nosplit.go is a bit ugly but I can't really think of a
way to make it nicer.

Change-Id: I2616b58015f0b62abbd62951575fcd0d2d8643c2
Reviewed-on: https://go-review.googlesource.com/16504
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 22:32:16 +00:00
Shenghou Ma
b28eeea136 cmd/dist: copy textflag.h for runtime/internal/* too
Change-Id: I22216df83898e560cfe6d97344f05e3678c2db99
Reviewed-on: https://go-review.googlesource.com/16872
Reviewed-by: Michael Matloob <matloob@golang.org>
2015-11-12 19:57:46 +00:00
Michael Matloob
80d0b98d80 runtime/internal/atomic: delete arch1_*.go files
I made a copy of the per-arch _CacheLineSize definitons when checking in
runtime/internal/atomic. Now that runtime/internal/sys is checked in,
we can use the definition there.

Change-Id: I7242f6b633e4164f033b67ff471416b9d71c64d2
Reviewed-on: https://go-review.googlesource.com/16847
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-12 17:37:22 +00:00
Burcu Dogan
b619d5573e Revert "cmd/go: use shallow clones for new git checkouts"
This reverts commit bc1f9d20b4.

The current go-get strategy doesn't support cases that servers
cannot handle shallow clients.

Also, `go get -u` is broken and is not compatible with already
go-getted unshallow repos.

Fixes #13213.
Fixes #13206.

Change-Id: Ie89d7603d96d323db64ad82997793fda0972f709
Reviewed-on: https://go-review.googlesource.com/16832
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 17:27:32 +00:00
Michael Matloob
87a65f6ce7 cmd/compile: delete the runtime_internal_atomic.go builtin defs file
The file was automatically placed in the cl by a tool I had built.
Since the compiler doesn't hook into the atomic package, it's unnecessary.

Change-Id: I631fd876813b381bb12604865b00fc5b268dce84
Reviewed-on: https://go-review.googlesource.com/16844
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-12 17:27:28 +00:00
Russ Cox
7e72505173 cmd/dist: remove race binaries when rebuilding everything
Fixes #13214.

Change-Id: Id8fbb252b8beadb0b41f839dcd85d6165dea86a3
Reviewed-on: https://go-review.googlesource.com/16845
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-12 17:07:06 +00:00
Michael Matloob
432cb66f16 runtime: break out system-specific constants into package sys
runtime/internal/sys will hold system-, architecture- and config-
specific constants.

Updates #11647

Change-Id: I6db29c312556087a42e8d2bdd9af40d157c56b54
Reviewed-on: https://go-review.googlesource.com/16817
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 17:04:45 +00:00
Ian Lance Taylor
d54c35675c cmd/go: subdirs of runtime other than runtime/internal do depend on runtime
Correct an error in the last change: it caused runtime/cgo and
runtime/race to not depend on runtime.

Fixes #13214.

Change-Id: Ib48b3b5e9a74567ddfaccb7ab4a897ee2aedc2b8
Reviewed-on: https://go-review.googlesource.com/16837
Reviewed-by: Michael Matloob <matloob@golang.org>
2015-11-12 15:35:48 +00:00
Keith Randall
75102afce7 [dev.ssa] cmd/compile: better register allocation
Use a more precise computation of next use.  It properly
detects lifetime holes and deallocates values during those holes.
It also uses a more precise version of distance to next use which
affects which values get spilled.

Change-Id: I49eb3ebe2d2cb64842ecdaa7fb4f3792f8afb90b
Reviewed-on: https://go-review.googlesource.com/16760
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-11-12 15:31:11 +00:00
Yao Zhang
704f83184f cmd/dist: added support for GOARCH=mips64{,le}
Change-Id: I22ea3352ad0794fc611334c2f2ec5f1e894985ce
Reviewed-on: https://go-review.googlesource.com/14460
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-12 04:54:40 +00:00
Yao Zhang
b4501ac4a5 cmd/cgo: added support for GOARCH=mips64{,le}
The actual cgo is not supported for now. This is just the cgo command.

Change-Id: I25625100ee552971f47e681b7d613cba16a2132f
Reviewed-on: https://go-review.googlesource.com/14446
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-12 04:45:54 +00:00
Yao Zhang
d5cd4ab46a cmd/compile: added support for mips64{,le}
It is based on ppc64 compiler.

Change-Id: I15a101df05f2919ba5292136957ba0009227d067
Reviewed-on: https://go-review.googlesource.com/14445
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-12 04:44:20 +00:00
Yao Zhang
053c75411f cmd/link: added support for mips64{,le}
Only internal linking without cgo is supported for now.

Change-Id: Ie6074a8ff3ec13605b72028f2d60758034f87185
Reviewed-on: https://go-review.googlesource.com/14444
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-12 04:44:00 +00:00
Yao Zhang
43ea305435 cmd/asm: added support for GOARCH=mips64{,le}
Change-Id: I951387f88993715e86b6ab9f18d38ed5c691ee0f
Reviewed-on: https://go-review.googlesource.com/14443
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-12 04:43:42 +00:00
Yao Zhang
fa6a1ecd63 cmd/internal/obj/mips: added support for GOARCH=mips64{,le}
MIPS64 has 32 general purpose 64-bit integer registers (R0-R31), 32
64-bit floating point registers (F0-F31). Instructions are fixed-width,
and are 32-bit wide. Instructions are all in standard 1-, 2-, 3-operand
forms.

MIPS64-specific relocations are added. For this reason, test data of
cmd/newlink are regenerated.

No other changes are made to portable structures.

Branch delay slots are current filled with NOP instructions. The function
for instruction scheduling (try to fill the delay slot with a useful
instruction) is implemented but disabled for now.

Change-Id: Ic364999c7a33245260c1381fc26a2fa8972d38b3
Reviewed-on: https://go-review.googlesource.com/14442
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-12 04:42:44 +00:00
Michael Hudson-Doyle
4255b78c7d cmd/go: handle linking against a shared library that implicitly includes a package
If you say "go install -buildmode=shared a b" and package a depends on another
package c, package c is implicitly included in the resulting shared library (as
specified by "Go Execution Modes"). But if c depends on b, linking against this
shared library hangs, because the go tool doesn't know when computing c's
dependencies that c is part of the same shared library as c.

Fix this by tracking the shared library a package *is* in separately from the
shared library a package has been explicitly linked into.

Fixes #13044

Change-Id: Iacfedab24ae9731ed53d225678b447a2a888823c
Reviewed-on: https://go-review.googlesource.com/16338
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-12 00:08:07 +00:00
Michael Hudson-Doyle
9514285da9 cmd/compile/internal/x86: avoid CX in a couple of places in the int64 code
I want to use CX as a scratch register in position independent code and these
uses are easy to remove.

Change-Id: I9e3cb470d7f0000d85786c30bd769d9ec86d532a
Reviewed-on: https://go-review.googlesource.com/16382
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-11 23:44:50 +00:00
Michael Hudson-Doyle
cf125a36d5 cmd/link: fix size of filetab slice
The linker writes the number of file symbols (Nhistfile) to the filetab slice
and then Nhistfile offsets -- which means the slice contains Nhistfile+1
entries, not just Nhistfile.

I think this bug has been around since at least 1.4 but it's easier to trigger
with shared libraries and a tiny binary that only has a couple of functions in
it -- try go install -buildmode=shared std && go run -linkshared test/fixedbugs/issue4388.go.

Change-Id: I6c0f01f1e607b9b2b96872e37ffce81281911504
Reviewed-on: https://go-review.googlesource.com/16342
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-11 23:17:25 +00:00
Hyang-Ah Hana Kim
05c4c6e2f4 cmd,runtime: TLS setup for android/386
Same ugly hack as https://go-review.googlesource.com/15991.

Update golang/go#9327.

Change-Id: I58284e83268a15de95eabc833c3e01bf1e3faa2e
Reviewed-on: https://go-review.googlesource.com/16678
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-11 21:59:24 +00:00
Meng Zhuo
bc1f9d20b4 cmd/go: use shallow clones for new git checkouts
Currently go get will clone the full history of git repos.
We can improve the download waiting time/size by passing depth argument.

The docs about shallow clones and the --depth argument are here:
https://git-scm.com/docs/git-clone
https://git-scm.com/docs/git-pull

Fixes #13078

Change-Id: Ie891d905d9c77f6ecadf7dcd5b44b477f4e079e0
Reviewed-on: https://go-review.googlesource.com/16360
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-11 14:28:58 +00:00
Keith Randall
7807bda91d [dev.ssa] cmd/compile: be safer about uintptr/unsafe.Pointer conversions
Make sure that when a pointer value is live across a function
call, we save it as a pointer.  (And similarly a uintptr
live across a function call should not be saved as a pointer.)

Add a nasty test case.

This is probably what is preventing the merge from master
to dev.ssa.  Signs point to something like this bug happening
in mallocgc.

Change-Id: Ib23fa1251b8d1c50d82c6a448cb4a4fc28219029
Reviewed-on: https://go-review.googlesource.com/16830
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-11-11 05:26:49 +00:00
Ian Lance Taylor
9dcc58c3d1 cmd/cgo, runtime: add checks for passing pointers from Go to C
This implements part of the proposal in issue 12416 by adding dynamic
checks for passing pointers from Go to C.  This code is intended to be
on at all times.  It does not try to catch every case.  It does not
implement checks on calling Go functions from C.

The new cgo checks may be disabled using GODEBUG=cgocheck=0.

Update #12416.

Change-Id: I48de130e7e2e83fb99a1e176b2c856be38a4d3c8
Reviewed-on: https://go-review.googlesource.com/16003
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-10 22:22:10 +00:00
Robert Griesemer
50fa646776 cmd/compile/internal/gc: avoid potential endless loop in float printing
The compiler should not usually call Fconv with an infinity, but if
it does, Fconv will end in an endless loop. Test for infinities early.

Change-Id: I48f366466538b0bd26a851e01258725025babaff
Reviewed-on: https://go-review.googlesource.com/16777
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-10 20:36:52 +00:00
Ian Lance Taylor
2fdff9586b cmd/go: always use --whole-archive for gccgo packages
This is, in effect, what the gc toolchain does.  It fixes cases where Go
code refers to a C global variable; without this, if the global variable
was the only thing visible in the C code, the generated cgo file might
not get pulled in from the archive, leaving the Go variable
uninitialized.

This was reported against gccgo as https://gcc.gnu.org/PR68255 .

Change-Id: I3e769dd174f64050ebbff268fbbf5e6fab1e2a1b
Reviewed-on: https://go-review.googlesource.com/16775
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-10 20:22:13 +00:00
Michael Hudson-Doyle
07a6cbf58a cmd/dist, cmd/go, misc/cgo/testshared: update testshared and run it on arm
And enable PIE in cmd/go because that's all it seems to take.

Change-Id: Ie017f427ace5e91de333a9f7cba9684c4641dfd5
Reviewed-on: https://go-review.googlesource.com/14222
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-10 19:57:30 +00:00
Michael Hudson-Doyle
e6ceb92e1c cmd/internal/obj/arm: access global data via GOT on arm when -dynlink
Change-Id: I88034611f56cc06bb47b0c431075cc78ca8dbb09
Reviewed-on: https://go-review.googlesource.com/14188
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-10 19:57:05 +00:00
Michael Matloob
67faca7d9c runtime: break atomics out into package runtime/internal/atomic
This change breaks out most of the atomics functions in the runtime
into package runtime/internal/atomic. It adds some basic support
in the toolchain for runtime packages, and also modifies linux/arm
atomics to remove the dependency on the runtime's mutex. The mutexes
have been replaced with spinlocks.

all trybots are happy!
In addition to the trybots, I've tested on the darwin/arm64 builder,
on the darwin/arm builder, and on a ppc64le machine.

Change-Id: I6698c8e3cf3834f55ce5824059f44d00dc8e3c2f
Reviewed-on: https://go-review.googlesource.com/14204
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-10 17:38:04 +00:00
Keith Randall
74e568f43a [dev.ssa] cmd/compile: Deduplicate panic{index,slice,divide} calls
Panics are only distinguished by their type and line number, so
if we can trigger two of those panics in the same line, use the
same panic call.  For example, in a[i]+b[j] we need only one
panicindex call that both bounds checks can use.

Change-Id: Ia2b6d3b1a67f2775df05fb72b8a1b149833572b7
Reviewed-on: https://go-review.googlesource.com/16772
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-11-10 16:56:11 +00:00
Keith Randall
170589ee1c [dev.ssa] cmd/compile: some SSA optimizations
Some optimizations of things I've seen looking at generated code.
  (x+y)-x == y
  x-0 == x
The ptr portion of the constant string "" can be nil.

Also update TODO with recent changes.

Change-Id: I02c41ca2f9e9e178bf889058d3e083b446672dbe
Reviewed-on: https://go-review.googlesource.com/16771
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-11-10 16:55:44 +00:00
Michael Hudson-Doyle
6c967c0ad2 cmd/dist: run more cgo tests on ppc64x
Change-Id: I992655bb02690ad95122a9e4c45cbd0948b545a0
Reviewed-on: https://go-review.googlesource.com/14238
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-10 01:47:56 +00:00
Michael Hudson-Doyle
c155e59062 cmd/link: enable external linking on ppc64
Change-Id: Iffe8ccb55b2c555b2cb8c168cebfbfd5892212df
Reviewed-on: https://go-review.googlesource.com/14236
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-10 01:47:41 +00:00
Michael Hudson-Doyle
4e3deae96d cmd/link, runtime: arm64 implementation of addmoduledata
Change-Id: I62fb5b20d7caa51b77560a4bfb74a39f17089805
Reviewed-on: https://go-review.googlesource.com/13999
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-10 01:24:25 +00:00
Michael Hudson-Doyle
712ffc0861 cmd/link: look at the R_AARCH64_RELATIVE relocs to find the gcdata on arm64
Change-Id: I5a1864a27ad917aa65c8e65a133f6cc0a980d05f
Reviewed-on: https://go-review.googlesource.com/13998
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-09 22:52:48 +00:00
Michael Hudson-Doyle
3a9bc571b0 cmd/internal/obj/arm64, cmd/link: use two instructions rather than three for loads from memory
Reduces size of godoc .text section by about 75k (or 1.4%).

Change-Id: I65850aa569aefbddd6cb07c6ae1addcc39cab6a5
Reviewed-on: https://go-review.googlesource.com/13993
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-09 22:03:11 +00:00
Mohit Agarwal
a7d331b368 cmd/go: clean the directory path containing the packages
The heuristic for determining if the packages or commands are stale
fails as the mtime comparison happens even though the GOROOT and
current package paths are the same, since the path name isn't
canonicalized before the comparison (GOROOT is).

Fixes: #12690

Change-Id: Ia7d142fbbed8aac2bd2f71d1db4efd1f3ff5aece
Reviewed-on: https://go-review.googlesource.com/16483
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-09 21:13:22 +00:00
Robert Griesemer
0bad50f2a4 cmd/compile/internal/gc: fix go.y to match y.go
In https://go-review.googlesource.com/#/c/16554/ y.go was modified
manually, but go.y (which is the source for y.go) was not changed.

Change-Id: I1273801bfd1ac65b875f4465033b0d062abff0b7
Reviewed-on: https://go-review.googlesource.com/16745
Reviewed-by: Austin Clements <austin@google.com>
2015-11-09 20:38:39 +00:00
Michael Hudson-Doyle
1b4d28f8cf cmd/link, runtime: arm implementation of addmoduledata
Change-Id: I3975e10c2445e23c2798a7203a877ff2de3427c7
Reviewed-on: https://go-review.googlesource.com/14189
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-08 21:46:17 +00:00
Dominik Honnef
3953c1d84f cmd/go: send all go build -n output to stderr
Also change a -v print, for consistency.

Fixes #12913

Change-Id: I6cc067d9f8dac66b1f9d1a675e0fbe0528371d0d
Reviewed-on: https://go-review.googlesource.com/16737
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-08 21:26:17 +00:00
Michael Hudson-Doyle
2ffdbd7ce4 cmd/go, cmd/link: allow -buildmode=pie on linux/ppc64le
Change-Id: I0d0abbb9503c3a3c35d846fc0379836b2c483dea
Reviewed-on: https://go-review.googlesource.com/15962
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-08 20:31:26 +00:00
Michael Hudson-Doyle
5e1d0fcbed cmd/internal/obj, cmd/link: handle the fact that a few store/loads on ppc64 are DS form
Change-Id: I4fe1af48ec1cd8a23e2f7f2a0257dc989ff7aced
Reviewed-on: https://go-review.googlesource.com/14235
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-08 19:35:47 +00:00
Tamir Duberstein
bb20266c9d cmd/internal/ld: skip dwarf output if dsymutil no-ops
Fixes #11994.

Change-Id: Icee6ffa6e3a9d15b68b4ae9b2716d65ecbdba73a
Reviewed-on: https://go-review.googlesource.com/16702
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-08 19:33:35 +00:00
Dominik Honnef
53d42fbead cmd/asm/internal/lex: format error correctly
Error doesn't take a format string and appends its own newline. Phrase
the error like the other ones.

Change-Id: Ic3af857e5d4890207c74a6eb59a0d1067b503e1b
Reviewed-on: https://go-review.googlesource.com/16420
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-08 19:17:54 +00:00
Keith Randall
0bef88aa5f cmd/compile: mark duffzero as using X0, not AX
duffzero was changed to use X0 instead of AX in
CL 14408.  This was missed as part of that change.

Change-Id: I72fb0114cfbc035b83bfaa8631d27e6740da2652
Reviewed-on: https://go-review.googlesource.com/16717
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-08 04:57:30 +00:00
Ilya Tocar
321a40721b runtime: optimize indexbytebody on amd64
Use avx2 to compare 32 bytes per iteration.
Results (haswell):

name                    old time/op    new time/op     delta
IndexByte32-6             15.5ns ± 0%     14.7ns ± 5%   -4.87%        (p=0.000 n=16+20)
IndexByte4K-6              360ns ± 0%      183ns ± 0%  -49.17%        (p=0.000 n=19+20)
IndexByte4M-6              384µs ± 0%      256µs ± 1%  -33.41%        (p=0.000 n=20+20)
IndexByte64M-6            6.20ms ± 0%     4.18ms ± 1%  -32.52%        (p=0.000 n=19+20)
IndexBytePortable32-6     73.4ns ± 5%     75.8ns ± 3%   +3.35%        (p=0.000 n=20+19)
IndexBytePortable4K-6     5.15µs ± 0%     5.15µs ± 0%     ~     (all samples are equal)
IndexBytePortable4M-6     5.26ms ± 0%     5.25ms ± 0%   -0.12%        (p=0.000 n=20+18)
IndexBytePortable64M-6    84.1ms ± 0%     84.1ms ± 0%   -0.08%        (p=0.012 n=18+20)
Index32-6                  352ns ± 0%      352ns ± 0%     ~     (all samples are equal)
Index4K-6                 53.8µs ± 0%     53.8µs ± 0%   -0.03%        (p=0.000 n=16+18)
Index4M-6                 55.4ms ± 0%     55.4ms ± 0%     ~           (p=0.149 n=20+19)
Index64M-6                 886ms ± 0%      886ms ± 0%     ~           (p=0.108 n=20+20)
IndexEasy32-6             80.3ns ± 0%     80.1ns ± 0%   -0.21%        (p=0.000 n=20+20)
IndexEasy4K-6              426ns ± 0%      215ns ± 0%  -49.53%        (p=0.000 n=20+20)
IndexEasy4M-6              388µs ± 0%      262µs ± 1%  -32.42%        (p=0.000 n=18+20)
IndexEasy64M-6            6.20ms ± 0%     4.19ms ± 1%  -32.47%        (p=0.000 n=18+20)

name                    old speed      new speed       delta
IndexByte32-6           2.06GB/s ± 1%   2.17GB/s ± 5%   +5.19%        (p=0.000 n=18+20)
IndexByte4K-6           11.4GB/s ± 0%   22.3GB/s ± 0%  +96.45%        (p=0.000 n=17+20)
IndexByte4M-6           10.9GB/s ± 0%   16.4GB/s ± 1%  +50.17%        (p=0.000 n=20+20)
IndexByte64M-6          10.8GB/s ± 0%   16.0GB/s ± 1%  +48.19%        (p=0.000 n=19+20)
IndexBytePortable32-6    436MB/s ± 5%    422MB/s ± 3%   -3.27%        (p=0.000 n=20+19)
IndexBytePortable4K-6    795MB/s ± 0%    795MB/s ± 0%     ~           (p=0.940 n=17+18)
IndexBytePortable4M-6    798MB/s ± 0%    799MB/s ± 0%   +0.12%        (p=0.000 n=20+18)
IndexBytePortable64M-6   798MB/s ± 0%    798MB/s ± 0%   +0.08%        (p=0.011 n=18+20)
Index32-6               90.9MB/s ± 0%   90.9MB/s ± 0%   -0.00%        (p=0.025 n=20+20)
Index4K-6               76.1MB/s ± 0%   76.1MB/s ± 0%   +0.03%        (p=0.000 n=14+15)
Index4M-6               75.7MB/s ± 0%   75.7MB/s ± 0%     ~           (p=0.076 n=20+19)
Index64M-6              75.7MB/s ± 0%   75.7MB/s ± 0%     ~           (p=0.456 n=20+17)
IndexEasy32-6            399MB/s ± 0%    399MB/s ± 0%   +0.20%        (p=0.000 n=20+19)
IndexEasy4K-6           9.60GB/s ± 0%  19.02GB/s ± 0%  +98.19%        (p=0.000 n=20+20)
IndexEasy4M-6           10.8GB/s ± 0%   16.0GB/s ± 1%  +47.98%        (p=0.000 n=18+20)
IndexEasy64M-6          10.8GB/s ± 0%   16.0GB/s ± 1%  +48.08%        (p=0.000 n=18+20)

Change-Id: I46075921dde9f3580a89544c0b3a2d8c9181ebc4
Reviewed-on: https://go-review.googlesource.com/16484
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
Reviewed-by: Klaus Post <klauspost@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-06 15:16:28 +00:00
Keith Randall
ffb20631fc runtime: teach peephole optimizer that duffcopy clobbers X0
Duffcopy now uses X0, as of 5cf281a.  Teach the peephole
optimizer that duffcopy clobbers X0 so that it does not
rename registers use X0 across the duffcopy instruction.

Fixes #13171

Change-Id: I389cbf1982cb6eb2f51e6152ac96736a8589f085
Reviewed-on: https://go-review.googlesource.com/16715
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
2015-11-06 15:11:42 +00:00
Ian Lance Taylor
26263354a3 cmd/link: don't warn about unnamed symbols in .debug_str section
They reportedly occur with LLVM 3.7 on FreeBSD ARM.

Fixes #13139.

Change-Id: Ia7d053a8662696b1984e81fbd1d908c951c35a98
Reviewed-on: https://go-review.googlesource.com/16667
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-06 05:23:30 +00:00
David du Colombier
6083bd65f7 cmd/go: skip TestBuildOutputToDevNull on Plan 9
TestBuildOutputToDevNull was added in CL 16585.
However, copying to /dev/null couldn't work on Plan 9,
because /dev/null is a regular file. Since it's not
different from any other file, the logic in copyFile
couldn't distinguish it from another, already existing,
file, that we wouldn't want to overwrite.

Change-Id: Ie8d353f318fedfc7cfb9541fed00a2397e232592
Reviewed-on: https://go-review.googlesource.com/16691
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David du Colombier <0intro@gmail.com>
2015-11-05 22:57:16 +00:00
Michael Hudson-Doyle
10c0753761 cmd/internal/obj/ppc64: fix assembly of SRADCC with immediate
sradi and sradi. hide the top bit of their immediate argument apart from the
rest of it, but the code only handled the sradi case.

I'm pretty sure this is the only instruction missing (a couple of the rotate
instructions encode their immediate the same way but their handling looks OK).

This fixes the failure of "GOARCH=amd64 ~/go/bin/go install -v runtime" as
reported in the bug.

Fixes #11987

Change-Id: I0cdefcd7a04e0e8fce45827e7054ffde9a83f589
Reviewed-on: https://go-review.googlesource.com/16710
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-05 22:54:21 +00:00
David du Colombier
b4447a1e81 cmd/go: skip TestGoGenerateEnv on Plan 9
TestGoGenerateEnv was added in CL 16537.
However, Plan 9 doesn't have the env command.

Change-Id: I5f0c937a1b9b456dcea41ceac7865112f2f65c45
Reviewed-on: https://go-review.googlesource.com/16690
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David du Colombier <0intro@gmail.com>
2015-11-05 21:29:17 +00:00
Ian Lance Taylor
321cf6f86d cmd/go: change ar argument to rc
Put 'r' first because that is the command, and 'c' is the modifier.
Keep 'c' because it means to not warn when creating an archive.
Drop 'u' because it is unnecessary and fails on Arch Linux.

No test because this is only for gccgo (I tested it manually).

Fixes #12310.

Change-Id: Id740257fb1c347dfaa60f7d613af2897dae2c059
Reviewed-on: https://go-review.googlesource.com/16664
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-05 16:16:41 +00:00
Ilya Tocar
967564be7e runtime: optimize string comparison on amd64
Use AVX2 if possible.
Results below (haswell):

name                            old time/op    new time/op     delta
CompareStringEqual-6              8.77ns ± 0%     8.63ns ± 1%   -1.58%        (p=0.000 n=20+19)
CompareStringIdentical-6          5.02ns ± 0%     5.02ns ± 0%     ~     (all samples are equal)
CompareStringSameLength-6         7.51ns ± 0%     7.51ns ± 0%     ~     (all samples are equal)
CompareStringDifferentLength-6    1.56ns ± 0%     1.56ns ± 0%     ~     (all samples are equal)
CompareStringBigUnaligned-6        124µs ± 1%      105µs ± 5%  -14.99%        (p=0.000 n=20+18)
CompareStringBig-6                 112µs ± 1%      103µs ± 0%   -7.87%        (p=0.000 n=20+17)

name                            old speed      new speed       delta
CompareStringBigUnaligned-6     8.48GB/s ± 1%   9.98GB/s ± 5%  +17.67%        (p=0.000 n=20+18)
CompareStringBig-6              9.37GB/s ± 1%  10.17GB/s ± 0%   +8.54%        (p=0.000 n=20+17)

Change-Id: I1c949626dd2aaf9f633e3c888a9df71c82eed7e1
Reviewed-on: https://go-review.googlesource.com/16481
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Klaus Post <klauspost@gmail.com>
2015-11-05 15:42:33 +00:00
Matthew Dempsky
7bb2a7d63b cmd/dist: remove vestigial -s flag
Fixes #12002.

Change-Id: I7262f4520560ac158fc2ee3ce1d2f7a488d40354
Reviewed-on: https://go-review.googlesource.com/16666
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-11-05 03:33:08 +00:00
Ian Lance Taylor
9496815598 cmd/go: put all generate variables in the environment
Fixes #13124.

Change-Id: I8a824156c84016504d29dc2dd2d522149b189be8
Reviewed-on: https://go-review.googlesource.com/16537
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-05 01:36:43 +00:00
David Crawshaw
dc9ad5861d cmd/vet: use testenv
Fix for iOS builder.

Change-Id: I5b6c977b187446c848182a9294d5bed6b5f9f6e4
Reviewed-on: https://go-review.googlesource.com/16633
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-11-04 15:59:10 +00:00
Mohit Agarwal
76811213d7 cmd/go: check if destination is a regular file
builder.copyFile ensures that the destination is an object file.  This
wouldn't be true if we are not writing to a regular file and the copy
fails.  Check if the destination is an object file only if we are
writing to a regular file.  While removing the file, ensure that it is a
regular file so that device files and such aren't removed when running
as a user with suggicient privileges.

Fixes #12407

Change-Id: Ie86ce9770fa59aa56fc486a5962287859b69db3d
Reviewed-on: https://go-review.googlesource.com/16585
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-04 15:28:57 +00:00
Austin Clements
3a765430c1 cmd/compile: add go:nowritebarrierrec annotation
This introduces a recursive variant of the go:nowritebarrier
annotation that prohibits write barriers not only in the annotated
function, but in all functions it calls, recursively. The error
message gives the shortest call stack from the annotated function to
the function containing the prohibited write barrier, including the
names of the functions and the line numbers of the calls.

To demonstrate the annotation, we apply it to gcmarkwb_m, the write
barrier itself.

This is a new annotation rather than a modification of the existing
go:nowritebarrier annotation because, for better or worse, there are
many go:nowritebarrier functions that do call functions with write
barriers. In most of these cases this is benign because the annotation
was conservative, but it prohibits simply coopting the existing
annotation.

Change-Id: I225ca483c8f699e8436373ed96349e80ca2c2479
Reviewed-on: https://go-review.googlesource.com/16554
Reviewed-by: Keith Randall <khr@golang.org>
2015-11-04 14:42:04 +00:00
Ian Lance Taylor
2780abd645 cmd/cgo: add a missing newline in writeExports
The code works without the newline, but it looks funny:

func _cgoexp_15afe6549f62_GoFn(a unsafe.Pointer, n int32) {	fn := GoFn

This adds a newline after the '{'.

Change-Id: I6c465abe16f47924426d1b22b91004b3a3586ebd
Reviewed-on: https://go-review.googlesource.com/16612
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-04 01:38:09 +00:00
Ian Lance Taylor
9179c9cb5c cmd/compile: make sure instrumented call has type width
The width of the type of an external variable defined with a type
literal may not be set when the instrumentation pass is run.  There are
two cases in the standard library that fail without the call to dowidth:

../../../src/encoding/base32/base32.go:322: constant -1000000000 overflows uintptr
../../../src/encoding/base32/base32.go:329: constant -1000000000 overflows uintptr
../../../src/encoding/json/encode.go:385: constant -1000000000 overflows uintptr
../../../src/encoding/json/encode.go:387: constant -1000000000 overflows uintptr

Change-Id: I7c3334f7decdb7488595ffe4090cd262d7334283
Reviewed-on: https://go-review.googlesource.com/16331
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-03 23:42:06 +00:00
Keith Randall
d19bfc3b68 [dev.ssa] cmd/compile: Handle ONOT in conditionals as well
Might as well, for a && !(b && c) and the like.

Change-Id: I2548b6e6ee5870e074bcef6edd56a7db6e81d70f
Reviewed-on: https://go-review.googlesource.com/16600
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
2015-11-03 18:36:14 +00:00
Keith Randall
02f4d0a130 [dev.ssa] cmd/compile: start arguments as spilled
Declare a function's arguments as having already been
spilled so their use just requires a restore.

Allow spill locations to be portions of larger objects the stack.
Required to load portions of compound input arguments.

Rename the memory input to InputMem.  Use Arg for the
pre-spilled argument values.

Change-Id: I8fe2a03ffbba1022d98bfae2052b376b96d32dda
Reviewed-on: https://go-review.googlesource.com/16536
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-11-03 17:29:40 +00:00
Keith Randall
582baae22a [dev.ssa] cmd/compile: Do pointer arithmetic with int, not uintptr
Be more consistent about this.  There's no reason to do the
pointer arithmetic on a different type, as sizeof(int) >=
sizeof(ptr) on all of our platforms.  It simplifies our
rewrite rules also, except for a few that need duplication.

Add some more constant folding to get constant indexing and
slicing to fold down to nothing.

Change-Id: I3e56cdb14b3dc1a6a0514f0333e883f92c19e3c7
Reviewed-on: https://go-review.googlesource.com/16586
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-11-03 17:28:12 +00:00
Keith Randall
991873116e [dev.ssa] cmd/compile: better ANDAND and OROR in IF and FOR
For the statement

    if a && b { target }

the old code allocated a new variable v and did:

    v = a
    if a {
       v = b
    }
    if v { goto target }

The new code does:

    if a {
      if b { goto target }
    }

The new arrangement tends to generate much more efficient code.  In
particular, there is no temporary variable and there is only one join
point instead of two.

The old code is still used for ANDAND and OROR which are not
direct descendents of IF or FOR statements.

Change-Id: I082f246d27c823c6f32d1287300e4b0911607507
Reviewed-on: https://go-review.googlesource.com/16584
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-11-03 17:22:27 +00:00
Michael Hudson-Doyle
ebafc80eba cmd/link: remove duplicate symtab entry for global functions
golang.org/cl/16436 added a local symbol for every global function, but also
added a duplicate entry for the global symbol. Surprisingly this hasn't caused
any noticeable problems, but it's still wrong.

Change-Id: Icd3906760f8aaf7bef31ffd4f2d866d73d36dc2c
Reviewed-on: https://go-review.googlesource.com/16581
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-02 23:07:12 +00:00
Ilya Tocar
0e23ca41d9 bytes: speed up Compare() on amd64
Use AVX2 if available.
Results (haswell), below:

name                           old time/op    new time/op     delta
BytesCompare1-6                  11.4ns ± 0%     11.4ns ± 0%     ~     (all samples are equal)
BytesCompare2-6                  11.4ns ± 0%     11.4ns ± 0%     ~     (all samples are equal)
BytesCompare4-6                  11.4ns ± 0%     11.4ns ± 0%     ~     (all samples are equal)
BytesCompare8-6                  9.29ns ± 2%     8.76ns ± 0%   -5.72%        (p=0.000 n=16+17)
BytesCompare16-6                 9.29ns ± 2%     9.20ns ± 0%   -1.02%        (p=0.000 n=20+16)
BytesCompare32-6                 11.4ns ± 1%     11.4ns ± 0%     ~           (p=0.191 n=20+20)
BytesCompare64-6                 14.4ns ± 0%     13.1ns ± 0%   -8.68%        (p=0.000 n=20+20)
BytesCompare128-6                20.2ns ± 0%     18.5ns ± 0%   -8.27%        (p=0.000 n=16+20)
BytesCompare256-6                29.3ns ± 0%     24.5ns ± 0%  -16.38%        (p=0.000 n=16+16)
BytesCompare512-6                46.8ns ± 0%     37.1ns ± 0%  -20.78%        (p=0.000 n=18+16)
BytesCompare1024-6               82.9ns ± 0%     62.3ns ± 0%  -24.86%        (p=0.000 n=20+14)
BytesCompare2048-6                155ns ± 0%      112ns ± 0%  -27.74%        (p=0.000 n=20+20)
CompareBytesEqual-6              10.1ns ± 1%     10.0ns ± 1%     ~           (p=0.527 n=20+20)
CompareBytesToNil-6              10.0ns ± 2%      9.4ns ± 0%   -6.57%        (p=0.000 n=20+17)
CompareBytesEmpty-6              8.76ns ± 0%     8.76ns ± 0%     ~     (all samples are equal)
CompareBytesIdentical-6          8.76ns ± 0%     8.76ns ± 0%     ~     (all samples are equal)
CompareBytesSameLength-6         10.6ns ± 1%     10.6ns ± 1%     ~           (p=0.240 n=20+20)
CompareBytesDifferentLength-6    10.6ns ± 0%     10.6ns ± 1%     ~           (p=1.000 n=20+20)
CompareBytesBigUnaligned-6        132±s ± 1%      105±s ± 1%  -20.61%        (p=0.000 n=20+18)
CompareBytesBig-6                 125±s ± 1%      105±s ± 1%  -16.31%        (p=0.000 n=20+20)
CompareBytesBigIdentical-6       8.13ns ± 0%     8.13ns ± 0%     ~     (all samples are equal)

name                           old speed      new speed       delta
CompareBytesBigUnaligned-6     7.94GB/s ± 1%  10.01GB/s ± 1%  +25.96%        (p=0.000 n=20+18)
CompareBytesBig-6              8.38GB/s ± 1%  10.01GB/s ± 1%  +19.48%        (p=0.000 n=20+20)
CompareBytesBigIdentical-6      129TB/s ± 0%    129TB/s ± 0%   +0.01%        (p=0.003 n=17+19)

Change-Id: I820f31bab4582dd4204b146bb077c0d2f24cd8f5
Reviewed-on: https://go-review.googlesource.com/16434
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
Reviewed-by: Klaus Post <klauspost@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2015-11-02 18:39:38 +00:00
David Crawshaw
cf73357e37 cmd/link: concurrent obj copy for external linking
Change-Id: I630ae29ecb39252642883398cc51d49133c6f3d7
Reviewed-on: https://go-review.googlesource.com/16451
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-02 17:52:55 +00:00
Michael Hudson-Doyle
35d71d6727 cmd/go, runtime: define GOBUILDMODE_shared rather than shared when dynamically linking
To avoid collisions with what existing code may already be doing.

Change-Id: Ice639440aafc0724714c25333d90a49954372230
Reviewed-on: https://go-review.googlesource.com/16503
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-01 19:52:33 +00:00
Ian Lance Taylor
914db9f060 cmd/link: support new 386/amd64 relocations
The GNU binutils recently picked up support for new 386/amd64
relocations.  Add support for them in the Go linker when doing an
internal link.

The 386 relocation R_386_GOT32X was proposed in
https://groups.google.com/forum/#!topic/ia32-abi/GbJJskkid4I .  It can
be treated as identical to the R_386_GOT32 relocation.

The amd64 relocations R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX were
proposed in
https://groups.google.com/forum/#!topic/x86-64-abi/n9AWHogmVY0 .  They
can both be treated as identical to the R_X86_64_GOTPCREL relocation.

The purpose of the new relocations is to permit additional linker
relaxations in some cases.  We do not attempt to support those cases.

While we're at it, remove the unused and in some cases out of date
_COUNT names from ld/elf.go.

Fixes #13114.

Change-Id: I34ef07f6fcd00cdd2996038ecf46bb77a49e968b
Reviewed-on: https://go-review.googlesource.com/16529
Reviewed-by: Minux Ma <minux@golang.org>
2015-10-31 23:22:58 +00:00
David Chase
729abfa35c [dev.ssa] cmd/compile: default compile+test with SSA
Some tests disabled, some bifurcated into _ssa and not,
with appropriate logging added to compiler.

"tests/live.go" in particular needs attention.

SSA-specific testing removed, since it's all SSA now.

Added "-run_skips" option to tests/run.go to simplify
checking whether a test still fails (or how it fails)
on a skipped platform.

The compiler now compiles with SSA by default.
If you don't want SSA, specify GOSSAHASH=n (or N) as
an environment variable.  Function names ending in "_ssa"
are always SSA-compiled.

GOSSAFUNC=fname retains its "SSA for fname, log to ssa.html"
GOSSAPKG=pkg only has an effect when GOSSAHASH=n
GOSSAHASH=10101 etc retains its name-hash-matching behavior
for purposes of debugging.

See #13068

Change-Id: I8217bfeb34173533eaeb391b5f6935483c7d6b43
Reviewed-on: https://go-review.googlesource.com/16299
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2015-10-30 20:35:20 +00:00
Marvin Stenger
8e7a3ea11e cmd/compile/internal: named types for Etype and Op in struct Node
Type Op is enfored now.
Type EType will need further CLs.
Added TODOs where Node.EType is used as a union type.
The TODOs have the format `TODO(marvin): Fix Node.EType union type.`.

Furthermore:
-The flag of Econv function in fmt.go is removed, since unused.
-Some cleaning along the way, e.g. declare vars first when getting initialized.

Passes go build -toolexec 'toolstash -cmp' -a std.

Fixes #11846

Change-Id: I908b955d5a78a195604970983fb9194bd9e9260b
Reviewed-on: https://go-review.googlesource.com/14956
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
2015-10-30 20:12:37 +00:00
Robert Griesemer
ddbc802b07 cmd/compile/internal/gc: fix complex literal overflow
Change-Id: Ibb15282a2baeb58439b085d70b82797d8c71de36
Reviewed-on: https://go-review.googlesource.com/16502
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-30 18:40:31 +00:00
Quentin Perez
70119accdf cmd/link/internal/ld: fix extra arguments Errorf
lib.go:1309
lib.go:1313
lib.go:1317
lib.go:1325

Change-Id: Ic3d3282d836c28f8bdeb5ce52fb7c018450871b9
Reviewed-on: https://go-review.googlesource.com/16473
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-30 17:23:13 +00:00
Todd Neal
cdc36252fe [dev.ssa] cmd/compile/internal/ssa: rewrite rules for const comparisons
Shaves ~8k off the go binary on darwin x64.

Change-Id: I73396af44ae28cd4cfc675290d6858f304d45b76
Reviewed-on: https://go-review.googlesource.com/16456
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-30 03:49:30 +00:00
Todd Neal
a92543e1a1 cmd/compile: add support for a go:noinline directive
Some tests need to disable inlining of a function.  It's currently done
in one of a few ways (adding a function call, an empty switch, or a
defer).  Add support for a less fragile 'go:noinline' directive that
prevents inlining.

Fixes #12312

Change-Id: Ife444e13361b4a927709d81aa41e448f32eec8d4
Reviewed-on: https://go-review.googlesource.com/13911
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-10-29 23:16:27 +00:00
Michael Hudson-Doyle
c9b8cab16c cmd/internal/obj, cmd/link, runtime: handle TLS more like a platform linker on ppc64
On ppc64x, the thread pointer, held in R13, points 0x7000 bytes past where
thread-local storage begins (presumably to maximize the amount of storage that
can be accessed with a 16-bit signed displacement). The relocations used to
indicate thread-local storage to the platform linker account for this, so to be
able to support external linking we need to change things so the linker applies
this offset instead of the runtime assembly.

Change-Id: I2556c249ab2d802cae62c44b2b4c5b44787d7059
Reviewed-on: https://go-review.googlesource.com/14233
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2015-10-29 22:24:29 +00:00
Keith Randall
d04f38e3ee [dev.ssa] cmd/compile: flag recomputing: find original values correctly
We "spill" flag values by recomputing them from their original
inputs.  The "find original inputs" part of the algorithm was
a hack.  It was broken by rematerialization.  This change does
the real job of keeping track of original values for each
spill/restore/flagrecompute/rematerialization we issue.

Change-Id: I95088326a4ee4958c98148b063e518c80e863e4c
Reviewed-on: https://go-review.googlesource.com/16500
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-29 21:59:10 +00:00
Michael Hudson-Doyle
d821ae2a9e cmd/internal/obj, cmd/link: simplify ppc64 archreloc now that the original value is passed to it
And get rid of the stupid game of encoding the instruction in the addend.

Change-Id: Ib4de7515196cbc1e63b4261b01931cf02a44c1e6
Reviewed-on: https://go-review.googlesource.com/14055
Reviewed-by: Russ Cox <rsc@golang.org>
2015-10-29 20:46:23 +00:00
Michael Hudson-Doyle
51586aadfb cmd/compile, cmd/go, cmd/link: enable -buildmode=shared and related flags on linux/arm64
Change-Id: Ibddbbf6f4a5bd336a8b234d40fad0fcea574cd6e
Reviewed-on: https://go-review.googlesource.com/13994
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-29 19:27:47 +00:00
Michael Hudson-Doyle
c34fb3cfc6 cmd/link: always resolve functions locally when linking dynamically
When dynamically linking, we want references to functions defined
in this module to always be to the function object, not to the
PLT. We force this by writing an additional local symbol for
every global function symbol and making all relocations against
the global symbol refer to this local symbol instead. This is
approximately equivalent to the ELF linker -Bsymbolic-functions
option, but that is buggy on several platforms.

Change-Id: Ie6983eb4d1947f8543736fd349f9a90df3cce91a
Reviewed-on: https://go-review.googlesource.com/16436
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-29 19:19:07 +00:00
David Crawshaw
ab7e82ef3b cmd/go: buildmode=c-shared support for linux/arm64
Change-Id: Ic826dc25b5203b2e9fc253d6fe997e4b41de3789
Reviewed-on: https://go-review.googlesource.com/16453
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-29 16:25:37 +00:00
Dominik Honnef
85a6a9771d cmd/go: use t.Fatalf for formatted errors
Change-Id: I657588ccc4a87e075d15acb9f4cd1e417bbd7960
Reviewed-on: https://go-review.googlesource.com/16421
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-29 02:38:32 +00:00
Michael Hudson-Doyle
c6f280584c cmd/go: implicitly include math in a shared library on arm
In the same manner in which runtime/cgo is included on other architectures.

Change-Id: I90a5ad8585248b2566d763d33994a600508d89cb
Reviewed-on: https://go-review.googlesource.com/14221
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-29 00:37:32 +00:00
Michael Hudson-Doyle
78c05b8657 cmd/compile, cmd/go: enable -buildmode=shared and related flags on linux/arm
Change-Id: I20840632771a250fb279df64d394135994482af8
Reviewed-on: https://go-review.googlesource.com/14186
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-10-28 23:46:56 +00:00
Todd Neal
74180dd7da [dev.ssa] cmd/compile/internal/ssa: reuse Aux values for PEXTERN
This improves cse and works correctly now that divide by zero is checked
explicitly.

Change-Id: If54fbe403ed5230b897afc5def644ba9f0056dfd
Reviewed-on: https://go-review.googlesource.com/16454
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-28 23:12:28 +00:00
Hyang-Ah Hana Kim
bcc5c6aa50 cmd/go: allow -buildmode=pie for android/amd64.
For golang/go#10743 golang/go#10807

Change-Id: I35dedb52e2b47fe7ffc655d01f22ac05fe830bde
Reviewed-on: https://go-review.googlesource.com/16396
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-10-28 20:55:29 +00:00
Hyang-Ah Hana Kim
26d0b00536 cmd/go: enable android/amd64 build.
For golang/go#10743

Change-Id: Iec047821147a0e28edebf875fefe25993785702b
Reviewed-on: https://go-review.googlesource.com/15994
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-10-28 20:55:13 +00:00
Hyang-Ah Hana Kim
dfc8649854 runtime, cmd: TLS setup for android/amd64.
Android linker does not handle TLS for us. We set up the TLS slot
for g, as darwin/386,amd64 handle instead. This is disgusting and
fragile. We will eventually fix this ugly hack by taking advantage
of the recent TLS IE model implementation. (Instead of referencing
an GOT entry, make the code sequence look into the TLS variable that
holds the offset.)

The TLS slot for g in android/amd64 assumes a fixed offset from %fs.
See runtime/cgo/gcc_android_amd64.c for details.

For golang/go#10743

Change-Id: I1a3fc207946c665515f79026a56ea19134ede2dd
Reviewed-on: https://go-review.googlesource.com/15991
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-10-28 20:54:28 +00:00
Keith Randall
a347ab7cd1 [dev.ssa] cmd/compile: split op rewrites into separate functions
The single value rewrite function is too big.  Some compilers
fail on it (out of memory, branch offset too large).  Break it
up into a rewrite function per op.

Change-Id: Iede697c8a1a3a22b485cd0dc85d3e233160c89c2
Reviewed-on: https://go-review.googlesource.com/16347
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2015-10-28 20:07:22 +00:00
Keith Randall
e514021153 [dev.ssa] cmd/compile: fix printing of live information
SSA generates ACALL assembly with the target in a *Sym.
The old compiler generates both that *Sym and a *Node.
Use the *Sym to print the live info so it works with both compilers.

Change-Id: I0b12a161f83e76638604358c21b9f5abb31ce950
Reviewed-on: https://go-review.googlesource.com/16432
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-10-28 19:52:34 +00:00
Michael Hudson-Doyle
80d9106487 cmd/internal/obj, cmd/link: support inital-exec TLS on arm64
Change-Id: Iaf9159a68fa395245bc20ccb4a2a377f89371a7e
Reviewed-on: https://go-review.googlesource.com/13996
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-10-28 19:51:28 +00:00
Michael Hudson-Doyle
72180c3b82 cmd/internal/obj, cmd/link, runtime: native-ish support for tls on arm64
Fixes #10560

Change-Id: Iedffd9c236c4fbb386c3afc52c5a1457f96ef122
Reviewed-on: https://go-review.googlesource.com/13991
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-10-28 19:51:05 +00:00
David Chase
18559e2da7 [dev.ssa] cmd/compile: make zero-divide panic from div/mod explicit
Added an explicit compare-zero and branch-to-panic for
integer division and mod so that other optimizations will
not be fooled by their implicit panics.

Change-Id: Ibf96f636b541c0088861907c537a6beb4b99fa4c
Reviewed-on: https://go-review.googlesource.com/16450
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-28 19:31:11 +00:00
Keith Randall
c24681ae2e [dev.ssa] cmd/compile: remember names of values
For debugging, spill values to named variables instead of autotmp_
variables if possible.  We do this by keeping a name -> value map
for each function, keep it up-to-date during deadcode elim, and use
it to override spill decisions in stackalloc.

It might even make stack frames a bit smaller, as it makes it easy
to identify a set of spills which are likely not to interfere.

This just works for one-word variables for now.  Strings/slices
will be a separate CL.

Change-Id: Ie89eba8cab16bcd41b311c479ec46dd7e64cdb67
Reviewed-on: https://go-review.googlesource.com/16336
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-10-28 17:00:31 +00:00
Michael Hudson-Doyle
6736cb0df1 cmd/link: remove unused field LSym.Hash
Change-Id: Idc5c4a69919a8ed9d76d4a9cfd9827fb5c59dd11
Reviewed-on: https://go-review.googlesource.com/16389
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-28 04:28:38 +00:00
Keith Randall
d43f2e37ed [dev.ssa] cmd/compile: introduce storeconst ops
Introduce opcodes that store a constant value.
AuxInt now needs to hold both the value to be stored and the
constant offset at which to store it.  Introduce a StoreConst
type to help encode/decode these parts to/from an AuxInt.

Change-Id: I1631883abe035cff4b16368683e1eb3d2ccb674d
Reviewed-on: https://go-review.googlesource.com/16170
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-10-28 03:09:55 +00:00
Michael Hudson-Doyle
3ae4dc8a75 cmd/compile, cmd/go, cmd/link: enable -buildmode=shared and related flags on linux/386
Change-Id: If3417135ca474468a480b08cf46334fda28f79b4
Reviewed-on: https://go-review.googlesource.com/16345
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-28 01:21:54 +00:00
Todd Neal
cd01c0be26 [dev.ssa] cmd/compile/internal/ssa: reorder fuse and dse
deadstore elimination currently works in a block, fusing before
performing dse eliminates ~1% more stores for make.bash

Change-Id: If5bbddac76bf42616938a8e8e84cb7441fa02f73
Reviewed-on: https://go-review.googlesource.com/16350
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-27 22:16:12 +00:00
Keith Randall
129261ae83 [dev.ssa] cmd/compile: give GetClosurePtr pointer type
If the closure pointer gets spilled, we need to spill it with
pointer type to make stack copy and GC happy.

Change-Id: Ic108748e6b9caecd45522141f02c9422567376e3
Reviewed-on: https://go-review.googlesource.com/16363
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-10-27 18:00:31 +00:00
Keith Randall
10462eb30f [dev.ssa] cmd/compile: better copying
Replace REP MOVSB with all the copying techniques used by the
old compiler.  Copy in chunks, DUFFCOPY, etc.

Introduces MOVO opcodes and an Int128 type to move around
16 bytes at a time.

Change-Id: I1e73e68ca1d8b3dd58bb4af2f4c9e5d9bf13a502
Reviewed-on: https://go-review.googlesource.com/16174
Reviewed-by: Todd Neal <todd@tneal.org>
Run-TryBot: Keith Randall <khr@golang.org>
2015-10-27 04:02:19 +00:00
Michael Hudson-Doyle
00f42437fd cmd/internal/obj/x86: remove REGTMP
Nothing uses this.

Change-Id: Ibc13066940bd2ea5c74d955a67f9dc531bef2758
Reviewed-on: https://go-review.googlesource.com/16344
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-27 03:48:21 +00:00
Robert Griesemer
53d43cb556 cmd/compile/internal/gc: introduce type for untyped constant kinds
Change-Id: Ia34b6dd099d07d5e1d4bffe775a20fa92705fdb0
Reviewed-on: https://go-review.googlesource.com/16335
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-26 23:36:22 +00:00
Robert Griesemer
cd7d7382bb cmd/compile/internal/gc: introduce type for decl contexts/storage classes
Change-Id: I956e27fa07f16060b8f41b986d991c36557f7c12
Reviewed-on: https://go-review.googlesource.com/16332
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-26 22:18:42 +00:00
Robert Griesemer
e6ccfc1ad1 cmd/compile/internal/gc: escape binary export data so it contains no '$'
Necessary to ensure that subsequent tools can continue to find
then end of the export data section simply by searching for "$$".

Adjusted gcimporter used by go/types accordingly.

Also, fixed a bug in gcimporter related to reading export data
in debug format.

Change-Id: Iaea4ed05edd8a5bab28ebe5b19a4740f5e537d35
Reviewed-on: https://go-review.googlesource.com/16283
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-10-26 17:27:17 +00:00
Marcel van Lohuizen
afe9837b23 cmd/compile/internal/gc: make embedded unexported structs RO
gc will need to be rebuild.

Package that assume f.PkgPath != nil means a field is unexported and
must be ignored must be revised to check for
	f.PkgPath != nil && !f.Anonymous,
so that they do try to walk into the embedded fields to look for
exported fields contained within.

Closes #12367, fixes #7363, fixes #11007, and fixes #7247.

Change-Id: I16402ee21ccfede80f277f84b3995cf26e97433d
Reviewed-on: https://go-review.googlesource.com/14085
Reviewed-by: Russ Cox <rsc@golang.org>
2015-10-26 13:57:48 +00:00
Keith Randall
31115a5c98 [dev.ssa] cmd/compile: optimize nil checks
Use faulting loads instead of test/jeq to do nil checks.
Fold nil checks into a following load/store if possible.

Makes binaries about 2% smaller.

Change-Id: I54af0f0a93c853f37e34e0ce7e3f01dd2ac87f64
Reviewed-on: https://go-review.googlesource.com/16287
Reviewed-by: David Chase <drchase@google.com>
2015-10-25 20:34:28 +00:00
Shenghou Ma
75a423a983 cmd/cgo: clarify C.GoStringN and C.GoBytes docs
Fixes #12427.

Change-Id: I46725620c1e163f3b60ffcd85e5388fa646f074d
Reviewed-on: https://go-review.googlesource.com/15997
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-23 22:23:05 +00:00
Keith Randall
a3180d8b1d [dev.ssa] cmd/compile: get rid of converts in unsafe.Pointer arithmetic
unsafe.Pointer->uintptr, add, then uintptr->unsafe.Pointer.
Do the add directly on the pointer type instead.

Change-Id: I5a3a32691d0a000e16975857974ed9a1039c6d28
Reviewed-on: https://go-review.googlesource.com/16281
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-10-23 21:43:38 +00:00
Håvard Haugen
9238cbd57a cmd/compile/internal/gc: remove "goto ret" in walkexpr
Passes go build -a -toolexec 'toolstash -cmp' std cmd.

Change-Id: Ib3d2c50601546495e7f1ab153d2978b1e3774101
Reviewed-on: https://go-review.googlesource.com/14800
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-10-23 20:07:52 +00:00
David Crawshaw
b7e4de4b1e cmd/go, cmd/link: -buildmode=pie for linux/amd64
Depends on external linking right now. I have no immediate use for
this, but wanted to check how hard it is to support as android/amd64
is coming and it will require PIE.

Change-Id: I65c6b19159f40db4c79cf312cd0368c2b2527bfd
Reviewed-on: https://go-review.googlesource.com/16072
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-23 19:51:55 +00:00
David Chase
e99dd52066 [dev.ssa] cmd/compile: enhance SSA filtering, add OpConvert
Modified GOSSA{HASH.PKG} environment variable filters to
make it easier to make/run with all SSA for testing.
Disable attempts at SSA for architectures that are not
amd64 (avoid spurious errors/unimplementeds.)

Removed easy out for unimplemented features.

Add convert op for proper liveness in presence of uintptr
to/from unsafe.Pointer conversions.

Tweaked stack sizes to get a pass on windows;
1024 instead 768, was observed to pass at least once.

Change-Id: Ida3800afcda67d529e3b1cf48ca4a3f0fa48b2c5
Reviewed-on: https://go-review.googlesource.com/16201
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2015-10-23 19:32:57 +00:00
David Chase
3abb844108 [dev.ssa] cmd/compile: repair ssa testing build and test
Calls to NewConfig required an extra parameter that
sometimes could not be nil.

Change-Id: I806dd53c045056a0c2d30d641a20fe27fb790539
Reviewed-on: https://go-review.googlesource.com/16272
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-23 17:30:09 +00:00
Jeremy Jackins
6327e8dc69 cmd/compile/internal/gc: update old c-style comments
Update old c-style comments to look like Go comments. Also replace some
lingering references to old .c files that don't exist anymore.

Change-Id: I72b2407a40fc76c23e9048643e0622fd70b4cf90
Reviewed-on: https://go-review.googlesource.com/16190
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-23 15:33:50 +00:00
Keith Randall
7d61246972 [dev.ssa] cmd/compile: implement reserved registers
BP for framepointer experiment
R15 for dynamic linking

Change-Id: I28e48be461d04a4d5c9b013f48fce5c0e58d6a08
Reviewed-on: https://go-review.googlesource.com/16231
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2015-10-23 04:14:06 +00:00
Robert Griesemer
79a3b561b5 cmd/compile/internal/gc: remove special handling for -0.0
Per the latest spec change, Go doesn't have -0 constants.

Change-Id: Ic2bcdc3bf507d121ed204f30f6744bb8764202c0
Reviewed-on: https://go-review.googlesource.com/16232
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-10-22 21:19:43 +00:00
Robert Griesemer
ae2f54a771 cmd/compile/internal/gc: compact binary export format
The binary import/export format is significantly more
compact than the existing textual format. It should
also be faster to read and write (to be measured).

Use -newexport to enable, for instance:
export GO_GCFLAGS=-newexport; make.bash

The compiler can import packages using both the old
and the new format ("mixed mode").

Missing: export info for inlined functions bodies
(performance issue, does not affect correctness).

Disabled by default until we have inlined function
bodies and confirmation of no regression and equality
of binaries.

For #6110.
For #1909.

This change depends on:

   https://go-review.googlesource.com/16220
   https://go-review.googlesource.com/16222

(already submitted) for all.bash to work.

Some initial export data sizes for std lib packages. This data
is without exported functions with inlineable function bodies.

Package                                       old      new    new/old

archive/tar.................................13875.....3883    28%
archive/zip.................................19464.....5046    26%
bufio....................................... 7733.....2222    29%
bytes.......................................10342.....3347    32%
cmd/addr2line.................................242.......26    11%
cmd/api.....................................39305....10368    26%
cmd/asm/internal/arch.......................27732.....7939    29%
cmd/asm/internal/asm........................35264....10295    29%
cmd/asm/internal/flags........................629......178    28%
cmd/asm/internal/lex........................39248....11128    28%
cmd/asm.......................................306.......26     8%
cmd/cgo.....................................40197....10570    26%
cmd/compile/internal/amd64...................1106......214    19%
cmd/compile/internal/arm....................27891.....7710    28%
cmd/compile/internal/arm64....................891......153    17%
cmd/compile/internal/big....................21637.....8336    39%
cmd/compile/internal/gc....................109845....29727    27%
cmd/compile/internal/mips64...................972......168    17%
cmd/compile/internal/ppc64....................972......168    17%
cmd/compile/internal/x86.....................1104......195    18%
cmd/compile...................................329.......26     8%
cmd/cover...................................12986.....3749    29%
cmd/dist......................................477.......67    14%
cmd/doc.....................................23043.....6793    29%
cmd/expdump...................................167.......26    16%
cmd/fix......................................1190......208    17%
cmd/go......................................26399.....5629    21%
cmd/gofmt.....................................499.......26     5%
cmd/internal/gcprog..........................1342......490    37%
cmd/internal/goobj...........................2690......980    36%
cmd/internal/obj/arm........................32740....10057    31%
cmd/internal/obj/arm64......................46542....15364    33%
cmd/internal/obj/mips.......................42140....13731    33%
cmd/internal/obj/ppc64......................42140....13731    33%
cmd/internal/obj/x86........................52732....19015    36%
cmd/internal/obj............................36729....11690    32%
cmd/internal/objfile........................36365....10287    28%
cmd/link/internal/amd64.....................45893....12220    27%
cmd/link/internal/arm.........................307.......96    31%
cmd/link/internal/arm64.......................345.......98    28%
cmd/link/internal/ld.......................109300....46326    42%
cmd/link/internal/ppc64.......................344.......99    29%
cmd/link/internal/x86.........................334......107    32%
cmd/link......................................314.......26     8%
cmd/newlink..................................8110.....2544    31%
cmd/nm........................................210.......26    12%
cmd/objdump...................................244.......26    11%
cmd/pack....................................14248.....4066    29%
cmd/pprof/internal/commands..................5239.....1285    25%
cmd/pprof/internal/driver...................37967.....8860    23%
cmd/pprof/internal/fetch....................30962.....7337    24%
cmd/pprof/internal/plugin...................47734.....7719    16%
cmd/pprof/internal/profile..................22286.....6922    31%
cmd/pprof/internal/report...................31187.....7838    25%
cmd/pprof/internal/svg.......................4315......965    22%
cmd/pprof/internal/symbolizer...............30051.....7397    25%
cmd/pprof/internal/symbolz..................28545.....6949    24%
cmd/pprof/internal/tempfile.................12550.....3356    27%
cmd/pprof.....................................563.......26     5%
cmd/trace....................................1455......636    44%
cmd/vendor/golang.org/x/arch/arm/armasm....168035....64737    39%
cmd/vendor/golang.org/x/arch/x86/x86asm.....26871.....8578    32%
cmd/vet.....................................38980.....9913    25%
cmd/vet/whitelist.............................102.......49    48%
cmd/yacc.....................................2518......926    37%
compress/bzip2...............................6326......129     2%
compress/flate...............................7069.....2541    36%
compress/gzip...............................20143.....5069    25%
compress/lzw..................................828......295    36%
compress/zlib...............................10676.....2692    25%
container/heap................................523......181    35%
container/list...............................3517......740    21%
container/ring................................881......229    26%
crypto/aes....................................550......187    34%
crypto/cipher................................1966......825    42%
crypto.......................................1836......646    35%
crypto/des....................................632......235    37%
crypto/dsa..................................18718.....5035    27%
crypto/ecdsa................................23131.....6097    26%
crypto/elliptic.............................20790.....5740    28%
crypto/hmac...................................455......186    41%
crypto/md5...................................1375......171    12%
crypto/rand.................................18132.....4748    26%
crypto/rc4....................................561......240    43%
crypto/rsa..................................22094.....6380    29%
crypto/sha1..................................1416......172    12%
crypto/sha256.................................551......238    43%
crypto/sha512.................................839......378    45%
crypto/subtle................................1153......250    22%
crypto/tls..................................58203....17984    31%
crypto/x509/pkix............................29447.....8161    28%
database/sql/driver..........................3318.....1096    33%
database/sql................................11258.....3942    35%
debug/dwarf.................................18416.....7006    38%
debug/elf...................................57530....21014    37%
debug/gosym..................................4992.....2058    41%
debug/macho.................................23037.....6538    28%
debug/pe....................................21063.....6619    31%
debug/plan9obj...............................2467......802    33%
encoding/ascii85.............................1523......360    24%
encoding/asn1................................1718......527    31%
encoding/base32..............................2642......686    26%
encoding/base64..............................3077......800    26%
encoding/binary..............................4727.....1040    22%
encoding/csv................................12223.....2850    23%
encoding......................................383......217    57%
encoding/gob................................37563....10113    27%
encoding/hex.................................1327......390    29%
encoding/json...............................30897.....7804    25%
encoding/pem..................................595......200    34%
encoding/xml................................37798.....9336    25%
errors........................................274.......36    13%
expvar.......................................3155.....1021    32%
flag........................................19860.....2849    14%
fmt..........................................3137.....1263    40%
go/ast......................................44729....13422    30%
go/build....................................16336.....4657    29%
go/constant..................................3703......846    23%
go/doc.......................................9877.....2807    28%
go/format....................................5472.....1575    29%
go/importer..................................4980.....1301    26%
go/internal/gccgoimporter....................5587.....1525    27%
go/internal/gcimporter.......................8979.....2186    24%
go/parser...................................20692.....5304    26%
go/printer...................................7015.....2029    29%
go/scanner...................................9719.....2824    29%
go/token.....................................7933.....2465    31%
go/types....................................64569....19978    31%
hash/adler32.................................1176......176    15%
hash/crc32...................................1663......360    22%
hash/crc64...................................1587......306    19%
hash/fnv.....................................3964......260     7%
hash..........................................591......278    47%
html..........................................217.......74    34%
html/template...............................69623....12588    18%
image/color/palette...........................315.......98    31%
image/color..................................5565.....1036    19%
image/draw...................................6917.....1028    15%
image/gif....................................8894.....1654    19%
image/internal/imageutil.....................9112.....1476    16%
image/jpeg...................................6647.....1026    15%
image/png....................................6906.....1069    15%
image.......................................28992.....6139    21%
index/suffixarray...........................17106.....4773    28%
internal/singleflight........................1614......506    31%
internal/testenv............................12212.....3152    26%
internal/trace...............................2762.....1323    48%
io/ioutil...................................13502.....3682    27%
io...........................................6765.....2482    37%
log.........................................11620.....3317    29%
log/syslog..................................13516.....3821    28%
math/big....................................21819.....8320    38%
math/cmplx...................................2816......438    16%
math/rand....................................2317......929    40%
math.........................................7511.....2444    33%
mime/multipart..............................12679.....3360    27%
mime/quotedprintable.........................5458.....1235    23%
mime.........................................6076.....1628    27%
net/http/cgi................................59796....17173    29%
net/http/cookiejar..........................14781.....3739    25%
net/http/fcgi...............................57861....16426    28%
net/http/httptest...........................84100....24365    29%
net/http/httputil...........................67763....18869    28%
net/http/internal............................6907......637     9%
net/http/pprof..............................57945....16316    28%
net/http....................................95391....30210    32%
net/internal/socktest........................4555.....1453    32%
net/mail....................................14481.....3608    25%
net/rpc/jsonrpc.............................33335......988     3%
net/rpc.....................................79950....23106    29%
net/smtp....................................57790....16468    28%
net/textproto...............................11356.....3248    29%
net/url......................................3123.....1009    32%
os/exec.....................................20738.....5769    28%
os/signal.....................................437......167    38%
os..........................................24875.....6668    27%
path/filepath...............................11340.....2826    25%
path..........................................778......285    37%
reflect.....................................15469.....5198    34%
regexp......................................13627.....4661    34%
regexp/syntax................................5539.....2249    41%
runtime/debug................................9275.....2322    25%
runtime/pprof................................1355......477    35%
runtime/race...................................39.......17    44%
runtime/trace.................................228.......92    40%
runtime.....................................13498.....1821    13%
sort.........................................2848......842    30%
strconv......................................2947.....1252    42%
strings......................................7983.....2456    31%
sync/atomic..................................2666.....1149    43%
sync.........................................2568......845    33%
syscall.....................................81252....38398    47%
testing/iotest...............................2444......302    12%
testing/quick...............................18890.....5076    27%
testing.....................................16502.....4800    29%
text/scanner.................................6849.....2052    30%
text/tabwriter...............................6607.....1863    28%
text/template/parse.........................22978.....6183    27%
text/template...............................64153....11518    18%
time........................................12103.....3546    29%
unicode......................................9706.....3320    34%
unicode/utf16................................1055......148    14%
unicode/utf8.................................1118......513    46%
vendor/golang.org/x/net/http2/hpack..........8905.....2636    30%

All packages                              3518505  1017774    29%

Change-Id: Id657334f276383ff1e6fa91472d3d1db5a03349c
Reviewed-on: https://go-review.googlesource.com/13937
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-10-22 21:01:29 +00:00
Robert Griesemer
28ef4c38c8 cmd/link/internal/ld: export data may be marked with $$ or $$B
Preparation for dealing with binary export format. Accept $$B
as marker for export data. For now, skip that data if found.

Change-Id: I464ba22aaedcf349725379d91070fc900d93b7a2
Reviewed-on: https://go-review.googlesource.com/16222
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-10-22 18:06:08 +00:00
Robert Griesemer
4e777c8eff cmd/internal/goobj: permit 0 bytes in export data (prep. for new export format)
Change-Id: Ida9a82a5420a41ef656388866a1cf8fadf12ccc6
Reviewed-on: https://go-review.googlesource.com/16220
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-10-22 18:05:49 +00:00
Robert Griesemer
3319ea98cd cmd/compile/internal/gc: fixed comments (cosmetic change)
Change-Id: I9cbbfcf55ce3cccb6f14b9ffe6777567dcdad9c9
Reviewed-on: https://go-review.googlesource.com/16179
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-10-22 18:04:20 +00:00
Keith Randall
f206b16ff7 [dev.ssa] cmd/compile: assign unused registers to phi ops
Register phis are better than stack phis.  If we have
unused registers available, use them for phis.

Change-Id: I3045711c65caa1b6d0be29131b87b57466320cc2
Reviewed-on: https://go-review.googlesource.com/16080
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-10-22 17:06:10 +00:00
Ian Lance Taylor
029c760c7b cmd/go: if -msan, pass -fsanitize=memory to cgo builds
Also fix the msan_fail test.  It was bogus, since it always aborted one
way or another.

Change-Id: Ic693327d1bddb7bc5c7d859ac047fc93cb9b5b1c
Reviewed-on: https://go-review.googlesource.com/16172
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-21 23:52:23 +00:00
Ian Lance Taylor
e7ee268292 cmd/go: add -msan option
The -msan option compiles Go code to use the memory sanitizer.  This is
intended for use when linking with C/C++ code compiled with
-fsanitize=memory.  When memory blocks are passed back and forth between
C/C++ and Go, code in both languages will agree as to whether the memory
is correctly initialized or not, and will report errors for any use of
uninitialized memory.

Change-Id: I2dbdbd26951eacb7d84063cfc7297f88ffadd70c
Reviewed-on: https://go-review.googlesource.com/16169
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-10-21 20:30:23 +00:00
Keith Randall
d96b4c494f cmd/internal/obj: fix PSRLW opcode
The reg-reg version compiled to PSRAW, not PSRLW (arithmetic
instead of logical shift right).

Fixes #13010.

Change-Id: I69a47bd83c8bbe66c7f8d82442ab45e9bf3b94fb
Reviewed-on: https://go-review.googlesource.com/16168
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-21 20:06:01 +00:00
Ian Lance Taylor
0c69f1303f cmd/compile: add -msan option
The -msan option causes the compiler to add instrumentation for the
C/C++ memory sanitizer.  Every memory read/write will be preceded by
a call to msanread/msanwrite.

This CL passes tests but is not usable by itself.  The actual
implementation of msanread/msanwrite in the runtime package, and support
for -msan in the go tool and the linker, and tests, will follow in
subsequent CLs.

Change-Id: I3d517fb3e6e65d9bf9433db070a420fd11f57816
Reviewed-on: https://go-review.googlesource.com/16160
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-10-21 14:58:53 +00:00
Ian Lance Taylor
7b4b96f248 cmd/link: add -msan option
The -msan option causes the linker to link against the runtime/msan
package in order to use the C/C++ memory sanitizer.

This CL passes tests but is not usable by itself.  The actual
runtime/msan package, and support for -msan in the go tool and the
compiler, and tests, are in separate CLs.

Change-Id: I02c097393b98c5b80e40ee3dbc167a8b4d23efe0
Reviewed-on: https://go-review.googlesource.com/16161
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-10-21 14:40:07 +00:00
Konstantin Shaposhnikov
3c1712db0b cmd/vet: fix shadow assignment check with complex rhs
This change fixes shadow assignment check in cases when RHS is not an identifier
or a type assertion.

Fixes #12188

Change-Id: I0940df8d9c237ab8b8d3272eb6895e676c75c115
Reviewed-on: https://go-review.googlesource.com/16038
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-21 14:27:49 +00:00
Ian Lance Taylor
9e902f0f3a cmd/compile: generalize racewalk to instrument (naming change)
This is mechanical change that is a step toward reusing the racewalk
pass for a more general instrumentation pass.  The first use will be to
add support for the memory sanitizer.

Change-Id: I75b93b814ac60c1db1660e0b9a9a7d7977d86939
Reviewed-on: https://go-review.googlesource.com/16105
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-10-21 13:55:23 +00:00
Nodir Turakulov
76dcedc920 cmd/go: dedup packages in packagesAndErrors
packagesAndErrors function doesn't dedup packages.
As a result, `go list io ./io` prints io package twice.
Same applies to `go build` and `go test`.

* dedup packages.
* add a test for go list

Change-Id: I54d4063979b1c9359e5416e12327cb85c4823a0f
Reviewed-on: https://go-review.googlesource.com/16136
Run-TryBot: Andrew Gerrand <adg@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-21 06:31:52 +00:00
Aaron Jacobs
d8c6bf916e cmd/compile: remove a stray word in the go:nosplit documentation
Change-Id: I7a85c0ad8aba2d50032c8faa58c83fb327f360cf
Reviewed-on: https://go-review.googlesource.com/16140
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-21 04:51:54 +00:00
acanino
b60c8203ea cmd/compile: "invalid variable name x in type switch", where x is a name of a constant
Small fix: looks like a short variable declaration with a type switch
checks to make sure the variable used had valid shape (ONAME, OTYPE, or
ONONAME) and rejects everything else. Then a new variable is declared.
If the symbol contained in the declaration was a named OLITERAL (still a
valid identifier obviously) it would be rejected, even though a new
variable would have been declared.

Fix adds this case to the check.

Added a test case from issue12413.

Fixes #12413

Change-Id: I150dadafa8ee5612c867d58031027f2dca8c6ebc
Reviewed-on: https://go-review.googlesource.com/15760
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-21 04:21:16 +00:00
Matthew Dempsky
d4a7ea1b71 runtime: add stringStructOf helper function
Instead of open-coding conversions from *string to unsafe.Pointer then
to *stringStruct, add a helper function to add some type safety.
Bonus: This caught two **string values being converted to
*stringStruct in heapdump.go.

While here, get rid of the redundant _string type, but add in a
stringStructDWARF type used for generating DWARF debug info.

Change-Id: I8882f8cca66ac45190270f82019a5d85db023bd2
Reviewed-on: https://go-review.googlesource.com/16131
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-20 23:13:27 +00:00
Robert Griesemer
76285213b8 cmd/compile/internal/gc: there are no -0 floating-point constants
Fixes #12577.

Change-Id: Id469cd92f5f9436b0ef948ee1a252ed1842bc7aa
Reviewed-on: https://go-review.googlesource.com/16133
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-20 22:11:11 +00:00
Keith Randall
fbfc18c522 [dev.ssa] cmd/compile: don't issue nops for static data
It confuses live variable analysis to have a bunch of unreachable
no-ops at the end of a function.  Symptom is:
    gc/plive.go:483 panic: interface conversion: interface {} is nil, not *gc.BasicBlock

I don't see any reason why the old compiler needs these no-ops either.
all.bash passes with the equivalent code removed on master.

Change-Id: Ifcd2c3e139aa16314f08aebc9079b2fb7aa60556
Reviewed-on: https://go-review.googlesource.com/16132
Reviewed-by: David Chase <drchase@google.com>
2015-10-20 21:59:01 +00:00
Robert Griesemer
27838f3990 cmd/compile/internal/gc: remove atoi function (minor cleanup)
Change-Id: I0ad7836c0e8d70ffdc458e125d97b01e85d8a608
Reviewed-on: https://go-review.googlesource.com/16130
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-20 17:55:39 +00:00
Ilya Tocar
7d2c6eb3f5 cmd/internal/obj/x86: align functions with trap instruction
Align functions with 0xCC (INT $3) - breakpoint instruction,
instead of 0x00, which can disassemble into valid instruction.

Change-Id: Ieda191886efc4aacb86f58bea1169fd1b3b57636
Reviewed-on: https://go-review.googlesource.com/16102
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
Reviewed-by: Gregory Shimansky <gregory.shimansky@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-20 15:48:49 +00:00
Gerrit Code Review
97728b6575 Merge "[dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch" into dev.ssa 2015-10-20 15:46:15 +00:00
Ian Lance Taylor
77b1fef27e cmd/compile, syscall: use go:norace comment for forkAndExecInChild
Use a go:norace comment rather than having the compiler know the special
name syscall.forkAndExecInChild.

Change-Id: I69bc6aa6fc40feb2148d23f269ff32453696fb28
Reviewed-on: https://go-review.googlesource.com/16097
Reviewed-by: Minux Ma <minux@golang.org>
2015-10-20 14:10:24 +00:00
Keith Randall
d694f83c21 [dev.ssa] cmd/compile: getg needs a memory arg
getg reads from memory, so it should really have a
memory arg.  It is critical in functions which call setg
to make sure getg gets ordered correctly with setg.

Change-Id: Ief4875421f741fc49c07b0e1f065ce2535232341
Reviewed-on: https://go-review.googlesource.com/16100
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
2015-10-20 03:41:03 +00:00
Keith Randall
65df9c4c2b [dev.ssa] cmd/compile: don't move mem-using values in tighten pass
It isn't safe, the place where we're moving the value to
might have a different live memory.  Moving will introduce
two simultaneously live memories.

Change-Id: I07e61a6db8ef285088c530dc2e5d5768d27871ff
Reviewed-on: https://go-review.googlesource.com/16099
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
2015-10-20 02:09:52 +00:00
Keith Randall
2dc88eead8 [dev.ssa] cmd/compile: Don't rematerialize getg
It isn't safe in functions that also call setg.

Change-Id: I76a7bf0401b4b6c8a129c245b15a2d6f06080e94
Reviewed-on: https://go-review.googlesource.com/16095
Reviewed-by: Todd Neal <todd@tneal.org>
2015-10-20 01:41:50 +00:00
Ian Lance Taylor
684218e135 cmd/compile: clarify where mkbuiltin.go input files are found
Just a comment change reflecting that the files were moved to the
builtin directory when the compiled was converted from C to Go.

Change-Id: I65e5340c09221684e40174feadfb69f738a9044a
Reviewed-on: https://go-review.googlesource.com/16089
Reviewed-by: Minux Ma <minux@golang.org>
2015-10-19 23:28:34 +00:00
Burcu Dogan
4dc49d23a7 cmd/go: don't override GIT_TERMINAL_PROMPT
This CL keeps disallowing `go get` from falling to the prompt unless
user has set GIT_TERMINAL_PROMPT env variable. If GIT_TERMINAL_PROMPT
is set, go-get will not override its value and will prompt for
username/password in the case of GIT_TERMINAL_PROMPT=1.

Fixes #12706.

Change-Id: Ibd6b1100af6b04fb8114279cdcf608943e7765be
Reviewed-on: https://go-review.googlesource.com/16091
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-19 23:05:52 +00:00
Keith Randall
7c4fbb650c [dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
The only major fixup is that duffzero changed from
8-byte writes to 16-byte writes.

Change-Id: I1762b74ce67a8e4b81c11568027cdb3572f7f87c
2015-10-19 14:00:03 -07:00
Michael Hudson-Doyle
d66f6c2c86 cmd/link: centralize knowledge of size of fixed part of stack
Shared libraries on ppc64le will require a larger minimum stack frame (because
the ABI mandates that the TOC pointer is available at 24(R1)). Part 2b of
preparing for that is to have all the code in the linker that needs to know
this size of this call a function to find out.

Change-Id: I246363840096db22e44beabbe38b61d60c1f31ad
Reviewed-on: https://go-review.googlesource.com/15675
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-19 20:28:16 +00:00
Michael Hudson-Doyle
c23c8d58d6 cmd/compile: allow -shared/-dynlink on ppc64
Only effect is register related: do not allocate R2 or R12, put function
entrypoint in R12 before indirect call.

Change-Id: I9cdd553bab022601c9cb5bb43c9dc0c368c6fb0a
Reviewed-on: https://go-review.googlesource.com/15961
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-19 20:27:55 +00:00
David Crawshaw
fd8592859b cmd/cgo: give __uint128_t type [16]uint8
The __uint128_t type appears in darwin/arm header files processed by
cgo -godefs in http://golang.org/cl/16045.

Change-Id: I666194c65dee8ea0ae933d2f02a3abe4581c4697
Reviewed-on: https://go-review.googlesource.com/16046
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-19 20:16:03 +00:00
Keith Randall
c64a6f6362 [dev.ssa] cmd/compile: Rematerialize in regalloc
Rematerialize constants instead of spilling and loading them.
"Constants" includes constant offsets from SP and SB.

Should help somewhat with stack frame sizes.  I'm not sure
exactly how much yet.

Change-Id: I44dbad97aae870cf31cb6e89c92fe4f6a2b9586f
Reviewed-on: https://go-review.googlesource.com/16029
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-10-19 19:01:24 +00:00
David Crawshaw
17a256bf22 cmd/go: -buildmode=pie for android/arm
Also make PIE executables the default build mode, as PIE executables
are required as of Android L.

For #10807

Change-Id: I86b7556b9792105cd2531df1b8f3c8f7a8c5d25c
Reviewed-on: https://go-review.googlesource.com/16055
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
2015-10-19 18:02:08 +00:00
David Crawshaw
26205cb3c0 cmd/link: PIE executables for android/arm
For #10807

Change-Id: Ied826d06cb622edf6413b6f2cdcc46987ab0b05a
Reviewed-on: https://go-review.googlesource.com/16054
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-19 17:41:39 +00:00
David Crawshaw
e920f7d5c5 cmd/cgo: don't print absolute path in comment
Change-Id: Ib424e14cfaab35d37ebdd084d41151928bfd645e
Reviewed-on: https://go-review.googlesource.com/16051
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
2015-10-19 15:28:32 +00:00
Todd Neal
d076ef749b [dev.ssa] cmd/compile/internal/ssa: reuse symbols
Reuse the ArgSymbol for nodes so that the Aux values will be equal for cse.

Change-Id: Iaae80bd19ff2d3f51b6c9049fd860e04baa6f175
Reviewed-on: https://go-review.googlesource.com/15930
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Todd Neal <todd@tneal.org>
2015-10-19 01:43:31 +00:00
Michael Hudson-Doyle
b8f8969fbd reflect, runtime, runtime/cgo: use ppc64 asm constant for fixed frame size
Shared libraries on ppc64le will require a larger minimum stack frame (because
the ABI mandates that the TOC pointer is available at 24(R1)). Part 3 of that
is using a #define in the ppc64 assembly to refer to the size of the fixed
part of the stack (finding all these took me about a week!).

Change-Id: I50f22fe1c47af1ec59da1bd7ea8f84a4750df9b7
Reviewed-on: https://go-review.googlesource.com/15525
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-18 23:15:26 +00:00
Michael Hudson-Doyle
97055dc1f1 cmd/compile, cmd/internal/obj: centralize knowledge of size of fixed part of stack
Shared libraries on ppc64le will require a larger minimum stack frame (because
the ABI mandates that the TOC pointer is available at 24(R1)). Part 2a of
preparing for that is to have all bits of arch-independent and ppc64-specific
codegen that need to know call a function to find out.

Change-Id: I55899f73037e92227813c491049a3bd6f30bd41f
Reviewed-on: https://go-review.googlesource.com/15524
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-18 22:19:06 +00:00
Michael Hudson-Doyle
45c06b27a4 cmd/internal/obj, runtime: add NOFRAME flag to suppress stack frame set up on ppc64x
Replace the confusing game where a frame size of $-8 would suppress the
implicit setting up of a stack frame with a nice explicit flag.

The code to set up the function prologue is still a little confusing but better
than it was.

Change-Id: I1d49278ff42c6bc734ebfb079998b32bc53f8d9a
Reviewed-on: https://go-review.googlesource.com/15670
Reviewed-by: Minux Ma <minux@golang.org>
2015-10-18 22:13:30 +00:00
Keith Randall
366dcc4529 [dev.ssa] cmd/compile: Reuse stack slots for spill locations
For each type, maintain a list of stack slots used to spill
SSA values to the stack.  Reuse those stack slots for noninterfering
spills.

Lowers frame sizes.  As an example, runtime.mSpan_Sweep goes from
584 bytes to 392 bytes.  heapBitsSetType goes from 576 bytes to 152 bytes.

Change-Id: I0e9afe80c2fd84aff9eb368318685de293c363d0
Reviewed-on: https://go-review.googlesource.com/16022
Reviewed-by: David Chase <drchase@google.com>
2015-10-18 16:36:13 +00:00
David Chase
57670ad8b2 [dev.ssa] cmd/compile: fill remaining SSA gaps
Changed racewalk/race detector to use FP in a more
sensible way.

Relaxed checks for CONVNOP when race detecting.

Modified tighten to ensure that GetClosurePtr cannot float
out of entry block (turns out this cannot be relaxed, DX is
sometimes stomped by other code accompanying race detection).

Added case for addr(CONVNOP)

Modified addr to take "bounded" flag to suppress nilchecks
where it is set (usually, by race detector).

Cannot leave unimplemented-complainer enabled because it
turns out we are optimistically running SSA on every platform.

Change-Id: Ife021654ee4065b3ffac62326d09b4b317b9f2e0
Reviewed-on: https://go-review.googlesource.com/15710
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-18 13:30:54 +00:00
Michael Hudson-Doyle
69a99ccc62 cmd/link: always disable lazy PLT resolution when dynamically linking Go
Go cannot allow lazy PLT resolution when calling between Go functions because
the lazy resolution can use more stack than is available. Lazy resolution is
disabled by passing -z now to the system linker, but unfortunately was only
passed when linking to a Go shared library. That sounds fine, but the shared
library containing the runtime is not linked to any other Go shared library but
calls main.init and main.main via a PLT, and before this fix this did use lazy
resolution. (For some reason this never caused a problem on intel, but it
breaks on ppc64le). Fortunately the fix is very simple: always pass -z now to
the system linker when dynamically linking Go.

Change-Id: I7806d40aac80dcd1e56b95864d1cfeb1c42614e2
Reviewed-on: https://go-review.googlesource.com/15870
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-17 01:01:42 +00:00
Matthew Dempsky
67722fea50 cmd/compile/internal/gc: reject invalid unsafe.Sizeof([0]byte{}[0])
Apply static bounds checking logic during type checking even to
zero-element arrays, but skip synthesized OINDEX nodes that the
compiler has asserted are within bounds (such as the ones generated
while desugaring ORANGE nodes).  This matches the logic in walkexpr
that also skips static bounds checking when Bounded is true.

Passes toolstash/buildall.

Fixes #12944.

Change-Id: I14ba03d71c002bf969d69783bec8d1a8e10e7d75
Reviewed-on: https://go-review.googlesource.com/15902
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-15 20:56:58 +00:00
Matthew Dempsky
7eb94db44c cmd/compile/internal/gc: refactor range/memclr optimization
No functional change and passes toolstash/buildall, but eliminates a
13-deep nesting of if statements.

Change-Id: I32e63dcf358c6eb521935f4ee07fbe749278e5ef
Reviewed-on: https://go-review.googlesource.com/15901
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-15 19:11:53 +00:00
Brad Fitzpatrick
20736fcab9 net/http: enable automatic HTTP/2 if TLSNextProto is nil
This enables HTTP/2 by default (for https only) if the user didn't
configure anything in their NPN/ALPN map. If they're using SPDY or an
alternate http2 or a newer http2 from x/net/http2, we do nothing
and don't use the standard library's vendored copy of x/net/http2.

Upstream remains golang.org/x/net/http2.

Update #6891

Change-Id: I69a8957a021a00ac353f9d7fdb9a40a5b69f2199
Reviewed-on: https://go-review.googlesource.com/15828
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-14 23:21:57 +00:00
Keith Randall
177b697ba5 [dev.ssa] cmd/compile: allow rewrite rules to specify a target block
Some rewrite rules need to make sure the rewrite target ends up
in a specific block.  For example:

(MOVBQSX (MOVBload [off] {sym} ptr mem)) ->
   @v.Args[0].Block (MOVBQSXload <v.Type> [off] {sym} ptr mem)

The MOVBQSXload op needs to be in the same block as the MOVBload
(to ensure exactly one memory is live at basic block boundaries).

Change-Id: Ibe49a4183ca91f6c859cba8135927f01d176e064
Reviewed-on: https://go-review.googlesource.com/15804
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-10-14 17:43:51 +00:00
Shenghou Ma
30b966307f cmd/internal/obj: move empty field to the top
Due to #9401, trailing empty fields will occupy at least 1 byte
of space.

Fixes #12884.

Change-Id: I838d3f1a73637e526f5a6dbc348981227d5bb2fd
Reviewed-on: https://go-review.googlesource.com/15660
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-13 21:06:58 +00:00
Burcu Dogan
29aaf679da cmd/go: always log dynamic import errors
There is no easy way to understand what user intent was and whether
they wanted to use a dynamic import or not.

If we skip logging such errors, it breaks common use cases such as
https://golang.org/issue/12810.

It's a better approach to expose the underlying mechanism and
be more verbose with the error messages.

Fixes #12810.

Change-Id: I7e922c9e848382690d9d9b006d7046e6cf93223b
Reviewed-on: https://go-review.googlesource.com/15756
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-12 23:59:09 +00:00
Burcu Dogan
5b9c6b9e9e cmd/go: don't accept a relative path as GOBIN
Fixes #12907.

Change-Id: I5925852fe6962d4ec7dbb3ea5323e8ddfaf9d576
Reviewed-on: https://go-review.googlesource.com/15755
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-12 23:53:04 +00:00
Ian Lance Taylor
a0c7f57903 cmd/link: remove -W option
The -W option has not worked since Go 1.3.  It is not documented.  When
it did work, it generated useful output, but it was for human viewing;
there was no reason to write a script that passes the -W option, so it's
unlikely that anybody is using it today.

Change-Id: I4769f1ffd308a48324a866592eb7fd79a4cdee54
Reviewed-on: https://go-review.googlesource.com/15701
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-09 21:30:44 +00:00
Robert Griesemer
a2119aca7d cmd/compile/internal/gc: make funcsyms a []*Node
Remove another use of NodeList.

Change-Id: Ice07eff862caf715f722dec7829006bf71715b07
Reviewed-on: https://go-review.googlesource.com/15432
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-10-09 20:45:54 +00:00
Nodir Turakulov
8815093572 cmd/go: print all warnings to stderr
All warnings in cmd/go are printed using fmt.Fprintf(os.Stderr...)
except one in test.go which is printed using log.Printf.
This is a minor inconsistency.

Change-Id: Ib470d318810b44b86e6cfaa77e9a556a5ad94069
Reviewed-on: https://go-review.googlesource.com/15657
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-09 20:42:30 +00:00
Keith Randall
9703564c9a [dev.ssa] cmd/compile: make sure we don't move loads between blocks
This can lead to multiple stores being live at once.

Do OINDEX and ODOT using addresses & loads instead of specific ops.
This keeps SSA values from containing unSSAable types.

Change-Id: I79567e9d43cdee09084eb89ea0bd7aa3aad48ada
Reviewed-on: https://go-review.googlesource.com/15654
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-10-09 18:10:19 +00:00
David Chase
32ffbf7e0f [dev.ssa] cmd/compile: handle addr of PARAM nodes
Turns out that these do occur after all, so did the obvious
refactoring into the addr method.

Also added better debugging for the case of unhandled
closure args.

Change-Id: I1cd8ac58f78848bae0b995736f1c744fd20a6c95
Reviewed-on: https://go-review.googlesource.com/15640
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2015-10-09 00:02:26 +00:00
Dave Cheney
b795ce9ab0 cmd/internal/obj: improve obj.ProgInfo struct layout
obj.ProgInfo is a field inside obj.Prog, which is currently 320 bytes
on 64bit platforms. By moving the Flags field below the other fields
the size of obj.Prog drops into the 288 byte size class, a saving of
32 bytes per value allocated on the heap.

Change-Id: If8bb12f45328996d7df1d0bac9d1c019d2af73bd
Reviewed-on: https://go-review.googlesource.com/15522
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-08 20:57:54 +00:00
Ian Lance Taylor
bd7de94d7f cmd/link: pass -Wl,-z,nodelete when creating an ELF shared library
Go shared libraries do not support dlclose, and there is no likelihood
that they will suppose dlclose in the future.  Set the DF_1_NODELETE
flag to tell the dynamic linker to not attempt to remove them from
memory.  This makes the shared library act as though every call to
dlopen passed the RTLD_NODELETE flag.

Fixes #12582.
Update #11100.
Update #12873.

Change-Id: Id4b6e90a1b54e2e6fc8355b5fb22c5978fc762b4
Reviewed-on: https://go-review.googlesource.com/15605
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2015-10-08 19:51:29 +00:00
David Chase
8824dccc28 [dev.ssa] cmd/compile: fixed heap-escaped-paramout
Changed tree generation to correctly use PARAMOUT instead
of PARAM.

Emit Func.Exit before any returns.

Change-Id: I2fa53cc7fad05fb4eea21081ba33d1f66db4ed49
Reviewed-on: https://go-review.googlesource.com/15610
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2015-10-08 18:12:52 +00:00
Keith Randall
808d7c70d5 [dev.ssa] cmd/compile: fix failed lowerings
One was OAPPEND of large types.  We need to mem-mem copy them
instead of storing them.

Another was pointer-like struct and array types being put in the
data field of an eface.  We need to use the underlying pointer
type for the load that fills in the eface.data field.

Change-Id: Id8278c0381904e52d59011a66ce46386b41b5521
Reviewed-on: https://go-review.googlesource.com/15552
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-10-08 18:12:09 +00:00
Didier Spezia
cb0e98b833 cmd/compile: fix some C to Go translation leftovers
Following the C to Go translation, some useless variables
were left in the code. In fmt.go, this was harmless.
In lex.go, it broke the error message related to
non-canonical import paths.

Fix it, and remove the useless variables.

The added test case is ignored in the go/types tests, since
the behavior of the non-canonical import path check seems
to be different.

Fixes #11362

Change-Id: Ic9129139ede90357dc79ebf167af638cf44536fa
Reviewed-on: https://go-review.googlesource.com/15580
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-08 01:51:24 +00:00
Michael Hudson-Doyle
a5cb76243a cmd/internal/obj, cmd/link, runtime: lots of TLS cleanup
It's particularly nice to get rid of the android special cases in the linker.

Change-Id: I516363af7ce8a6b2f196fe49cb8887ac787a6dad
Reviewed-on: https://go-review.googlesource.com/14197
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-08 00:21:30 +00:00
Nodir Turakulov
0b248cea16 cmd/go: fix go test -n
The <importPath>/_test directory is not actually created in -n mode, so
`go test` fails to write _testmain.go.

Do not write _testmain.go if -n is passed.

Change-Id: I825d5040cacbc9d9a8c89443e5a3f83e6f210ce4
Reviewed-on: https://go-review.googlesource.com/15433
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-07 01:12:42 +00:00
Shenghou Ma
7c43975ace cmd/compile/internal/big: fix unused result from testing/quick.Check
Update #12834.

Change-Id: If7bbcc249517f2f2d8a7dcbba6411ede92331abe
Reviewed-on: https://go-review.googlesource.com/15381
Reviewed-by: Damian Gryski <dgryski@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-06 21:29:36 +00:00
David du Colombier
50ad337238 runtime: don't use duffcopy on Plan 9
In CL 14836, the implementation of duffcopy on amd64
was changed to replace the use of the MOVQ instructions
by MOVUPS.

However, it broke the build on plan9/amd64, since
Plan 9 doesn't allow floating point in note handler.

This change disables the use of duffcopy on Plan 9.

Fixes #12829.

Change-Id: Ifd5b17b17977a1b631b16c3dfe2dc7ab4ad00507
Reviewed-on: https://go-review.googlesource.com/15421
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-06 19:06:11 +00:00
Michael Hudson-Doyle
3e6334e2e0 cmd/link: set the ELF headers of ARM executables that use cgo correctly
It is generally expected that the ELF flags of a dynamically linked executable
and the libraries it links against match. Go's linker currently always produces
executables with flags that do not declare a float abi (hard, soft) at all, but
when cgo is involved it is unlikely that this matches the system libraries
being linked against -- really the decision about ABI is made by the C compiler
during the invocation of cgo.

This change is basically a port of the code from binutils that parses the
".ARM.attributes" section to check for the tag that declares that the code is
built for the hard-float ABI.

Fixes #7094

Change-Id: I737c8f3b5ed4af545cfc3e86722d03eb83083402
Reviewed-on: https://go-review.googlesource.com/14860
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-10-06 07:05:51 +00:00
Shenghou Ma
007ee631d6 cmd/go: given better error when -race is used without cgo
Fixes #12844.

Change-Id: Id51b24aae239fd2e1fb1cd0bc9fe443186301044
Reviewed-on: https://go-review.googlesource.com/15440
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-06 06:59:42 +00:00
Shenghou Ma
5ae12e9c71 cmd/cgo: update docs refering to 6g and 6l
Change-Id: Id6cb5e3d40e8a2ded6359aa7fcdc012861cc3994
Reviewed-on: https://go-review.googlesource.com/14545
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-06 06:59:21 +00:00
Michael Hudson-Doyle
710b9ad617 cmd/compile/internal/ppc64: fix the epilogue for non-leaf generated methods
This lets us re-enable duffzero.

Fixes #12108

Change-Id: Iefd24d26eaa56067caa2c29ff99cd20a42d8714a
Reviewed-on: https://go-review.googlesource.com/14937
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-06 03:34:13 +00:00
Nodir Turakulov
0a486b8a06 cmd/go: print go test -help to stderr
Usage of all commands is printed to stderr, except go test, which is printed to
stdout. This is inconsistent.

Print `go test -help` to stderr instead.

R=rsc@golang.org

Change-Id: I079f4788134bf9aedcccc26838879eedad1c925e
Reviewed-on: https://go-review.googlesource.com/15434
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-06 01:11:30 +00:00
Didier Spezia
9c258c6aa6 cmd/cgo: fix panic on references to non-existing C types
cgo panics in Package.rewriteRef for:

var a = C.enum_test(1)
or
p := new(C.enum_test)

when the corresponding enum type is not defined.

Check nil values for Type fields and issue a proper
error instead.

Fixes #11097
Updates #12160

Change-Id: I5821d29097ef0a36076ec5273125b09846c7d832
Reviewed-on: https://go-review.googlesource.com/15264
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-05 22:37:07 +00:00
Keith Randall
9aba7e76f6 [dev.ssa] cmd/compile: Eval append args after growslice
For appending large types, we want to evaluate the
values being appended after the growslice call, not before.
Evaluating them before leads to phi operations on large types
which confuses the lowering pass.

The order pass has already removed any side-effects from the
values being appended, so it doesn't matter if we do this
last eval before or after the growslice call.

This change fixes a bunch (but not all) of our failed lowerings.

Change-Id: I7c697d4d5275d71b7ef4677b830fd86c52ba03a4
Reviewed-on: https://go-review.googlesource.com/15430
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
2015-10-05 21:25:48 +00:00
Ilya Tocar
9dd81d6227 cmd/internal/obj/x86: Add initial VEX support.
Support VZEROUPPER, VMOVNTDQ, VMOVDQU, VMOVDQA.
Use MOVHD* for names, where HD stands for HexaDeca (16).

Change-Id: I9b1ea52e7ef0714a3d2aeb31ec1823fe509a047e
Reviewed-on: https://go-review.googlesource.com/14127
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-05 16:00:25 +00:00
Michael Hudson-Doyle
0357c38adf cmd/compile: do not let regopt use REGTMP on ppc64
ppc64 codegen assumes that it is OK to stomp on r31 at any time, but it is not
excluded from the set of registers that regopt is allowed to use.

Fixes #12597

Change-Id: I29c7655e32abd22f3c21d88427b73e4fca055233
Reviewed-on: https://go-review.googlesource.com/15245
Reviewed-by: Minux Ma <minux@golang.org>
2015-10-05 03:50:51 +00:00
David Chase
f7a39a54e9 cmd/compile: escape analysis, don't always escape variadic args
Turns out the summary information for the ... args was
already correctly computed, all that lacked was to make
use of it and correct tests that documented our prior
deficiencies.

Fixes #12006

Change-Id: Ie8adfab7547f179391d470679598f0904aabf9f7
Reviewed-on: https://go-review.googlesource.com/15200
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-10-04 20:45:35 +00:00
Shenghou Ma
f78a4c84ac cmd/go: remove the bootstrap with make.bash error message
The runtime/zgoos_$GOOS.go and runtime/zgoarch_$GOARCH.go files
are in the repository now, so the message is actually incorrect
(running make.bash won't generate those). The reason is probably
wrong $GOROOT.

Change-Id: I8dc125594c52d666eca91fd5af48b60d12d599b8
Reviewed-on: https://go-review.googlesource.com/15221
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-04 01:36:40 +00:00
Shenghou Ma
62491ff778 cmd/yacc: fix copying action code when line comment is disabled
Fixes #12601.

Change-Id: I0be69ffe9ba19934aaef1651845c725708db77de
Reviewed-on: https://go-review.googlesource.com/14546
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-04 01:36:03 +00:00
Didier Spezia
f12b6208f6 cmd/cgo: remove support for CGOPKGPATH
CGOPKGPATH variable was undocumented, but it is not needed anymore.

It was used before the existence of the go tool to tell cgo the full
path of the package that it was building, which in turn set the name
of the shared library that cgo expected to load back when cgo used
shared libraries. CGOPKGPATH no longer does anything useful;
it just affects the comments in the generated header file.

Remove it to avoid any future confusion.

Fixes #11852

Change-Id: Ieb452e5bbcfd05b87a4a3618b5b8f44423341858
Reviewed-on: https://go-review.googlesource.com/15266
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-03 18:41:59 +00:00
Brad Fitzpatrick
89a68e9f1a cmd/compile/internal/gc: fix the build
Commit acc90c5 passed the trybots, lingered for weeks, and in the
meantime the type of this variable changed to a bool. I didn't rebase
and re-run the trybots before submitting.

Fixes #12832

Change-Id: If24fda227edd8207f8069c67f1c45f08e6ac215a
Reviewed-on: https://go-review.googlesource.com/15286
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-03 16:37:18 +00:00
Ilya Tocar
37cfb2e07e math: optimize ceil/floor functions on amd64
Use SSE 4.1 rounding instruction to perform rounding
Results (haswell):

name      old time/op  new time/op  delta
Floor-48  2.71ns ± 0%  1.87ns ± 1%  -31.17%  (p=0.000 n=16+19)
Ceil-48   3.09ns ± 3%  2.16ns ± 0%  -30.16%  (p=0.000 n=19+12)

Change-Id: If63715879eed6530b1eb4fc96132d827f8f43909
Reviewed-on: https://go-review.googlesource.com/14561
Reviewed-by: Klaus Post <klauspost@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-03 15:55:08 +00:00
acanino
acc90c53e8 cmd/compile: Fix internal compiler: getinarg: not a func when returning invalid interface.
Internal error arose from calling methodfunc on a invalid interface
field during the implements check. int obviously isn't a function,
and errors on getinarg...

for im := iface.Type; im != nil; im = im.Down {
  imtype = methodfunc(im.Type, nil)
  // ...
}

Fix handles the internal compiler error, but does not throw an
additional error, i.e. the following code will error on the I
interface, but type A will pass the implements check since
'Read(string) string' is implemented and 'int' is skipped

type I interface {
  Read(string) string
  int
}

type A struct {
}

func (a *A) Read(s string) string {
  return s
}

func New() I {
  return new(A)
}

Fixes #10975

Change-Id: I4b54013afb2814db3f315515f0c742d8631ca500
Reviewed-on: https://go-review.googlesource.com/13747
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-03 15:32:46 +00:00
David Crawshaw
47ccf96a95 runtime: darwin/386 entrypoint for c-archive
Change-Id: Ic22597b5e2824cffe9598cb9b506af3426c285fd
Reviewed-on: https://go-review.googlesource.com/12412
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-02 11:45:52 +00:00
David Chase
745cdc3ad7 cmd/compile: repair escape analysis of range &fixedArray
The existing test did not take into account the implicit
dereference of &fixedArray and thus heap-escaped when it
was not necessary.

Also added a detailed test for this and related cases.

Fixes #12588

Change-Id: I951e9684a093082ccdca47710f69f4366bd6b3cf
Reviewed-on: https://go-review.googlesource.com/15130
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-10-01 18:49:18 +00:00
Ian Lance Taylor
0c1f0549b8 runtime, runtime/cgo: support using msan on cgo code
The memory sanitizer (msan) is a nice compiler feature that can
dynamically check for memory errors in C code.  It's not useful for Go
code, since Go is memory safe.  But it is useful to be able to use the
memory sanitizer on C code that is linked into a Go program via cgo.
Without this change it does not work, as msan considers memory passed
from Go to C as uninitialized.

To make this work, change the runtime to call the C mmap function when
using cgo.  When using msan the mmap call will be intercepted and marked
as returning initialized memory.

Work around what appears to be an msan bug by calling malloc before we
call mmap.

Change-Id: I8ab7286d7595ae84782f68a98bef6d3688b946f9
Reviewed-on: https://go-review.googlesource.com/15170
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-09-30 22:17:55 +00:00
Robert Griesemer
829cc349c5 go/format: handle whitespace-only input correctly
Applied identical change to cmd/gofmt/internal.go.

Fixes #11275.

Change-Id: Icb4bf0460c94c9e2830dd0d62c69376774cbda30
Reviewed-on: https://go-review.googlesource.com/15154
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-09-30 16:39:43 +00:00
Robert Griesemer
a4fc3512ba go/format, cmd/gofmt: avoid dependency on internal package format
Fixes #11844.

Change-Id: I32edd39e79f7c9bdc132c49bd06081f35dac245d
Reviewed-on: https://go-review.googlesource.com/15114
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-09-30 16:32:47 +00:00
Russ Cox
0e5b4eb07b cmd/dist: build packages in parallel, make code more Go-like
(Changed modified by bradfitz from original rsc version)

Change-Id: I8ea40044c325f333a13d48b59b4795b02c579533
Reviewed-on: https://go-review.googlesource.com/14026
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-29 16:30:15 +00:00
Håvard Haugen
c73df92be6 cmd/compile/internal/gc: remove stringsCompare
Inlined the last occurrence of stringsCompare into exprcmp.

Passes go build -a -toolexec 'toolstash -cmp' std cmd.

Change-Id: I8fd99e3fbffc84283cc269368595cba950533066
Reviewed-on: https://go-review.googlesource.com/14872
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-29 07:13:30 +00:00
Rob Pike
0722a5e718 cmd/doc: fix pretty printing of paths
The code to strip GOROOT and GOPATH had a bug: it assumed there
were bytes after the GOROOT prefix but there might not be.
Fix this and other issues by taking care the prefix is really a
file name prefix for the path, not just a string prefix, and
handle the case where GOROOT==path.

Change-Id: I8066865fd05f938bb6dbf3bb8ab1fc58e5cf6bb5
Reviewed-on: https://go-review.googlesource.com/15112
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-29 02:18:57 +00:00
Rob Pike
c978f13a71 cmd/doc: rearrange the newlines to group better
Main change is that the comment for an item no longer has a blank line
before it, so it looks bound to the item it's about.

Motivating example: go doc.io.read changes from

<
func (l *LimitedReader) Read(p []byte) (n int, err error)
func (r *PipeReader) Read(data []byte) (n int, err error)

    Read implements the standard Read interface: it reads data from the pipe,
    blocking until a writer arrives or the write end is closed. If the write end
    is closed with an error, that error is returned as err; otherwise err is
    EOF.
func (s *SectionReader) Read(p []byte) (n int, err error)
>

to

<
func (l *LimitedReader) Read(p []byte) (n int, err error)
func (r *PipeReader) Read(data []byte) (n int, err error)
    Read implements the standard Read interface: it reads data from the pipe,
    blocking until a writer arrives or the write end is closed. If the write end
    is closed with an error, that error is returned as err; otherwise err is
    EOF.

func (s *SectionReader) Read(p []byte) (n int, err error)
>

Now the comment about PipeReader.Read doesn't look like it's about
SectionReader.

Based on a suggestion by dsnet@, a slight tweak from a CL he suggested
and abandoned.

Fixes #12756,

Change-Id: Iaf60ee9ae7f644c83c32d5e130acab0312b0c926
Reviewed-on: https://go-review.googlesource.com/14999
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-28 16:27:33 +00:00
Ian Lance Taylor
09c6d13ac2 cmd/cgo: only declare real function in gccgo exported header file
When exporting a function using gccgo, we generate two functions: a Go
function with a leading Cgoexp_ prefix, and a C function that calls the
Go function.  The Go function has a name that can not be represented in
C, so the C code needs a declaration with an __asm__ qualifier giving
the name of the Go function.

Before this CL we put that declaration in the exported header file.
Because code would sometimes #include "_cgo_export.h", we added a macro
definition for the C function giving it the name of the declaration.  We
then added a macro undefine in the actual C code, so that we could
declare the C function we wanted.

This rounadabout process worked OK until we started exporting the header
file for use with -buildmode=c-archive and c-shared.  Doing that caused
the code to see the define and thus call the Go function rather than the
C function.  That often works fine, but the C function calls
_cgo_wait_runtime_init_done before calling the Go function, and that
sometimes matters.  This didn't show up in tests because we don't test
using gccgo.  That is something we should fix, but not now.

Fix that by simplifying the code to declare the C function in the header
file as one would expect, and move the __asm__ declaration to the C
code.

Change-Id: I33547e028152ff98e332630994b4f33285feec32
Reviewed-on: https://go-review.googlesource.com/15043
Reviewed-by: Minux Ma <minux@golang.org>
2015-09-28 04:37:31 +00:00
Joel Sing
c4689579c0 cmd/go: Skip note reading test with linkmode external on openbsd/arm
openbsd/arm does not support external linking - skip the note reading test that
uses linkmode external on this platform. While here, cleanup the code and
consistently use t.Skipf for all platforms that cannot run this test.

Change-Id: I64f0d9e038bc4c993c3d843fc069a0b723a924d6
Reviewed-on: https://go-review.googlesource.com/15054
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-27 01:04:59 +00:00
Shawn Walker-Salas
dc6df1b070 cmd/go: elide -rpath when not applicable and used via LDFLAGS
Some linker flags should only be applied when performing the final
linking step for a shared library or executable, etc. In other
contexts, they're either invalid, or meaningless to apply (so should
not be specified).

When an external linker is used (either directly by Go or by the
compiler driver used by cgo), -rpath and -rpath-link should only be
specified in the final linking step.  On platforms such as Solaris,
ld(1) will reject its use in any other scenario (such as when linking
relocatable objects).

This change is necessary because Go does not currently offer a way to
specify LDFLAGS based on when they should be applied.

Fixes #12115

Change-Id: If35a18d8eee8ec7ddcca2d4ccd41ab6ffcf93b41
Reviewed-on: https://go-review.googlesource.com/14674
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-25 17:53:00 +00:00
Rob Pike
007fa019a3 cmd/doc: don't stop after first package if the symbol is not found
The test case is
	go doc rand.Float64
The first package it finds is crypto/rand, which does not have a Float64.
Before this change, cmd/doc would stop there even though math/rand
has the symbol. After this change, we get:

	% go doc rand.Float64
	package rand // import "math/rand"

	func Float64() float64

	    Float64 returns, as a float64, a pseudo-random number in [0.0,1.0) from the
	    default Source.
	%

Another nice consequence is that if a symbol is not found, we might get
a longer list of packages that were examined:

	% go doc rand.Int64
	doc: no symbol Int64 in packages crypto/rand, math/rand
	exit status 1
	%

This change introduces a coroutine to scan the file system so that if
the symbol is not found, the coroutine can deliver another path to try.
(This is darned close to the original motivation for coroutines.)
Paths are delivered on an unbuffered channel so the scanner does
not proceed until candidate paths are needed.

The scanner is attached to a new type, called Dirs, that caches the results
so if we need to scan a second time, we don't walk the file system
again. This is significantly more efficient than the existing code, which
could scan the tree multiple times looking for a package with
the symbol.

Change-Id: I2789505b9992cf04c19376c51ae09af3bc305f7f
Reviewed-on: https://go-review.googlesource.com/14921
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-24 23:04:37 +00:00
Marvin Stenger
44ab8bab1c compile/internal/gc,internal/obj: remove some usages of obj.Bool2int
Passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: Iea8c7bba2401f61ddf2caffc4bece2c293d10f74
Reviewed-on: https://go-review.googlesource.com/14951
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-24 15:39:50 +00:00
Marvin Stenger
550b7ccf77 cmd/link/internal/ld: removed some uses of stringsCompare
Only one use of stringsCompare is left. Cannot simply be replaced by
strings.Compare for bootstrapping reasons I guess.
Moving the function away from util.go to the actual destination data.go
also would not help much. So I left this one unchanged for readability and convenience.

Change-Id: I60d22fec0be8f8c47c80586436f9a550af59194e
Reviewed-on: https://go-review.googlesource.com/14953
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-24 15:05:04 +00:00
Marvin Stenger
ffe743945f cmd/compile/internal/gc: move functions from util.go to lex.go
Moves the functions:
        isSpace(int) bool
        isAlpha(int) bool
        isDigit(int) bool
        isAlnum(int) bool
        plan9quote(string) string

Passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I6f946981abb6f29b047ad90d5c117847e826789f
Reviewed-on: https://go-review.googlesource.com/14952
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-24 14:45:28 +00:00
Marvin Stenger
d08f34e744 cmd/compile/internal/gc: convert return values from int to bool
Passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I895350987661c1855803d1594dbab16068f8d1bc
Reviewed-on: https://go-review.googlesource.com/14873
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-24 12:54:22 +00:00
Shenghou Ma
2c96e5d2fc cmd/dist: fix build after "go test" argument order change
Change-Id: I332cd4a4b48cbb52d2beeb16c4a24833bb7069d7
Reviewed-on: https://go-review.googlesource.com/14890
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-23 23:10:14 +00:00
Rob Pike
6acb4d944d cmd/go: fix processing of flags for test binaries.
The usage message says:

	test [-c] [-i] [build and test flags] [packages] [flags for test binary]

but this was not what was implemented. Instead, after packages are named,
flag processing continues, which makes it impossible, for example, to pass
to the binary a flag with the same name as a test flag. This was triggered
by the -v flag in glog.

Consider this test:

package pkg

... imports ...

var v = flag.Int("v", 0, "v flag")

func TestFoo(t *testing.T) {
	if *v != 7 { log.Fatal(*v) }
}

Attempting to run this test with go test pkg -v=7 would give a usage
message. This change allows it. In fact it allows

	go test -v pkg -v=7

The solution is to implement the usage message. One compatibility
issue is that flags after the package name are no longer processed
as test flags, so this no longer works:

	go test foo -cover

One must write

	go test -cover foo

I do not think this is onerous but it must be called out in the
release notes.

Fixes #12177.

Change-Id: Ib9267884b47a6b0c183efa888ec78333272113aa
Reviewed-on: https://go-review.googlesource.com/14826
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-23 21:21:40 +00:00
David Chase
579ccd831f [dev.ssa] cmd/compile: remove done items from TODO
Change-Id: I5ee2953f7d387ef5bc70f6958763f775f0ae72dc
Reviewed-on: https://go-review.googlesource.com/14880
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-23 14:54:29 +00:00
David Chase
956f3199a3 [dev.ssa] cmd/compile: addressed vars and closures
Cleaned up first-block-in-function code.
Added cases for |PHEAP for PPARAM and PAUTO.
Made PPARAMOUT act more like PAUTO for purposes
of address generation and vardef placement.
Added cases for OCLOSUREVAR and Ops for getting closure
pointer.  Closure ops are scheduled at top of entry block
to capture DX.

Wrote test that seems to show proper behavior for addressed
parameters, locals, and returns.

Change-Id: Iee93ebf9e3d9f74cfb4d1c1da8038eb278d8a857
Reviewed-on: https://go-review.googlesource.com/14650
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2015-09-22 18:07:03 +00:00
Ilya Tocar
5cf281a9b7 runtime: optimize duffcopy on amd64
Use movups to copy 16 bytes at a time.
Results (haswell):

name            old time/op  new time/op  delta
CopyFat8-48     0.62ns ± 3%  0.63ns ± 3%     ~     (p=0.535 n=20+20)
CopyFat12-48    0.92ns ± 2%  0.93ns ± 3%     ~     (p=0.594 n=17+18)
CopyFat16-48    1.23ns ± 2%  1.23ns ± 2%     ~     (p=0.839 n=20+19)
CopyFat24-48    1.85ns ± 2%  1.84ns ± 0%   -0.48%  (p=0.014 n=19+20)
CopyFat32-48    2.45ns ± 0%  2.45ns ± 1%     ~     (p=1.000 n=16+16)
CopyFat64-48    3.30ns ± 2%  2.14ns ± 1%  -35.00%  (p=0.000 n=20+18)
CopyFat128-48   6.05ns ± 0%  3.98ns ± 0%  -34.22%  (p=0.000 n=18+17)
CopyFat256-48   11.9ns ± 3%   7.7ns ± 0%  -35.87%  (p=0.000 n=20+17)
CopyFat512-48   23.0ns ± 2%  15.1ns ± 2%  -34.52%  (p=0.000 n=20+18)
CopyFat1024-48  44.8ns ± 1%  29.8ns ± 2%  -33.48%  (p=0.000 n=17+19)

Change-Id: I8a78773c656d400726a020894461e00c59f896bf
Reviewed-on: https://go-review.googlesource.com/14836
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-22 15:02:37 +00:00
Robert Griesemer
c396c047c6 src/cmd/compile/internal/gc: remove now unnecessary restriction on float exponent parsing
https://go-review.googlesource.com/#/c/13778/ fixed this issue in math/big.
Remove restriction in compiler.

Fixes #11326.

Change-Id: I1429d0dd0d79431706c65616413373fff58f081e
Reviewed-on: https://go-review.googlesource.com/14830
Reviewed-by: Rob Pike <r@golang.org>
2015-09-22 00:22:49 +00:00
Rob Pike
980cb0caf2 cmd/asm: fix crash triggered by nested #define
A panic was in place for an impossible condition that turned
out to be possible if one used a macro to define a macro.

Another go-fuzz "win".

Fixes #12654.

Change-Id: I0a7bb0f0eabb260c986bf7a2288860c78d8db1af
Reviewed-on: https://go-review.googlesource.com/14777
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-21 22:38:39 +00:00
Håvard Haugen
bca70a66a7 cmd/compile/internal/gc: use sort.Interface for reflect methods
Generate slices of method *Sig(nature)s instead of linked lists.
Remove custom lsort function in favor of sort.Interface.

Eliminates another use of stringsCompare.

Passes go build -a -toolexec 'toolstash -cmp' std cmd.

Change-Id: I9ed1664b7f55be9e967dd7196e396a76f6ea3422
Reviewed-on: https://go-review.googlesource.com/14559
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-21 22:27:53 +00:00
Rob Pike
ebd96933c1 cmd/vet: build the binary only once in the test
Recent changes caused vet to build the binary for each Test function.
This is wasteful and will become only more so as more tests are added.
Use testing.Main to build only once.

Verified that compilation errors still appear if the binary cannot be
built.

Before:
	real	0m11.169s
	user	0m18.328s
	sys	0m2.152s

After:
	real	0m5.132s
	user	0m9.404s
	sys	0m1.168s

Of course if the compiler were fast we might not notice, but vet is
a big program and growing bigger all the time, as are the tests.

Change-Id: I209a8fdcace94bc5cec946f5dd365d7191f44c02
Reviewed-on: https://go-review.googlesource.com/14822
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-21 20:20:32 +00:00
Rob Pike
7454f53604 cmd/vet: copy changes from golang.org/x/tools to cmd/vet
This means bringing over the examples flag and sorting doc.go.

Subsequent changes will generalize the examples flag to a general
test naming flag, but let's start with the original code.

No more changes to golang.org/x/tools please. This should not have
happened (and letting it happen was partly my fault).

Change-Id: Ia879ea1d15d82372df14853f919263125dfb7b96
Reviewed-on: https://go-review.googlesource.com/14821
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-21 17:48:38 +00:00
Rob Pike
4e99ed6fef cmd/doc: don't drop const/var block if first entry is unexported
The code assumed that if the first entry was unexported, all the
entries were. The fix is simple: delete a bunch of code.

Fixes #12286.

Change-Id: Icb09274e99ce97df4d8bddbe59d17a5c0622e4c6
Reviewed-on: https://go-review.googlesource.com/14780
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-21 16:42:09 +00:00
Keith Randall
04d6edc36d [dev.ssa] cmd/compile: clean up zeroing. Use duffzero when appropriate.
Change-Id: I4deb03340e87f43179d5e22bf81843c17b5581fc
Reviewed-on: https://go-review.googlesource.com/14756
Reviewed-by: David Chase <drchase@google.com>
2015-09-21 03:24:30 +00:00
Keith Randall
3a70bf9c0c [dev.ssa] cmd/compile: use function calls instead of special ops for panics
There's no need for special ops for panicindex and panicslice.
Just use regular runtime calls.

Change-Id: I71b9b73f4f1ebce1220fdc1e7b7f65cfcf4b7bae
Reviewed-on: https://go-review.googlesource.com/14726
Reviewed-by: David Chase <drchase@google.com>
2015-09-21 02:54:06 +00:00
Håvard Haugen
6d0178359f cmd/compile/internal/gc: eliminate stringsCompare for stackvar sorting
Passes go build -a -toolexec 'toolstash -cmp' std cmd.

Change-Id: I2a87d31da74affdf3d0f358d0efdb3f1c646d917
Reviewed-on: https://go-review.googlesource.com/14759
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-20 21:07:12 +00:00
Keith Randall
8c5bfcc52b [dev.ssa] cmd/compile: Move runtime call gen to its own function
Change-Id: I5de36244de4dcc4a9827ee0fa04526e3e3578e7f
Reviewed-on: https://go-review.googlesource.com/14755
Reviewed-by: David Chase <drchase@google.com>
2015-09-20 07:18:11 +00:00
Keith Randall
d29e92be52 [dev.ssa] cmd/compile: Use varkill only for non-SSAable vars
For variables which get SSA'd, SSA keeps track of all the def/kill.
It is only for on-stack variables that we need them.

This reduces stack frame sizes significantly because often the
only use of a variable was a varkill, and without that last use
the variable doesn't get allocated in the frame at all.

Fixes #12602

Change-Id: I3f00a768aa5ddd8d7772f375b25f846086a3e689
Reviewed-on: https://go-review.googlesource.com/14758
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-20 07:10:05 +00:00
Keith Randall
37590bddc4 [dev.ssa] cmd/compile: move un-SSAable objects
We need to move any objects whose types are not SSA-able.

Fixes the "not lowered: Load ARRAY PTR64 mem" errors.

Change-Id: I7a0b609f917d7fb34bc9215fee4da15f9961cf6c
Reviewed-on: https://go-review.googlesource.com/14753
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-19 18:22:46 +00:00