1
0
mirror of https://github.com/golang/go synced 2024-11-14 08:40:27 -07:00
Commit Graph

46827 Commits

Author SHA1 Message Date
Tamir Duberstein
a671e33c6d all: use more precise build tags
s/!gccgo/gc/ in files which use gc-syntax assembly.

Change-Id: Ifdadb62edd1210ebc70e7cd415648b752afaf067
Reviewed-on: https://go-review.googlesource.com/c/go/+/269957
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: David Chase <drchase@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
2021-02-23 19:55:03 +00:00
Joel Sing
c584f42dcf cmd/compile: change riscv64 Eq32/Neq32 to zero extend before subtraction
As done with other equality tests, zero extend before subtraction rather than
after (or in this case, at the same time). While at face value this appears to
require more instructions, in reality it allows for most sign extensions to
be completely eliminated due to correctly typed loads. Existing optimisations
(such as subtraction of zero) then become more effective.

This removes more than 10,000 instructions from the Go binary and in particular,
a writeBarrier check only requires three instructions (AUIPC, LWU, BNEZ) instead
of the current four (AUIPC, LWU, NEGW, BNEZ).

Change-Id: I7afdc1921c4916ddbd414c3b3f5c2089107ec016
Reviewed-on: https://go-review.googlesource.com/c/go/+/274066
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
2021-02-23 18:39:53 +00:00
Russ Cox
080119799b runtime: fix usleep on windows/arm
Changed calling convention to pre-multiply the argument by -100,
and then deleted the * 100 but not the negation in the windows/arm assembly.
Delete the negation.

Fixes the current all.bash breakage on windows/arm builder.
(Maybe that will uncover more.)

Change-Id: I13006a44866ecc007586deb180a49c038d70aa99
Reviewed-on: https://go-review.googlesource.com/c/go/+/295529
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-02-23 18:35:59 +00:00
David Chase
74cac8d479 cmd/compile: add AMD64 parameter register defs, Arg ops, plumb to ssa.Config
This is partial plumbing recycled from the original register abi test work;
these are the parts that translate easily.  Some other bits are deferred till
later when they are ready to be used.

For #40724.

Change-Id: Ica8c55a4526793446189725a2bc3839124feb38f
Reviewed-on: https://go-review.googlesource.com/c/go/+/260539
Trust: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-02-23 18:14:42 +00:00
Keith Randall
42cd40ee74 cmd/compile: improve bit test code
Some bit test instruction generation stopped triggering after
the change to addressing modes. I suspect this was just because
ANDQload was being generated before the rewrite rules could discover
the BTQ. Fix that by decomposing the ANDQload when it is surrounded
by a TESTQ (thus re-enabling the BTQ rules).

Fixes #44228

Change-Id: I489b4a5a7eb01c65fc8db0753f8cec54097cadb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/291749
Trust: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-02-23 18:02:48 +00:00
Jason A. Donenfeld
f1562c7610 cmd/go: recognize DLL magic from llvm binaries
When using LLD with c-shared, the magic in the output DLL is slightly
different than for EXEs.

Change-Id: Icc5f34f7bb61f11a9d75494236b7797cc1988b40
Reviewed-on: https://go-review.googlesource.com/c/go/+/291638
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-23 17:58:33 +00:00
Cherry Zhang
bf5fa2d198 cmd/compile: guard special register usage with GOEXPERIMENT=regabi
Previously, some special register uses are only guarded with ABI
wrapper generation (-abiwrap). This CL makes it also guarded with
the GOEXPERIMENT. This way we can enable only the wrapper
generation without fully the new ABI, for benchmarking purposes.

Change-Id: I90fc34afa1dc17c9c73e7b06e940e79e4c4bf7f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/295289
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-23 17:53:19 +00:00
Andy Pan
c7f596f919 cmd/go: resolve TODO by replacing InDir() function
Change-Id: Idf886bbc4e66c9ee2a41c90034075301e0a21a58
Reviewed-on: https://go-review.googlesource.com/c/go/+/271909
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
2021-02-23 17:38:55 +00:00
Alberto Donizetti
5e94fe9316 go/build/constraint: fix splitPlusBuild func doc comment
Noticed while reading the code of the new package; likely a copy-paste
from the splitGoBuild function, which is almost identical.

Change-Id: I869272123708d25d237a4f0445f8e853865747f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/295469
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-02-23 16:48:00 +00:00
Andy Pan
55d7dcc3cd runtime: optimize the memory padding in p struct
Since allocation for p struct will be rounded up to the next size class,
the two relevant adjacent classes for this case are 9728 bytes and 10240 bytes.

A p is currently 10072 bytes, so it gets rounded up to 10240 bytes when we allocate one,
So the pad in p struct is unnecessary, eliminate it and add comments for
warning the false sharing.

Change-Id: Iae8b32931d1beddbfff1f58044d8401703da6407
Reviewed-on: https://go-review.googlesource.com/c/go/+/268759
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
2021-02-23 16:02:56 +00:00
Jason A. Donenfeld
ab331c0254 runtime/cgo: use correct lean and mean macro
WIN64_LEAN_AND_MEAN is not the correct macro to use and doesn't ever
exist.

Change-Id: I32a5523cc0f7cc3f3a4d022071cf81f88db39aa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/291634
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-02-23 15:04:12 +00:00
Jason A. Donenfeld
91cfbf39e4 cmd/link: set .ctors COFF section to writable and aligned
Without setting these flags, LLVM's LLD ignores the .ctors section when
merging objects.

Updates #44250.
Updates #39326.
Updates #38755.
Updates #36439.
Updates #43800.

Change-Id: I8766104508f7acd832088a590ee7d68afa0d6065
Reviewed-on: https://go-review.googlesource.com/c/go/+/291633
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-23 15:03:54 +00:00
Jason A. Donenfeld
811167e2c9 cmd/link: do not pass -Bsymbolic for PE DLLs
This is only a valid option on ELF. Binutils accepts it, but LLVM
rejects it, so for Windows, it's best to just omit it.

Updates #44250.
Updates #39326.
Updates #38755.
Updates #36439.
Updates #43800.

Change-Id: Iffd2345d757f23dd737e63bd464cd412527077c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/291632
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-23 15:03:39 +00:00
Jason A. Donenfeld
a51daac840 cmd/link: set SizeOfRawData rather than VirtualSize in COFF files for .bss section
GCC and Clang both set the SizeOfRawData field rather than the
VirtualSize field for communicating the size of the .bss section. As a
consequence, LLD does not look at VirtualSize and collapses the .bss
section into whatever is around it, resulting in runtime crashes. This
commit changes the logic so that if the requested "file size" is 0, then
the SizeOfRawData field is set rather than the VirtualSize field as the
sole length marker.

Fixes #44250.
Fixes #39326.
Updates #38755.
Updates #36439.
Updates #43800.

Change-Id: Ied89ddaa0a717fed840238244c6e4848845aeeb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/291630
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-23 15:03:26 +00:00
Than McIntosh
e5159b2a2f cmd/internal/dwarf: minor cleanups
Remove a stale comment, demote PutInlinedFunc from public to private,
and remove an unused interface originally used for sorting vars.
No change in functionality.

Change-Id: I5ee1ad2b10b78b158e2223c6979bab830202db95
Reviewed-on: https://go-review.googlesource.com/c/go/+/295009
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-23 12:49:05 +00:00
Joel Sing
b3b65f2176 runtime: enable race detector on openbsd/amd64
Now that this commit[1] has landed in LLVM the .syso file can be generated for
OpenBSD.

With the changes to src/runtime running the sample race[2] detects the data
race as expected.

Based on golang/go#39464 (https://go-review.googlesource.com/c/go/+/237057) from
Aaron Bieber <deftly@gmail.com>, however the race_openbsd_amd64.syso file has
been built on OpenBSD 6.4 and necessary changes added to race.bash.

[1] fcf6ae2f07
[2] https://golang.org/doc/articles/race_detector.html

Change-Id: Ic2479ccfa91d6b2cb4585346a11d813d96450f68
Reviewed-on: https://go-review.googlesource.com/c/go/+/275892
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-02-23 12:14:32 +00:00
Andy Pan
a78b0e6721 internal/poll: fix the verbose condition in splice
Change-Id: I0b433ea1a78632de20ea58c48c9be0f1fb6eb083
Reviewed-on: https://go-review.googlesource.com/c/go/+/271499
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
2021-02-23 10:04:13 +00:00
Tobias Klauser
08543f0715 ios/fs: mention f.dir in (*subFS).fixErr godoc
There is no dir parameter to (f *subFS).fixErr.

Change-Id: I49e42bac5e102cfab0d289658d9871429cfec515
Reviewed-on: https://go-review.googlesource.com/c/go/+/292389
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-23 09:16:54 +00:00
Joel Sing
0398a771d2 cmd/internal/obj/riscv: prevent constant loads that do not target registers
Check that the target of a constant load is a register and add test coverage
for this error condition. While here, rename the RISC-V testdata and tests
to be consistent with other platforms.

Change-Id: I7fd0bfcee8cf9df0597d72e65cd74a2d0bfd349a
Reviewed-on: https://go-review.googlesource.com/c/go/+/292895
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-23 09:15:50 +00:00
Joel Sing
6525abddce cmd/internal/obj/riscv: clean up branch tests
Address review comments from earlier changes, which would have previously
caused unwanted conflicts.

Change-Id: If2c61ffe977d721cccf276f931825b003521fda1
Reviewed-on: https://go-review.googlesource.com/c/go/+/284116
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
2021-02-23 09:15:36 +00:00
Russ Cox
c4b771348c runtime: fix windows/arm signal handling assembly
Bug introduced in CL 288799: R12 is used but not set.

Fixes windows/arm builder.

Change-Id: I015a5a83cfa3bdd23da1ffb73713623764f2f817
Reviewed-on: https://go-review.googlesource.com/c/go/+/295109
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-02-23 09:14:42 +00:00
Cuong Manh Le
2a18e37c4e cmd/compile: remove backend's "scratch mem" support
This CL rebases CL 273987 on top of master with @mdempsky's permission.

The last (only?) use for this feature was 387 support, which was
removed in golang.org/cl/258957.

Change-Id: I4f79fee8d0c336c9b6082bcd5eb6ece52c032dc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/292893
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-02-23 06:01:42 +00:00
Cuong Manh Le
e52149822b cmd/compile: simplify assert{E,I}2I{,2} calling conventions
This CL rebases CL 273694 on top of master with @mdempsky's permission.

For assertE2I and assertI2I, there's no need to pass through the
interface's data pointer: it's always going to come back unmodified.

For assertE2I2 and assertI2I2, there's no need for an extra bool
result parameter: it's redundant with testing the returned interface
value for nil.

Change-Id: Ic92d4409ad381952f875d3d74b8cf11c32702fa6
Reviewed-on: https://go-review.googlesource.com/c/go/+/292892
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-02-23 06:01:29 +00:00
Cuong Manh Le
86deb459de cmd/compile: remove selectnbrecv2
Previous CL did remove selectnbrecv2 in runtime, the compiler now only
call selectnbrecv, so remove this. Make this as separated CL because it
adds much of noise to git stat.

Change-Id: I06e89c823c0403e9bd66f2633409c455a46d6e79
Reviewed-on: https://go-review.googlesource.com/c/go/+/292891
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-02-23 05:02:42 +00:00
Cuong Manh Le
4048491234 cmd/compile,runtime: make selectnbrecv return two values
The only different between selectnbrecv and selectnbrecv2 is the later
set the input pointer value by second return value from chanrecv.

So by making selectnbrecv return two values from chanrecv, we can get
rid of selectnbrecv2, the compiler can now call only selectnbrecv and
generate simpler code.

Change-Id: Ifaf6cf1314c4f47b06ed9606b1578319be808507
Reviewed-on: https://go-review.googlesource.com/c/go/+/292890
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-02-23 05:02:26 +00:00
Cuong Manh Le
5e804ba17d cmd/compile: use transitive relations for slice len/cap in poset
Currently, we keep track of slice len by mapping from slice ID to
len/cap SSA value. However, slice len/cap can have multiple SSA values,
so when updating fact table for slice len/cap, we only update in one
place.

Instead, we can take advantage of the transitive relations provided by
poset. So all duplicated slice lens are set as equal to one another.
When updating fact table for one, that fact will be reflected to all
others. The same mechanism is applied for slice cap.

Removes 15 bounds checks from std/cmd.

Fixes #42603

Change-Id: I32c07968824cc33765b1e441b3ae2c4b5f5997c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/273670
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-02-23 05:01:04 +00:00
Robert Griesemer
6a40dd05d8 cmd/compile/internal/types2: review of sanitize.go
Remove the "// UNREVIEWED" marker and add guards (as in go/types)
to prevent data races. To see the added guards, see compare patch
sets 3 and 4. The equivalent changes for go/types were done in
https://golang.org/cl/294411.

Change-Id: Ibef07eaae400bd32bff32b102cc743580290d135
Reviewed-on: https://go-review.googlesource.com/c/go/+/294510
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-02-23 04:51:48 +00:00
Cuong Manh Le
975ba6e2b2 cmd/compile: mark OpSB, OpSP as poor statement Op
So that would make them last choice for a statement boundary.

This is follow up of CL 273506.

Change-Id: I0203aa0e0d95d538064c2113143c85c4fbb1e65e
Reviewed-on: https://go-review.googlesource.com/c/go/+/273666
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-02-23 04:17:35 +00:00
Robert Griesemer
a2e150c7cd go/types, cmd/compile/internal/types2: use regular type printing for unsafe.Pointer
Type string printing special-cased printing of unsafe.Pointer because
it's a built-in type; yet it's declared in a package like any other
imported or used-defined type (unlike built-in types such as int).

Use the same mechanism for printing unsafe.Pointer like any other
(non-basic) type. This will make it possible to use the package
Qualifier if so desired.

Fixes #44515.

Change-Id: I0dd1026f850737ecfc4bb99135cfb8e3c18be9e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/295271
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-02-23 04:13:24 +00:00
Robert Griesemer
5a0e4fc4e7 cmd/compile/internal/types2: review of conversions.go
The changes between (equivalent, and reviewed) go/types/conversions.go
and conversions.go can be seen by comparing patchset 1 and 2. The actual
change is just removing the "// UNREVIEWED" marker.

Change-Id: I86d20d8100ec29fe3be996b975c9b4aff01be85e
Reviewed-on: https://go-review.googlesource.com/c/go/+/294509
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-02-23 04:13:20 +00:00
Robert Griesemer
89eb2b55b9 cmd/compile/internal/types2: review of issues_test.go
The changes between (equivalent, and reviewed) go/types/issues_test.go
and issues_test.go can be seen by comparing patchset 1 and 3. The actual
change is just removing the "// UNREVIEWED" marker and making making
some minor code adjustments to match go/types's version more closely.

Change-Id: I26f3f700d12db69fc68161a6b0dc081a0e9cd0d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/294473
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-02-23 04:13:16 +00:00
Robert Griesemer
378f73e2d5 cmd/compile/internal/types2: enable TestIssue25627
Since we have syntax.Walk, we can make this test work again.

Change-Id: I55cbde7303e5bcbe1123b6679f2ce859d377fd86
Reviewed-on: https://go-review.googlesource.com/c/go/+/294472
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-02-23 04:13:10 +00:00
Cuong Manh Le
1901e2647f test: add test for findTypeLoop with symbols from other packages
CL 274294 improved findTypeLoop but also fixed a new found bug on master
branch. This Cl adds test cases for this.

Updates #44266

Change-Id: Ie4a07a3487758a1e4ad2f2847dcde975b10d2a77
Reviewed-on: https://go-review.googlesource.com/c/go/+/292889
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-02-23 04:10:09 +00:00
Dan Scales
5f3dabbb79 cmd/compile: fix import of functions of multiple nested closure
For import of functions with closures, the connections among closure
variables are constructed on-the-fly via CaptureName(). For multiple
nested closures, we need to temporarily set r.curfn to each closure we
construct, so that the processing of closure variables will be correct
for any nested closure inside that closure.

Fixes #44335

Change-Id: I34f99e2822250542528ff6b2232bf36756140868
Reviewed-on: https://go-review.googlesource.com/c/go/+/294212
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-02-23 01:53:51 +00:00
yangwenmai
7af821a661 all: faster midpoint computation in binary search
On my machine (3.1 GHz Quad-Core Intel Core i7, macOS 10.15.7 10.15.7), go 1.15.6

benchstat:
name          old time/op  new time/op  delta
SearchInts-8  20.3ns ± 1%  16.6ns ± 6%  -18.37%  (p=0.000 n=9+10)

Change-Id: I346e5955fd6df6ce10254b22267dbc8d5a2b16c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/279439
Reviewed-by: Ben Shi <powerman1st@163.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
2021-02-23 01:37:31 +00:00
Cherry Zhang
f113e9a14f cmd/dist: match goexperiment.regabi tag when GOEXPERIMENT is on
Change-Id: I5e4347dde6dcb49cd96608e4f67e54c7b3050bc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/293851
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-02-23 00:20:38 +00:00
Rob Findley
1126bbb82a go/parser: return ast.BadExpr for missing index operands
The parser was returning the indexed operand when a slice or index or
instance expression was missing any index arguments (as in the
expression `a[]`). This can result in returning an *ast.Ident for the
LHS of the (invalid) assignment `a[] = ...` -- in this case parsing the
LHS as just `a`. Unfortunately, as the indexed operand `a` has already
been resolved, this results in a panic for duplicate resolution.

Fix this by instead returning an ast.BadExpr. This can suppress some
subsequent errors from the typechecker, but those errors may or may not
be correct anyway. Other interpretations, such as an *ast.IndexExpr with
bad or missing X, run into potential misinterpretations downstream (both
caused errors in go/types and/or gopls).

Fixes #44504

Change-Id: I5ca8bed4a1861bcc7db8898770b08937110981d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/295151
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-02-22 23:43:15 +00:00
Cherry Zhang
1678829d95 cmd/compile: correctly use X15 to zero frame
In CL 288093 we reserve X15 as the zero register and use that to
zero values. It only covered zeroing generated in SSA but missed
zeroing the frame generated late in the compilation. The latter
still uses X0, but now DUFFZERO expects X15, so it doesn't
actually zero the frame. Change it to use X15.

Should fix #44333.

Change-Id: I239d2b78a5f6468bc86b70aecdd294045311759f
Reviewed-on: https://go-review.googlesource.com/c/go/+/295210
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2021-02-22 23:37:09 +00:00
cui
094048b938 cmd/compile/internal: loop opt
Change-Id: I5fe767237b8046934e9b0f33bd3dafabdb727dd6
GitHub-Last-Rev: 94fea3d572
GitHub-Pull-Request: golang/go#44384
Reviewed-on: https://go-review.googlesource.com/c/go/+/293809
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-22 22:55:23 +00:00
zhengjianxun
1391d4142c fix typo in issue16760.go
fix typo in issue16760.go, unconditinally ->  unconditionally

Change-Id: I3a04fbcb23395c562821b35bc2d81cfaec0bc1ed
GitHub-Last-Rev: 5ce52a3deb
GitHub-Pull-Request: golang/go#44495
Reviewed-on: https://go-review.googlesource.com/c/go/+/294969
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: zhengjianxun <zhuimengshaonian04@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-02-22 22:53:51 +00:00
Josh Bleecher Snyder
04903476fe cmd/compile: reject some rare looping CFGs in shortcircuit
One CFGs that shortcircuit looks for is:
 
p   q
 \ /
  b
 / \
t   u

The test case creates a CFG like that in which p == t.
That caused the compiler to generate a (short-lived) invalid phi value.

Fix this with a relatively big hammer: Disallow single-length loops entirely.
This is probably overkill, but it such loops are very rare.
This doesn't change the generated code for anything in std.

It generates worse code for the test case:
It no longer compiles the entire function away.

Fixes #44465

Change-Id: Ib8cdcd6cc9d7f48b4dab253652038ace24eae152
Reviewed-on: https://go-review.googlesource.com/c/go/+/295130
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-02-22 20:27:09 +00:00
Josh Bleecher Snyder
87e984ab29 test: add test for issue 38698
It was fixed by CL 294289, for #44378.
This is a different style of test that uses
line directives instead of extremely long lines.

Fixes #38698.

Change-Id: I50a1585030978b35fffa9981d6ed96b99216dc3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/295129
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-22 20:00:00 +00:00
Paul E. Murphy
b2bdadfe88 cmd/internal: cleanup ppc64 optab structure
This is no-functionality change to begin the process of supporting
more than 6 operands.

This rewrites the table to use named arguments, and removes default
initialized argument values.  The following sed regexes rewrote the table:

  s/{\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\)}/{as:\1,a1:\2,a2:\3,a3:\4,a4:\5,type_:\6,size:\7,param:\8}
  s/a[1-4]: C_NONE, //g
  s/, param: 0//

Change-Id: I5f4de9da75f2fb3964d625d6b4e2f1ce1e29cc47
Reviewed-on: https://go-review.googlesource.com/c/go/+/294189
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
2021-02-22 18:51:18 +00:00
Than McIntosh
0f66fb7b85 go/internal/gccgoimporter: fix up gccgo installation test
Change the TestInstallationImporter testpoint to query type
information for sort.Search instead of sort.Ints. The latter function
changed recently (1.16 timeframe), parameter "a" is now "x". A better
candidate for this sort of query is sort.Search, which has been stable
for a while.

Fixes #44425.

Change-Id: I314476eac0b0802f86f5cbce32195cab2926db83
Reviewed-on: https://go-review.googlesource.com/c/go/+/294290
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-21 02:25:41 +00:00
Than McIntosh
e78e04ce39 cmd/compile: fix panic in DWARF-gen handling obfuscated code
DWARF generation uses variable source positions (file/line/col) as a
way to uniquely identify locals and parameters, as part of the process
of matching up post-optimization variables with the corresponding
pre-optimization versions (since the DWARF needs to be in terms of the
original source constructs).

This strategy can run into problems when compiling obfuscated or
machine-generated code, where you can in some circumstances wind up
with two local variables that appear to have the same name, file,
line, and column. This patch changes DWARF generation to skip over
such duplicates as opposed to issuing a fatal error (if an
obfuscation tool is in use, it is unlikely that a human being will be
able to make much sense of DWARF info in any case).

Fixes #44378.

Change-Id: I198022d184701aa9ec3dce42c005d29b72d2e321
Reviewed-on: https://go-review.googlesource.com/c/go/+/294289
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
2021-02-21 02:25:26 +00:00
Ian Lance Taylor
03d36d8198 syscall: add explicit ios build tag
This permits analysis of the syscall package by tools built with
older versions of Go that do not recognize ios as a GOOS.

Fixes #44459

Change-Id: I79cec2ffe0dbcbc2dc45a385e556dc9e62033125
Reviewed-on: https://go-review.googlesource.com/c/go/+/294634
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-20 19:56:50 +00:00
Alberto Donizetti
40656f3a75 doc/1.16: fix link to fs.FileInfo
Updates #40700

Change-Id: Ifff622ccadaa31c0c0684c3c695aadcaa2305623
Reviewed-on: https://go-review.googlesource.com/c/go/+/294669
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-20 19:33:34 +00:00
Russ Cox
d4b2638234 all: go fmt std cmd (but revert vendor)
Make all our package sources use Go 1.17 gofmt format
(adding //go:build lines).

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Change-Id: Ia0534360e4957e58cd9a18429c39d0e32a6addb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/294430
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-20 03:54:50 +00:00
Russ Cox
0625460f79 cmd/vet: update buildtag check for //go:build lines
Brings in golang.org/x/tools@2363391a
and adjusts, adds cmd/vet tests accordingly.

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

This brings in the new //go:build checks in cmd/vet.

Change-Id: I8a9735cc014171691012b307ec30e94c81aadfe1
Reviewed-on: https://go-review.googlesource.com/c/go/+/240609
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-02-20 03:54:48 +00:00
Russ Cox
9fd6cc105d go/printer: canonicalize //go:build and // +build lines while formatting
Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Gofmt and any other go/printer-using program will now:

 - move //go:build and //+build lines to the appropriate file location
 - if there's no //go:build line, add one derived from the // +build lines
 - if there is a //go:build line, recompute and replace any // +build lines
   to match what the //go:build line says

For Go 1.17.

Change-Id: Ide5cc3b4a07507ba9ed6f8b0de846e840876f49f
Reviewed-on: https://go-review.googlesource.com/c/go/+/240608
Trust: Russ Cox <rsc@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-02-20 03:54:46 +00:00