]> Cypherpunks repositories - gostls13.git/log
gostls13.git
4 years ago[dev.typeparams] cmd/compile/internal/types2: report error for invalid type expression
Robert Griesemer [Fri, 11 Dec 2020 02:07:09 +0000 (18:07 -0800)]
[dev.typeparams] cmd/compile/internal/types2: report error for invalid type expression

This bug was introduced by the change from go/ast to syntax which
represents pointer types as (unary) operations rather than dedicated
StarExpr nodes. Accordingly, this bug does not exist for go/types.
It's still ok to backport the test.

Fixes #43125.

Change-Id: Ic55d913f8afc92862856e1eb7c2861d07fc56cfb
Reviewed-on: https://go-review.googlesource.com/c/go/+/278013
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years ago[dev.typeparams] cmd/compile/internal/types2: report invalid ... in conversions
Robert Griesemer [Thu, 10 Dec 2020 19:30:18 +0000 (11:30 -0800)]
[dev.typeparams] cmd/compile/internal/types2: report invalid ... in conversions

This fixes the bug below for types2.

Updates #43124.

Change-Id: Ic1962d41f321d8a08992d8529625bc133e526b0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/278012
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years ago[dev.typeparams] test: finish triaging all outstanding failing tests
Robert Griesemer [Thu, 10 Dec 2020 04:14:07 +0000 (20:14 -0800)]
[dev.typeparams] test: finish triaging all outstanding failing tests

Also: Adjusted error patterns for passing test that have different
error messages.

Change-Id: I216294b4c4855aa93da22cdc3c0b3303e54a8420
Reviewed-on: https://go-review.googlesource.com/c/go/+/277994
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years ago[dev.typeparams] cmd/compile/internal/types2: don't report two errors for bad strings
Robert Griesemer [Thu, 10 Dec 2020 03:15:15 +0000 (19:15 -0800)]
[dev.typeparams] cmd/compile/internal/types2: don't report two errors for bad strings

If the parser reported an error for (string) literals, don't report
a second error during type checking.

This should have a couple of tests but they are tricky to arrange
with the current testing framework as the ERROR comment cannot be
on the line where the string. But the change is straightforward
and we have test/fixedbugs/issue32133.go that is passing now.

Change-Id: I0cd7f002b04e4092b8eb66009c7413288c8bfb23
Reviewed-on: https://go-review.googlesource.com/c/go/+/277993
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years ago[dev.typeparams] merge: merge branch 'dev.regabi' into 'dev.typeparams'
Robert Griesemer [Mon, 14 Dec 2020 19:53:55 +0000 (11:53 -0800)]
[dev.typeparams] merge: merge branch 'dev.regabi' into 'dev.typeparams'

The following files had merge conflicts and were merged manually:

src/cmd/compile/fmtmap_test.go
src/cmd/compile/internal/gc/noder.go
src/go/parser/error_test.go
test/assign.go
test/chan/perm.go
test/fixedbugs/issue22822.go
test/fixedbugs/issue4458.go
test/init.go
test/interface/explicit.go
test/map1.go
test/method2.go

The following files had manual changes to make tests pass:

test/run.go
test/used.go
src/cmd/compile/internal/types2/stdlib_test.go

Change-Id: Ia495aaaa80ce321ee4ec2a9105780fbe913dbd4c

4 years ago[dev.regabi] cmd/compile: add register ABI analysis utilities
Than McIntosh [Tue, 24 Nov 2020 23:10:11 +0000 (18:10 -0500)]
[dev.regabi] cmd/compile: add register ABI analysis utilities

Introduce a new utility routine for analyzing a given function
signature to how its various input and output parameters will be
passed (in registers or on the stack) for a given ABI description,
along with some unit tests.

Change-Id: Id64a98a0a142e42dd9c2dc9f6607c0d827ef84fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/273011
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Trust: Than McIntosh <thanm@google.com>

4 years ago[dev.regabi] cmd/compile: fix noopt builder
Matthew Dempsky [Fri, 11 Dec 2020 05:04:41 +0000 (21:04 -0800)]
[dev.regabi] cmd/compile: fix noopt builder

The non-simple, phi-insertion algorithm can leave OpFwdRefs in the SSA
graph unresolved if they're in dead blocks. Normally, these would be
harmlessly removed later during SSA dead-code elimination, but those
passes are omitted for -N builds. And so they reach zcse, where the
Value.Aux is used within a hash map.

This became a problem after golang.org/cl/275788, which added
FwdRefAux to wrap OpFwdRef's ir.Node, and to ensure that it's not
compared for equality / used as a map key.

This CL adds a simple fix: if there are any OpFwdRefs remaining after
resolveFwdRef, then they must be dead code and we can simply replace
them with OpUnknown.

Change-Id: I72e4116d52d3f6441ebb0bf6160906617cd59513
Reviewed-on: https://go-review.googlesource.com/c/go/+/277075
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years ago[dev.regabi] cmd/compile/internal/types: add IsScalar query method
Than McIntosh [Wed, 2 Dec 2020 21:13:45 +0000 (16:13 -0500)]
[dev.regabi] cmd/compile/internal/types: add IsScalar query method

Add method Type.IsScalar() method, which returns TRUE
for numeric and pointer-shaped types, false for composites
such as string/array/slice/struct.

Change-Id: Ie53c71c07c5b3fbae11b48addd172343dc6bf3fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/274857
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: refactor type initialization code into helper
Than McIntosh [Tue, 24 Nov 2020 23:09:00 +0000 (18:09 -0500)]
[dev.regabi] cmd/compile: refactor type initialization code into helper

Create a helper routine for initializing the types package, so as make
it easier to use in unit testing (in a follow-on patch).

Change-Id: I0f937788dfd34ac6641a4f28c16e47008aa08116
Reviewed-on: https://go-review.googlesource.com/c/go/+/273010
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: remove unnecessary String methods
Matthew Dempsky [Tue, 8 Dec 2020 04:05:17 +0000 (20:05 -0800)]
[dev.regabi] cmd/compile: remove unnecessary String methods

There were only a few places these were still used, none of which
justify generating all this code. Instead rewrite them to use
fmt.Sprint or simpler means.

Passes buildall w/ toolstash -cmp.

Change-Id: Ibd123a1696941a597f0cb4dcc96cda8ced672140
Reviewed-on: https://go-review.googlesource.com/c/go/+/276072
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
4 years agoMerge branch 'master' into dev.regabi
Alexander Rakoczy [Mon, 14 Dec 2020 16:42:42 +0000 (11:42 -0500)]
Merge branch 'master' into dev.regabi

Change-Id: I098acdbc5e2676aeb8700d935e796a9c29d04b88

4 years ago[dev.typeparams] cmd/compile/internal/types2: bring over subst.go changes from go...
Robert Griesemer [Thu, 10 Dec 2020 01:09:14 +0000 (17:09 -0800)]
[dev.typeparams] cmd/compile/internal/types2: bring over subst.go changes from go/types

This CL make this code match closely with the go/types version
(see https://golang.org/cl/276253).

Change-Id: I2b7841309fdbda7e2c9533768bd98317729b13b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/276814
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years ago[dev.typeparams] test: exclude 32bit-specific test that fails on 32bit platforms...
Robert Griesemer [Thu, 10 Dec 2020 01:17:36 +0000 (17:17 -0800)]
[dev.typeparams] test: exclude 32bit-specific test that fails on 32bit platforms (fix build)

Change-Id: I4f1d5d34dd9b26cea8e837a8ff7e833e02c913e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/276815
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile: don't constant fold divide by zero
Keith Randall [Wed, 9 Dec 2020 16:27:54 +0000 (08:27 -0800)]
cmd/compile: don't constant fold divide by zero

It just makes the compiler crash. Oops.

Fixes #43099

Change-Id: Id996c14799c1a5d0063ecae3b8770568161c2440
Reviewed-on: https://go-review.googlesource.com/c/go/+/276652
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years ago[dev.typeparams] cmd/compile/internal/types2: report correct line number for missing key
Robert Griesemer [Wed, 9 Dec 2020 23:49:04 +0000 (15:49 -0800)]
[dev.typeparams] cmd/compile/internal/types2: report correct line number for missing key

Use the Key position of a syntax.KeyValueExpr (not the position of the
":") when reporting an error for a missing key.

(In go/types, the KeyValueExpr position is the start of the expression
not the ":", so there this works as expected.)

Change-Id: I74147d245927847274cf4e53b4f03dbb5110c324
Reviewed-on: https://go-review.googlesource.com/c/go/+/276813
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years ago[dev.typeparams] cmd/compile/internal/types2: adjusted more error messages for compiler
Robert Griesemer [Wed, 9 Dec 2020 20:28:15 +0000 (12:28 -0800)]
[dev.typeparams] cmd/compile/internal/types2: adjusted more error messages for compiler

Triaged and adjusted more test/fixedbugs/* tests.

Change-Id: I80b9ead2445bb8d126b7d79db4bea9ddcb225a84
Reviewed-on: https://go-review.googlesource.com/c/go/+/276812
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years ago[dev.typeparams] cmd/compile/internal/types2: adjusted qualified identifier error...
Robert Griesemer [Wed, 9 Dec 2020 06:01:22 +0000 (22:01 -0800)]
[dev.typeparams] cmd/compile/internal/types2: adjusted qualified identifier error message for compiler

Also: Triaged/adjusted some more test/fixedbugs tests.
Change-Id: I050847b6dfccc7f301f8100bfdbe84e0487e33fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/276512
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years ago[dev.typeparams] cmd/compile/internal/types2: adjust init cycle error message for...
Robert Griesemer [Wed, 9 Dec 2020 01:56:35 +0000 (17:56 -0800)]
[dev.typeparams] cmd/compile/internal/types2: adjust init cycle error message for compiler

Enabled some more test/fixedbugs tests.

Change-Id: I02102b698eedfbee582b3234850fb01418ebbf7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/276453
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>

4 years ago[dev.typeparams] cmd/compile/internal/types2: adjusted array error message for compiler
Robert Griesemer [Wed, 9 Dec 2020 01:48:39 +0000 (17:48 -0800)]
[dev.typeparams] cmd/compile/internal/types2: adjusted array error message for compiler

Also: Triaged/adjusted some more test/fixedbugs tests.
Change-Id: Idaba1875273d6da6ef82dd8de8edd8daa885d32c
Reviewed-on: https://go-review.googlesource.com/c/go/+/276472
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agogo/types: avoid endless recursion in the Comparable predicate
Rob Findley [Wed, 9 Dec 2020 11:10:52 +0000 (06:10 -0500)]
go/types: avoid endless recursion in the Comparable predicate

This is a port of CL 276374 from the dev.typeparams branch. Avoid an
endless recursion in Comparable by tracking types that have already been
considered.

Fixes #43088

Change-Id: I927b29ac544df9bfb5c8c04699d57fafe6cfff73
Reviewed-on: https://go-review.googlesource.com/c/go/+/276552
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agoall: update to use os.ReadDir where appropriate
Russ Cox [Thu, 29 Oct 2020 18:46:29 +0000 (14:46 -0400)]
all: update to use os.ReadDir where appropriate

os.ReadDir is a replacement for ioutil.ReadDir that returns
a slice of fs.DirEntry instead of fs.FileInfo, meaning it is the
more efficient form.

This CL updates call sites throughout the Go source tree
wherever possible. As usual, code built using the Go 1.4
bootstrap toolchain is not included. There is also a use in
go/build that appears in the public API and can't be changed,
at least not without additional changes.

Fixes #42026.

Change-Id: Icfc9dd52c6045020f6830e22c72128499462d561
Reviewed-on: https://go-review.googlesource.com/c/go/+/266366
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoall: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp
Russ Cox [Thu, 29 Oct 2020 18:17:47 +0000 (14:17 -0400)]
all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp

As part of #42026, these helpers from io/ioutil were moved to os.
(ioutil.TempFile and TempDir became os.CreateTemp and MkdirTemp.)

Update the Go tree to use the preferred names.

As usual, code compiled with the Go 1.4 bootstrap toolchain
and code vendored from other sources is excluded.

ReadDir changes are in a separate CL, because they are not a
simple search and replace.

For #42026.

Change-Id: If318df0216d57e95ea0c4093b89f65e5b0ababb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/266365
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years ago[dev.regabi] cmd/compile: first start towards using Ident
Matthew Dempsky [Tue, 8 Dec 2020 05:56:58 +0000 (21:56 -0800)]
[dev.regabi] cmd/compile: first start towards using Ident

This CL adds Ident, which will eventually replace *Name and *PkgName
within the AST for representing uses of declared names. (Originally, I
intended to call it "IdentExpr", but neither go/ast nor
cmd/compile/internal/syntax include the "Expr" suffix for their
respective types.)

To start, this CL converts two uses of *Name to *Ident: the tag
identifier in a TypeSwitchGuard (which doesn't actually declare a
variable by itself), and the not-yet-known placeholder ONONAME
returned by oldname to stand-in for identifiers that might be declared
later in the package.

The TypeSwitchGuard's Name's Used flag was previously used for
detecting whether none of the per-clause variables were used. To avoid
bloating all Idents for this rare use, a "Used" bool is added to
TypeSwitchGuard instead. Eventually it could maybe be packed into
miniNode.bits, but for now this is good enough.

Passes buildall w/ toolstash -cmp.

Change-Id: I393284d86757cbbebd26e1320c7354e2bdcb30b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/276113
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
4 years ago[dev.regabi] cmd/compile: iexport debug crumbs for toolstash
Matthew Dempsky [Tue, 8 Dec 2020 09:28:57 +0000 (01:28 -0800)]
[dev.regabi] cmd/compile: iexport debug crumbs for toolstash

Prints offsets for declarations, inline bodies, and strings when -v is
used. Still not much, but hopefully useful for narrowing down the
cause of export data differences.

Change-Id: I9b2e4a3d55b92823fa45a39923e8c4b25303693c
Reviewed-on: https://go-review.googlesource.com/c/go/+/276112
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
4 years ago[dev.regabi] cmd/compile: adjust IR representations
Russ Cox [Mon, 7 Dec 2020 14:14:44 +0000 (09:14 -0500)]
[dev.regabi] cmd/compile: adjust IR representations

Based on actually using the IR when prototyping adding
type assertions, a few changes to improve it:

- Merge DeferStmt and GoStmt, since they are variants of one thing.
- Introduce LogicalExpr for && and ||, since they (alone) need an init list before Y.
- Add an explicit op to various constructors to make them easier to use.
- Add separate StructKeyExpr - it stores Value in a different abstract location (Left) than KeyExpr (Right).
- Export all fields for use by rewrites (and later reflection).

Passes buildall w/ toolstash -cmp.

Change-Id: Iefbff2386d2bb9ef511ce53b7f92ff6c709dc991
Reviewed-on: https://go-review.googlesource.com/c/go/+/275883
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: arrange for walkstmt, walkexpr, to return from switch cases
Russ Cox [Mon, 7 Dec 2020 05:04:54 +0000 (00:04 -0500)]
[dev.regabi] cmd/compile: arrange for walkstmt, walkexpr, to return from switch cases

Ending them in a returning switch makes it safe for each case
to do an appropriate type assertion.

Passes buildall w/ toolstash -cmp.

Change-Id: I55d8f0a555006104164d84d27822aa8c5ad68515
Reviewed-on: https://go-review.googlesource.com/c/go/+/275882
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: use reflection in ir.Dump
Russ Cox [Sun, 6 Dec 2020 20:17:05 +0000 (15:17 -0500)]
[dev.regabi] cmd/compile: use reflection in ir.Dump

ir.Dump is the final (I think!) piece of the compiler that was walking
nodes using Left, Right etc without knowing what they meant.
This CL uses reflection to walk nodes without knowing what they mean instead.
One benefit is that we can print actual meanings (field names).

While we are here, I could not resist fixing a long-standing mental TODO:
make the line number more clearly a line number. I've forgotten where the
line number is in the dumps far too many times in the last decade.

As a small example, here is a fragment of go tool compile -W test/235.go:

.   FOR l(28) tc(1)
.   .   LT-init
.   .   .   AS l(28) tc(1)
.   .   .   .   NAME-main..autotmp_4 l(28) x(0) class(PAUTO) esc(N) tc(1) assigned used int
.   .   .   .   LEN l(28) tc(1) int
.   .   .   .   .   NAME-main.xs g(2) l(26) x(0) class(PPARAM) esc(no) tc(1) used SLICE-[]uint64
.   .   LT l(28) tc(1) hascall bool
.   .   .   NAME-main.i g(4) l(28) x(0) class(PAUTO) esc(no) tc(1) assigned used int
.   .   .   NAME-main..autotmp_4 l(28) x(0) class(PAUTO) esc(N) tc(1) assigned used int
.   .   BLOCK l(28)
.   .   BLOCK-list
.   .   .   ASOP-ADD l(28) tc(1) implicit(true) int
.   .   .   .   NAME-main.i g(4) l(28) x(0) class(PAUTO) esc(no) tc(1) assigned used int
.   .   .   .   LITERAL-1 l(28) tc(1) int
.   FOR-body
.   .   VARKILL l(28) tc(1)
.   .   .   NAME-main..autotmp_4 l(28) x(0) class(PAUTO) esc(N) tc(1) assigned used int
.   .   IF l(29) tc(1)
.   .   .   LT l(29) tc(1) bool
.   .   .   .   INDEX l(29) tc(1) uint64
.   .   .   .   .   NAME-main.xs g(2) l(26) x(0) class(PPARAM) esc(no) tc(1) used SLICE-[]uint64
.   .   .   .   .   NAME-main.i g(4) l(28) x(0) class(PAUTO) esc(no) tc(1) assigned used int
.   .   .   .   NAME-main.m g(3) l(27) x(0) class(PAUTO) esc(no) tc(1) assigned used uint64
.   .   IF-body
.   .   .   AS l(30) tc(1)
.   .   .   .   NAME-main.m g(3) l(27) x(0) class(PAUTO) esc(no) tc(1) assigned used uint64
.   .   .   .   INDEX l(30) tc(1) uint64
.   .   .   .   .   NAME-main.xs g(2) l(26) x(0) class(PPARAM) esc(no) tc(1) used SLICE-[]uint64
.   .   .   .   .   NAME-main.i g(4) l(28) x(0) class(PAUTO) esc(no) tc(1) assigned used int

and here it is after this CL:

.   FOR tc(1) # 235.go:28
.   FOR-Cond
.   .   LT-init
.   .   .   AS tc(1) # 235.go:28
.   .   .   .   NAME-main..autotmp_4 x(0) class(PAUTO) esc(N) tc(1) assigned used int # 235.go:28
.   .   .   .   LEN tc(1) int # 235.go:28 int
.   .   .   .   .   NAME-main.xs g(2) x(0) class(PPARAM) esc(no) tc(1) used SLICE-[]uint64 # 235.go:26
.   .   LT tc(1) hascall bool # 235.go:28 bool
.   .   .   NAME-main.i g(4) x(0) class(PAUTO) esc(no) tc(1) assigned used int # 235.go:28
.   .   .   NAME-main..autotmp_4 x(0) class(PAUTO) esc(N) tc(1) assigned used int # 235.go:28
.   FOR-Post
.   .   BLOCK # 235.go:28
.   .   BLOCK-List
.   .   .   ASOP-ADD tc(1) implicit(true) int # 235.go:28 int
.   .   .   .   NAME-main.i g(4) x(0) class(PAUTO) esc(no) tc(1) assigned used int # 235.go:28
.   .   .   .   LITERAL-1 tc(1) int # 235.go:28
.   FOR-Body
.   .   VARKILL tc(1) # 235.go:28
.   .   .   NAME-main..autotmp_4 x(0) class(PAUTO) esc(N) tc(1) assigned used int # 235.go:28
.   .   IF tc(1) # 235.go:29
.   .   IF-Cond
.   .   .   LT tc(1) bool # 235.go:29 bool
.   .   .   .   INDEX tc(1) uint64 # 235.go:29 uint64
.   .   .   .   .   NAME-main.xs g(2) x(0) class(PPARAM) esc(no) tc(1) used SLICE-[]uint64 # 235.go:26
.   .   .   .   .   NAME-main.i g(4) x(0) class(PAUTO) esc(no) tc(1) assigned used int # 235.go:28
.   .   .   .   NAME-main.m g(3) x(0) class(PAUTO) esc(no) tc(1) assigned used uint64 # 235.go:27
.   .   IF-Body
.   .   .   AS tc(1) # 235.go:30
.   .   .   .   NAME-main.m g(3) x(0) class(PAUTO) esc(no) tc(1) assigned used uint64 # 235.go:27
.   .   .   .   INDEX tc(1) uint64 # 235.go:30 uint64
.   .   .   .   .   NAME-main.xs g(2) x(0) class(PPARAM) esc(no) tc(1) used SLICE-[]uint64 # 235.go:26
.   .   .   .   .   NAME-main.i g(4) x(0) class(PAUTO) esc(no) tc(1) assigned used int # 235.go:28

Note in particular the clear marking of FOR-Cond, FOR-Post, FOR-Body compared to the original.

The only changes to a few test files are the improved field name lines, and of course the line numbers.

Passes buildall w/ toolstash -cmp.

Change-Id: I5b654d9d8ee898976d4c387742ea688a082bac78
Reviewed-on: https://go-review.googlesource.com/c/go/+/275785
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: two small fixes
Russ Cox [Mon, 7 Dec 2020 20:26:24 +0000 (15:26 -0500)]
[dev.regabi] cmd/compile: two small fixes

Addressing comments from CL 275434 and CL 275444.
I forgot to run "git rw" to rebase the fixup CLs down before
running "git submit".

Change-Id: Ideaa2340a81511491c096555c6834cd9bdb267d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/275881
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agoruntime/metrics: simplify test to support more environments
Dmitri Shuralyov [Wed, 9 Dec 2020 00:44:33 +0000 (19:44 -0500)]
runtime/metrics: simplify test to support more environments

go test sets the working directory to that of the package being tested,
so opening one of the package source files can be done in a simpler way.
This also allows the test to run in more environments, for example when
GOROOT_FINAL¹ is set.

Also remove the testenv.HasSrc-like check for Go source. The doc.go
file is a part of the package being built and tested, so it's expected
to be available. If it's important for this test to handle when a test
binary is built with go test -c and executed elsewhere without package
source files, something more than testenv.HasSrc would be needed.

¹ https://golang.org/cmd/go/#hdr-Environment_variables

Fixes #43085.

Change-Id: Ie6ade395a8fc7beebdadbad6f4873800138dfc26
Reviewed-on: https://go-review.googlesource.com/c/go/+/276452
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

4 years ago[dev.typeparams] cmd/compile/internal/types2: avoid endless recursion in Comparable...
Robert Griesemer [Wed, 9 Dec 2020 00:58:00 +0000 (16:58 -0800)]
[dev.typeparams] cmd/compile/internal/types2: avoid endless recursion in Comparable predicate

Use a map to detect recursive types.
With this we can now typecheck fixedbugs/issue8501.go.

Updates #43088.

Change-Id: I7fad6ccf6c94268473ff72b09a3158e13a7f4cc3
Reviewed-on: https://go-review.googlesource.com/c/go/+/276374
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile: fix message typo
Ikko Ashimine [Wed, 9 Dec 2020 14:17:56 +0000 (14:17 +0000)]
cmd/compile: fix message typo

occurences -> occurrences

Change-Id: Ia81671f5de8a24ddd303a77b4580e8c726f29122
GitHub-Last-Rev: 11f9ab9f8c2c9acd70bcf170930426547d9b63eb
GitHub-Pull-Request: golang/go#43097
Reviewed-on: https://go-review.googlesource.com/c/go/+/276612
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agonet/http: add connections back that haven't been canceled
Michael Fraenkel [Thu, 3 Dec 2020 00:07:27 +0000 (17:07 -0700)]
net/http: add connections back that haven't been canceled

Issue #41600 fixed the issue when a second request canceled a connection
while the first request was still in roundTrip.
This uncovered a second issue where a request was being canceled (in
roundtrip) but the connection was put back into the idle pool for a
subsequent request.
The fix is the similar except its now in readLoop instead of roundTrip.
A persistent connection is only added back if it successfully removed
the cancel function; otherwise we know the roundTrip has started
cancelRequest.

Fixes #42942

Change-Id: Ia56add20880ccd0c1ab812d380d8628e45f6f44c
Reviewed-on: https://go-review.googlesource.com/c/go/+/274973
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
4 years agoruntime: prevent stack growth after fork in runtime.sigfillset
Haoran Luo [Tue, 8 Dec 2020 14:29:04 +0000 (14:29 +0000)]
runtime: prevent stack growth after fork in runtime.sigfillset

This fixes the unexpected growth of stack in child process, which
is caused by stack checking code in runtime.sigfillset called from
runtime.sigset while clearing the signal handlers in child process.

The redundant stack checking code is generated due to missing
'//go:nosplit' directive that should be annotated for
runtime.sigfillset.

Fixes #43066
Updates #21314

Change-Id: I9483a962a4b0747074313991841e2440ee32198c
Reviewed-on: https://go-review.googlesource.com/c/go/+/276173
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agodoc: add description of new framepointer vet check
Keith Randall [Tue, 8 Dec 2020 22:35:41 +0000 (14:35 -0800)]
doc: add description of new framepointer vet check

Update #43014

Change-Id: I5fbfaa16e6acb8859fd0b1188f532f5a225f6349
Reviewed-on: https://go-review.googlesource.com/c/go/+/276373
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
4 years agocmd/vet: vendor in x/tools, enable framepointer vet check
Keith Randall [Tue, 8 Dec 2020 22:07:19 +0000 (14:07 -0800)]
cmd/vet: vendor in x/tools, enable framepointer vet check

Vendor in latest x/tools.
Add framepointer vet check to vet.

Fixes #43014

Change-Id: Ife72f85b1261aa60c0028041c58040d60a40918a
Reviewed-on: https://go-review.googlesource.com/c/go/+/276372
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years ago[dev.typeparams] go/*: add TODOs from CLs importing dev.go2go changes
Rob Findley [Tue, 8 Dec 2020 20:01:32 +0000 (15:01 -0500)]
[dev.typeparams] go/*: add TODOs from CLs importing dev.go2go changes

With the plurality of CLs importing dev.go2go changes it's getting hard
to track all of the code review comments that were deferred for later
consideration. Add some TODOs to capture these comments in the source,
so that they may be more easily located.

Change-Id: I5caf085fec11ca8992b7affe6feb0a7aa202f21f
Reviewed-on: https://go-review.googlesource.com/c/go/+/276254
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>
4 years agogo/types: correct error position for inherited const init expressions
Rob Findley [Tue, 8 Dec 2020 14:44:48 +0000 (09:44 -0500)]
go/types: correct error position for inherited const init expressions

This is a port of CL 275517 from the dev.typeparams branch, to fix the
positioning of error messages for invalid const init expressions that
are inherited.

Differences from CL 275517:
 + The inherited flag is added to the constDecl intermediate
   representation.
 + The errpos override is made a positioner, the internal interface
   used by go/types to capture error position and span. For const decls
   errpos is just set to a singular point, but using positioner is
   correct and causes span start and end positions to also be
   overridden.
 + Test cases are updated to assert on just 'overflows', as the go/types
   error message is, for example, "cannot use 255 + iota (untyped int
   constant 256) as byte value in constant declaration (overflows)".
   This is more verbose than the compiler's "constant 256 overflows
   byte", but changing that is out of scope.

Fixes #42991

Change-Id: I0a71d2290f7fff5513f2a6e49b83e6f0f4da30e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/276172
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years ago[dev.typeparams] go/types: import universe changes from dev.go2go
Rob Findley [Tue, 8 Dec 2020 16:53:26 +0000 (11:53 -0500)]
[dev.typeparams] go/types: import universe changes from dev.go2go

This is unmodified from the dev.go2go branch, except to remove the aType
embedding.

Change-Id: Id14d97a56d27ea609c43b453e8f9f1cf1a451406
Reviewed-on: https://go-review.googlesource.com/c/go/+/276252
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>
4 years agodoc/go1.16: improve channel race detector changes description
Austin Clements [Mon, 7 Dec 2020 02:20:15 +0000 (21:20 -0500)]
doc/go1.16: improve channel race detector changes description

Based on text from Daniel Fava.

For #40700.

Change-Id: I0bc3a4340b8a777ff96d3cf226a7d51d3f65db2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/275786
Trust: Austin Clements <austin@google.com>
Reviewed-by: Daniel Fava <danielsfava@gmail.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
4 years ago[dev.typeparams] go/types: import the Type API from dev.go2go
Rob Findley [Fri, 4 Dec 2020 17:39:38 +0000 (12:39 -0500)]
[dev.typeparams] go/types: import the Type API from dev.go2go

Import the Type changes from the dev.go2go branch, as well as a minimal
set of related changes to the Checker code so that tests pass. This
involved making some decisions about which functionality to import, with
some parts of the Type API (for example instance.expand) carved out as
they pulled in too many additional changes.

Minimal changes were made from the dev.go2go version. Notably:
 + The aType helper struct is removed. It could have been removed in CL
   274852 but was missed.
 + writeTParamList was cleaned up for the bracketed parameter style.
 + Some interface iteration functions were simplified.

One observation along the way is that, especially with converter methods
removed from the Type interface, we should probably avoid storing the
Checker on Type instances for lazy evaluation. If a function is only
valid during a checking pass, we should make it a method on Checker
instead of a method on the Type instance. Rather than do this now, which
would make later changes harder to import, I left a couple TODOs to
address this later.

Change-Id: Ie669224614269874474d87e46c68216cb06b6d0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/275441
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>

4 years ago[dev.regabi] cmd/compile: replace many uses of ir.Node with *ir.Name
Matthew Dempsky [Mon, 7 Dec 2020 02:28:49 +0000 (18:28 -0800)]
[dev.regabi] cmd/compile: replace many uses of ir.Node with *ir.Name

This commit adds exactly two "n := n.(*ir.Name)" statements, that are
each immediately preceded by a "case ir.ONAME:" clause in an n.Op()
switch. The rest of the changes are simply replacing "ir.Node" to
"*ir.Name" and removing now unnecessary "n.(*ir.Name)" type
assertions, exposing the latent typing details.

Passes buildall w/ toolstash -cmp.

Updates #42982.

Change-Id: I8ea3bbb7ddf0c7192245cafa49a19c0e7a556a39
Reviewed-on: https://go-review.googlesource.com/c/go/+/275791
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
4 years ago[dev.regabi] cmd/compile: ir.Node is no longer an ssa.Aux
Matthew Dempsky [Mon, 7 Dec 2020 02:25:41 +0000 (18:25 -0800)]
[dev.regabi] cmd/compile: ir.Node is no longer an ssa.Aux

After the previous rewrite, we can now remove CanBeAnSSASym and
CanBeAnSSAAux from the generic Node interface, and declare them just
on *ir.Name.

Updates #42982.

Change-Id: I865771fd30c95c009740410844f20ade08648343
Reviewed-on: https://go-review.googlesource.com/c/go/+/275790
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
4 years ago[dev.regabi] cmd/compile: rewrite Aux uses of ir.Node to *ir.Name [generated]
Matthew Dempsky [Mon, 7 Dec 2020 02:13:43 +0000 (18:13 -0800)]
[dev.regabi] cmd/compile: rewrite Aux uses of ir.Node to *ir.Name [generated]

Now that the only remaining ir.Node implementation that is stored
(directly) into ssa.Aux, we can rewrite all of the conversions between
ir.Node and ssa.Aux to use *ir.Name instead.

rf doesn't have a way to rewrite the type switch case clauses, so we
just use sed instead. There's only a handful, and they're the only
times that "case ir.Node" appears anyway.

The next CL will move the tag method declarations so that ir.Node no
longer implements ssa.Aux.

Passes buildall w/ toolstash -cmp.

Updates #42982.

[git-generate]
cd src/cmd/compile/internal
sed -i -e 's/case ir.Node/case *ir.Name/' gc/plive.go */ssa.go

cd ssa
rf '
ex . ../gc {
  import "cmd/compile/internal/ir"

  var v *Value
  v.Aux.(ir.Node) -> v.Aux.(*ir.Name)

  var n ir.Node
  var asAux func(Aux)
  strict n        # only match ir.Node-typed expressions; not *ir.Name
  implicit asAux  # match implicit assignments to ssa.Aux
  asAux(n)        -> n.(*ir.Name)
}
'

Change-Id: I3206ef5f12a7cfa37c5fecc67a1ca02ea4d52b32
Reviewed-on: https://go-review.googlesource.com/c/go/+/275789
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
4 years ago[dev.regabi] cmd/compile: introduce FwdRefAux for wrapping ir.Node as ssa.Aux
Matthew Dempsky [Mon, 7 Dec 2020 02:10:34 +0000 (18:10 -0800)]
[dev.regabi] cmd/compile: introduce FwdRefAux for wrapping ir.Node as ssa.Aux

OpFwdRef is the only SSA value that needs the ability to store an
arbitrary ir.Node in its Aux field. Every other SSA value always uses
an *ir.Name.

This CL introduces FwdRefAux, which wraps an ir.Node and implements
the ssa.Aux tag interface, so that a subsequent refactoring can change
ir.Node to not implement ssa.Aux.

Passes buildall w/ toolstash -cmp.

Updates #42982.

Change-Id: Id1475b28847579573cd376e82f28761d84cd1c23
Reviewed-on: https://go-review.googlesource.com/c/go/+/275788
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
4 years agoruntime: correct sigfwd on openbsd/mips64
Joel Sing [Mon, 7 Dec 2020 17:21:33 +0000 (04:21 +1100)]
runtime: correct sigfwd on openbsd/mips64

Position independent code expects that R25 (aka $t9) contains the address of the
called function. As such, use R25 when calling from sigfwd.

Change-Id: I66b2b9bfa1f1bb983c7385eb2eaa19d9cd87d9fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/275893
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years ago[dev.regabi] cmd/compile: change LocalSlot.N to *ir.Name
Matthew Dempsky [Sun, 6 Dec 2020 20:02:22 +0000 (12:02 -0800)]
[dev.regabi] cmd/compile: change LocalSlot.N to *ir.Name

This was already documented as always being an ONAME, so it just
needed a few type assertion changes.

Passes buildall w/ toolstash -cmp.

Updates #42982.

Change-Id: I61f4b6ebd57c43b41977f4b37b81fe94fb11a723
Reviewed-on: https://go-review.googlesource.com/c/go/+/275757
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>

4 years ago[dev.regabi] cmd/compile: add ssa.Aux tag interface for Value.Aux
Matthew Dempsky [Tue, 8 Dec 2020 01:15:44 +0000 (17:15 -0800)]
[dev.regabi] cmd/compile: add ssa.Aux tag interface for Value.Aux

It's currently hard to automate refactorings around the Value.Aux
field, because we don't have any static typing information for it.
Adding a tag interface will make subsequent CLs easier and safer.

Passes buildall w/ toolstash -cmp.

Updates #42982.

Change-Id: I41ae8e411a66bda3195a0957b60c2fe8a8002893
Reviewed-on: https://go-review.googlesource.com/c/go/+/275756
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>

4 years agodoc/go1.16: update linker stats
Austin Clements [Mon, 7 Dec 2020 22:15:06 +0000 (17:15 -0500)]
doc/go1.16: update linker stats

benchstat v2 comparison vs HEAD:

                    1.15.6                    1.16
                    sec/op       sec/op           vs base
LinkIstio-48        4.44 ± 1%   3.43 ± 1%  -22.79% (p=0.000 n=20)
LinkKubelet-48     10.89 ± 1%   8.42 ± 1%  -22.63% (p=0.000 n=20)
LinkDiscovery-48    1.43 ± 1%   1.06 ± 1%  -25.68% (p=0.000 n=20)
LinkIstio-4         4.50 ± 1%   3.52 ± 1%  -21.84% (p=0.000 n=20)
LinkKubelet-4      10.84 ± 2%   8.55 ± 1%  -21.09% (p=0.000 n=20)
LinkDiscovery-4     1.45 ± 2%   1.11 ± 2%  -23.81% (p=0.000 n=20)

                     1.15.6                      1.16
                  max-RSS-bytes  max-RSS-bytes         vs base
LinkIstio-48       1085Mi ± 1%    1006Mi ± 0%    -7.32% (p=0.000 n=20)
LinkKubelet-48     1.60Gi ± 5%    1.46Gi ± 1%    -8.57% (p=0.000 n=20)
LinkDiscovery-48    392Mi ± 1%     362Mi ± 2%    -7.71% (p=0.000 n=20)
LinkIstio-4        1022Mi ± 6%     958Mi ± 1%    -6.26% (p=0.000 n=20)
LinkKubelet-4      1.63Gi ± 2%    1.44Gi ± 0%   -11.44% (p=0.000 n=20)
LinkDiscovery-4     400Mi ± 0%     353Mi ± 1%   -11.83% (p=0.000 n=20)

                     1.15.6                    1.16
                   exe-bytes     exe-bytes           vs base
LinkIstio-48       97.7Mi ± 0%   93.4Mi ± 0%  -4.38% (p=0.000 n=20)
LinkKubelet-48      129Mi ± 0%    127Mi ± 0%  -1.17% (p=0.000 n=20)
LinkDiscovery-48   31.9Mi ± 0%   29.1Mi ± 0%  -8.67% (p=0.000 n=20)
LinkIstio-4        97.7Mi ± 0%   93.4Mi ± 0%  -4.38% (p=0.000 n=20)
LinkKubelet-4       129Mi ± 0%    127Mi ± 0%  -1.17% (p=0.000 n=20)
LinkDiscovery-4    31.9Mi ± 0%   29.1Mi ± 0%  -8.67% (p=0.000 n=20)

https://perf.golang.org/search?q=upload:20201207.6

For #40700.

Change-Id: I3f7b3e08db4fb7980d2472f15e5fc04503e95ea0
Reviewed-on: https://go-review.googlesource.com/c/go/+/275912
Trust: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoreflect: document multiple keys in struct tags
Ian Lance Taylor [Thu, 3 Dec 2020 02:25:19 +0000 (18:25 -0800)]
reflect: document multiple keys in struct tags

For #40281
Fixes #42959

Change-Id: Ibc4769fda1592a1373ec720ea30baf319c0a0136
Reviewed-on: https://go-review.googlesource.com/c/go/+/274448
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
4 years ago[dev.regabi] cmd/compile: fix comment
Keith Randall [Sun, 6 Dec 2020 01:24:48 +0000 (17:24 -0800)]
[dev.regabi] cmd/compile: fix comment

Russ, is this what you meant?

Change-Id: I27d2847811c6eabd94358e435eb3eb4bc8cfaa9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/275712
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
4 years agoio/fs: fix Sub method error text
Russ Cox [Mon, 7 Dec 2020 20:20:37 +0000 (15:20 -0500)]
io/fs: fix Sub method error text

Noticed in (and alternative to) CL 275520.

Change-Id: If6c107ee9928dd1910facd4dc66da7234cb91c39
Reviewed-on: https://go-review.googlesource.com/c/go/+/275879
Trust: Russ Cox <rsc@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years ago[dev.regabi] cmd/compile: export all Node fields [generated]
Russ Cox [Sun, 6 Dec 2020 20:36:58 +0000 (15:36 -0500)]
[dev.regabi] cmd/compile: export all Node fields [generated]

The plan was always to export them once we remove the getters
and setters, but do it a bit early, with _ suffixes as needed, so that
the reflection-based ir.Dump can access the fields.

Passes buildall w/ toolstash -cmp.

[git-generate]
cd src/cmd/compile/internal/ir
rf '
mv AddStringExpr.list AddStringExpr.List_
mv BlockStmt.list BlockStmt.List_
mv CallExpr.body CallExpr.Body_
mv CaseStmt.list CaseStmt.List_
mv CaseStmt.body CaseStmt.Body_
mv ClosureExpr.fn ClosureExpr.Func_
mv CompLitExpr.list CompLitExpr.List_
mv ForStmt.body ForStmt.Body_
mv Func.body Func.Body_
mv IfStmt.body IfStmt.Body_
mv InlinedCallExpr.body InlinedCallExpr.Body_
mv RangeStmt.body RangeStmt.Body_
mv SliceExpr.list SliceExpr.List_
mv SliceHeaderExpr.lenCap SliceHeaderExpr.LenCap_
mv TypeSwitchGuard.name TypeSwitchGuard.Name_
'
go generate

Change-Id: I06e65920cecbcc51bea2254f52fcd7d5c5d0dc90
Reviewed-on: https://go-review.googlesource.com/c/go/+/275784
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: prepare mknode for rename of Func.body
Russ Cox [Sun, 6 Dec 2020 20:49:58 +0000 (15:49 -0500)]
[dev.regabi] cmd/compile: prepare mknode for rename of Func.body

The next CL will rename Func.body to Func.Body_.
At some point in the future we will rename it to Func.Body.
Make the generator not get confused.

Passes buildall w/ toolstash -cmp.

Change-Id: Iee3f4915889a8287377bf3304d5b9250a909477e
Reviewed-on: https://go-review.googlesource.com/c/go/+/275783
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: rewrite stale format strings
Russ Cox [Sun, 6 Dec 2020 19:53:38 +0000 (14:53 -0500)]
[dev.regabi] cmd/compile: rewrite stale format strings

On ir.Node, ir.Nodes, and ir.Op, # is ignored, so %#v is %v.
On ir.Node, %S is the same as %v.

On types.Type, # is ignored, so %#L is %L, %#v is %v.
On types.Type, 0 is ignored, so %0S is %S.

Rewrite all these using go test cmd/compile -r, plus a
few multiline formats mentioning %0S on types updated by hand.

Now the formats used in the compiler match the documentation
for the format methods, a minor miracle.

Passes buildall w/ toolstash -cmp.

Change-Id: I3d4a3fae543145a68da13eede91166632c5b1ceb
Reviewed-on: https://go-review.googlesource.com/c/go/+/275782
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: simplify fmtmap
Russ Cox [Sun, 6 Dec 2020 19:33:06 +0000 (14:33 -0500)]
[dev.regabi] cmd/compile: simplify fmtmap

The format map is going to keep growing as we add more use of
concrete node types. Stop that by reporting all Node implementations
as Node.

Also, there's little point to reporting uses of %v, %p, %T, nor to reporting
formatting of basic types like int and []byte. Remove those too.
(Vet takes care of mistakes involving basic types now.)

Passes buildall w/ toolstash -cmp.

Change-Id: Ia9fb39b401c29bf0c76ffebaa24836c70acd773f
Reviewed-on: https://go-review.googlesource.com/c/go/+/275781
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: clean up and document formatting
Russ Cox [Sun, 6 Dec 2020 19:15:09 +0000 (14:15 -0500)]
[dev.regabi] cmd/compile: clean up and document formatting

Some cleanup left over from moving the Type and Sym formatting to types.
And then document what the type formats are, now that it's clear.

Passes buildall w/ toolstash -cmp.

Change-Id: I35cb8978f1627db1056cb8ab343ce6ba6c99afad
Reviewed-on: https://go-review.googlesource.com/c/go/+/275780
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: move Type, Sym printing to package types [generated]
Russ Cox [Sun, 6 Dec 2020 18:54:50 +0000 (13:54 -0500)]
[dev.regabi] cmd/compile: move Type, Sym printing to package types [generated]

Move the printing of types.Type and types.Sym out of ir
into package types, where it properly belongs. This wasn't
done originally (when the code was in gc) because the Type
and Sym printing was a bit tangled up with the Node printing.
But now they are untangled and can move into the correct
package.

This CL is automatically generated.
A followup CL will clean up a little bit more by hand.

Passes buildall w/ toolstash -cmp.

[git-generate]
cd src/cmd/compile/internal/ir
rf '
mv FmtMode fmtMode
mv FErr fmtGo
mv FDbg fmtDebug
mv FTypeId fmtTypeID
mv FTypeIdName fmtTypeIDName
mv methodSymName SymMethodName

mv BuiltinPkg LocalPkg BlankSym OrigSym NumImport \
fmtMode fmtGo symFormat sconv sconv2 symfmt SymMethodName \
BasicTypeNames fmtBufferPool InstallTypeFormats typeFormat tconv tconv2 fldconv FmtConst \
typefmt.go

mv typefmt.go cmd/compile/internal/types
'
cd ../types
mv typefmt.go fmt.go

Change-Id: I6f3fd818323733ab8446f00594937c1628760b27
Reviewed-on: https://go-review.googlesource.com/c/go/+/275779
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: untangle FmtFlag, FmtMode
Russ Cox [Sun, 6 Dec 2020 18:17:03 +0000 (13:17 -0500)]
[dev.regabi] cmd/compile: untangle FmtFlag, FmtMode

It turns out that the FmtFlag is really only tracking the FmtLong and FmtShort bits,
and the others simply mirror the state of the FmtMode and are copied out and
back in repeatedly.

Simplify to FmtFlag being the verb itself ('S', 'L', or 'v').

Now there is only one formatting enumeration, making it a bit
easier to understand what's going on.

Passes buildall w/ toolstash -cmp.

Change-Id: I85bde2183eb22228fcf46d19d003401d588d9825
Reviewed-on: https://go-review.googlesource.com/c/go/+/275778
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: remove mode.Sprintf etc in printer
Russ Cox [Sun, 6 Dec 2020 17:38:11 +0000 (12:38 -0500)]
[dev.regabi] cmd/compile: remove mode.Sprintf etc in printer

This code is now hardly used and not worth the complexity.
It also tangles together Nodes and Types in a way that keeps
this code in package ir instead of package types.

Passes buildall w/ toolstash -cmp.

Change-Id: I2e829c1f6b602acbdc8ab4aac3b798f9ded762ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/275777
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: narrow interface between ir and types
Russ Cox [Sat, 5 Dec 2020 20:20:51 +0000 (15:20 -0500)]
[dev.regabi] cmd/compile: narrow interface between ir and types

Narrow the interface between package ir and package types
to make it easier to clean up the type formatting code all in one place.

Also introduce ir.BlankSym for use by OrigSym, so that later
OrigSym can move to package types without needing to reference
a variable of type ir.Node.

Passes buildall w/ toolstash -cmp.

Change-Id: I39fa419a1c8fb3318203e31cacc8d06399deeff9
Reviewed-on: https://go-review.googlesource.com/c/go/+/275776
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: simplify Op, Node, Nodes printing
Russ Cox [Sat, 5 Dec 2020 19:46:19 +0000 (14:46 -0500)]
[dev.regabi] cmd/compile: simplify Op, Node, Nodes printing

nconvFmt calls base.Fatalf if mode is anything but FErr,
proving that the only formats that matter for nodes are
plain %v, %S, and %L. And the nodes formatter can only get to %v.
(%S and %v are the same; we'll clean that up separately.)

Node and Nodes can therefore ignore mode, and all the mode
code can be removed from those implementations, removing
quite a few layers of abstraction.

Op similarly only runs in one mode and can be simplified.

Passes buildall w/ toolstash -cmp.

Change-Id: Ibfd845033e9c68181a20fb81c8f3dd428463920a
Reviewed-on: https://go-review.googlesource.com/c/go/+/275775
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: untangle ir.Dump printing
Russ Cox [Sat, 5 Dec 2020 05:02:46 +0000 (00:02 -0500)]
[dev.regabi] cmd/compile: untangle ir.Dump printing

The Node printing code is tangled up due to the multiple printing modes.
Split out the Dump mode into its own code, which clarifies it considerably.
We are going to have to change the code for the new Node representations,
so it is nice to have it in an understandable form first.

The output of Dump is unchanged except for the removal of spurious
mid-Dump blank lines that have been printed for a while but don't
really make sense and appear to be a bug.

The %+v verb on Op prints the name ("ADD" not "+"), matching
%+v on Node and %+v on Nodes to get Dump and DumpList formats.

Passes buildall w/ toolstash -cmp.

Change-Id: I07f0f245859f1f785e10bdd671855ca43c51b545
Reviewed-on: https://go-review.googlesource.com/c/go/+/275774
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: reorganize ir/fmt.go
Russ Cox [Sat, 5 Dec 2020 05:02:46 +0000 (00:02 -0500)]
[dev.regabi] cmd/compile: reorganize ir/fmt.go

This code is a few layer of abstraction stacked up on top
of each other, and they're hard to see all at the same time
because the file is pretty mixed up. As much as I try to avoid
code rearrangement to keep history, this one is long overdue.

A followup CL will cut out some of the layers, and the diff will be
much clearer what's going on with the code ordered with
callers near callees, as it is now.

Passes buildall w/ toolstash -cmp.

Change-Id: Iffc49d43cf4be9fab47e2dd59a5f98930573350f
Reviewed-on: https://go-review.googlesource.com/c/go/+/275773
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: remove "short" node header mode
Russ Cox [Fri, 4 Dec 2020 23:40:24 +0000 (18:40 -0500)]
[dev.regabi] cmd/compile: remove "short" node header mode

This is unreachable code - the only way short can be true is
if verb == 'S', but jconv is only called when verb == 'j'.
Simplify by removing.

Passes buildall w/ toolstash -cmp.

Change-Id: I27bd38319f72215069e940b320b5c82608e2651a
Reviewed-on: https://go-review.googlesource.com/c/go/+/275772
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: arrange for typecheck1 to end in switch
Russ Cox [Fri, 4 Dec 2020 16:37:54 +0000 (11:37 -0500)]
[dev.regabi] cmd/compile: arrange for typecheck1 to end in switch

Ending typecheck1 in the switch makes it safe for each case
to do an appropriate type assertion. The main change is dropping
the computation of "ok" and using the syntax nodes themselves
to decide what's OK.

Passes buildall w/ toolstash -cmp.

Change-Id: I2a1873a51e3f1194d74bb87a6653cb9857a02a1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/275444
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] test: add exhaustive test of evaluated but not used
Russ Cox [Fri, 4 Dec 2020 17:40:39 +0000 (12:40 -0500)]
[dev.regabi] test: add exhaustive test of evaluated but not used

Change-Id: I49db03c88b7595f1ea593df568244ad6aad3b024
Reviewed-on: https://go-review.googlesource.com/c/go/+/275443
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: generate Node methods using program
Russ Cox [Fri, 4 Dec 2020 15:17:50 +0000 (10:17 -0500)]
[dev.regabi] cmd/compile: generate Node methods using program

Add Node method generator by Matthew Dempsky,
lightly adapted to account for a few special cases.
No more writing these by hand.

Change-Id: I6933b895df666928b851bddf81b994799c0c97f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/275434
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agoruntime/cgo: fix building on musl
Tonis Tiigi [Sun, 6 Dec 2020 20:13:47 +0000 (20:13 +0000)]
runtime/cgo: fix building on musl

sys/unistd.h only exists in glibc and not in musl so use the standard
location. This is a regression from CL 210639

Change-Id: Idd4c75510d9829316b44300c36c34df6d667cc05
GitHub-Last-Rev: 0fa4162f1c7c460bda7585300285f47d1781985d
GitHub-Pull-Request: golang/go#43038
Reviewed-on: https://go-review.googlesource.com/c/go/+/275732
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Andrew G. Morgan <agm@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>

4 years agodoc/go1.16: announce openbsd/mips64 port
Austin Clements [Mon, 7 Dec 2020 02:28:36 +0000 (21:28 -0500)]
doc/go1.16: announce openbsd/mips64 port

Updates #40995.
For #40700.

Change-Id: I4dced8d70e2f1fa2da98e2eb1a5f1f829f55bb6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/275787
Trust: Austin Clements <austin@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
4 years agotest: add new test that gofrontend failed to handle
Ian Lance Taylor [Sat, 5 Dec 2020 16:08:47 +0000 (08:08 -0800)]
test: add new test that gofrontend failed to handle

The gofrontend code would in some circumstances incorrectly generate a
type descriptor for an alias type, causing the type to fail to be
equal to the unaliased type.

Change-Id: I47d33b0bfde3c72a9a186049539732bdd5a6a96e
Reviewed-on: https://go-review.googlesource.com/c/go/+/275632
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agodoc/go1.16: fix typo
Alberto Donizetti [Mon, 7 Dec 2020 17:10:56 +0000 (18:10 +0100)]
doc/go1.16: fix typo

For #40700

Change-Id: Idea442d45d18ca8cedc0b160df23eac6b86755ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/275677
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
4 years ago[dev.typeparams] cmd/compile/internal/types2: correct error position for inherited...
Robert Griesemer [Fri, 4 Dec 2020 21:20:06 +0000 (13:20 -0800)]
[dev.typeparams] cmd/compile/internal/types2: correct error position for inherited const init expression

Enabled fixedbugs/issue8183.go for run.go with new typechecker
now that issue is fixed.

Fixes #42992.
Updates #42991.

Change-Id: I23451999983b740d5f37ce3fa75ee756daf1a44f
Reviewed-on: https://go-review.googlesource.com/c/go/+/275517
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agodoc/go1.16: add missing </a> tag
Tobias Klauser [Mon, 7 Dec 2020 10:33:00 +0000 (11:33 +0100)]
doc/go1.16: add missing </a> tag

For #40700

Change-Id: Ic4e16106cbbe18d0c9efffee81c5234ddeedfd32
Reviewed-on: https://go-review.googlesource.com/c/go/+/275674
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
4 years agointernal/cpu: add darwin/arm64 CPU feature detection support
Martin Möhrmann [Sat, 21 Nov 2020 16:44:04 +0000 (17:44 +0100)]
internal/cpu: add darwin/arm64 CPU feature detection support

Fixes #42747

Change-Id: I6b1679348c77161f075f0678818bb003fc0e8c86
Reviewed-on: https://go-review.googlesource.com/c/go/+/271989
Trust: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years ago[dev.regabi] cmd/compile: silence errors about missing blank methods
Matthew Dempsky [Thu, 3 Dec 2020 22:00:19 +0000 (14:00 -0800)]
[dev.regabi] cmd/compile: silence errors about missing blank methods

If an interface contains a blank method, that's already an error. No
need for useless follow-up error messages about not implementing them.

Fixes #42964.

Change-Id: I5bf53a8f27d75d4c86c61588c5e2e3e95563d320
Reviewed-on: https://go-review.googlesource.com/c/go/+/275294
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agodoc/go1.16: document riscv64 port changes
Tobias Klauser [Thu, 3 Dec 2020 10:27:05 +0000 (11:27 +0100)]
doc/go1.16: document riscv64 port changes

For #36641
For #40700

Change-Id: Ib268559a2ce7839372dbf273d95876d8d4521a45
Reviewed-on: https://go-review.googlesource.com/c/go/+/274478
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years ago[dev.regabi] cmd/compile: change iexport to avoid map[ir.Node]
Matthew Dempsky [Sun, 6 Dec 2020 20:14:46 +0000 (12:14 -0800)]
[dev.regabi] cmd/compile: change iexport to avoid map[ir.Node]

In the past, we had a lot of trouble with misusing *types.Sym
throughout the frontend, so I tried to push us towards always passing
around ONAMEs instead. But for constructing and writing out the symbol
indexes for the indexed export data, keying by *types.Sym is exactly
what we want.

Passes buildall w/ toolstash -cmp.

Updates #42982.

Change-Id: Idd8f1fb057d75a52a34ebc7788d9332fb49caf8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/275755
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
4 years ago[dev.regabi] cmd/compile: change nowritebarrierrec to use map[*ir.Func]
Matthew Dempsky [Sun, 6 Dec 2020 00:33:59 +0000 (16:33 -0800)]
[dev.regabi] cmd/compile: change nowritebarrierrec to use map[*ir.Func]

All of the uses were already using *ir.Func index operands, so only
needs the map type itself updated.

Passes buildall w/ toolstash -cmp.

Updates #42982.

Change-Id: I568d8601f3eb077e07e887f2071aa1a2667d803c
Reviewed-on: https://go-review.googlesource.com/c/go/+/275754
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

4 years ago[dev.regabi] cmd/compile: replace NodeQueue with NameQueue
Matthew Dempsky [Sun, 6 Dec 2020 20:29:42 +0000 (12:29 -0800)]
[dev.regabi] cmd/compile: replace NodeQueue with NameQueue

Similar to the previous CL, the only two users of NodeQueue only
needed it for tracking objects, not arbitrary AST nodes. So change
it's signature to use *Name instead of Node.

This does require a tweak to the nowritebarrierrec checker, because
previously it was pushing the ODCLFUNC *Func pointers into the queue,
whereas now we push the ONAME/PFUNC *Name pointers instead. However,
it's trivial and safe to flip between them.

Also, this changes a handful of export-related code from Node to
*Name, to avoid introducing type assertions within iexport.go.

Passes buildall w/ toolstash -cmp.

Updates #42982.

Change-Id: I867f9752121509fc3da753978c6a41d5015bc0ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/275753
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years ago[dev.regabi] cmd/compile: change NodeSet to NameSet
Matthew Dempsky [Sat, 5 Dec 2020 23:49:03 +0000 (15:49 -0800)]
[dev.regabi] cmd/compile: change NodeSet to NameSet

The only user of NodeSet (computing initialization dependencies) only
needs to store *Names in this structure. So change its definition to
match that need, and update the code in initorder.go accordingly.

Passes buildall w/ toolstash -cmp.

Updates #42982.

Change-Id: I181a8aaf9bc71e88f4ac009c4f381a718080e48f
Reviewed-on: https://go-review.googlesource.com/c/go/+/275752
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agointernal/cpu: fix typo in cpu_arm64.go
Ikko Ashimine [Sat, 5 Dec 2020 14:43:53 +0000 (14:43 +0000)]
internal/cpu: fix typo in cpu_arm64.go

auxillary -> auxiliary

Change-Id: I7c29c4a63d236c3688b8e4f5af70650d43cd89c0
GitHub-Last-Rev: d4a18c71a15cf0803bd847225ed5bf898c52e0f3
GitHub-Pull-Request: golang/go#43024
Reviewed-on: https://go-review.googlesource.com/c/go/+/275592
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Keith Randall <khr@golang.org>

4 years agosyscall: correct CertOpenStore to expect a 0 return value on failure
Jason A. Donenfeld [Sun, 29 Nov 2020 12:33:37 +0000 (13:33 +0100)]
syscall: correct CertOpenStore to expect a 0 return value on failure

According to [1], this function returns NULL when it errors, rather than
INVALID_HANDLE_VALUE, which other Win32 functions return. This was
pointed out in CL 273446 for the x/sys package, and this patch here
cleans it up for the syscall package and updates the vendored x/sys
package using the usual `go get/go mod vendor` dance. The function is
currently in use by crypto/x509/root_windows.go, which calls
CertOpenStore(CERT_STORE_PROV_MEMORY), which I assume can fail under OOM
or other weird conditions. Quick reversing indicates that [1] is
correct, as there's a `xor eax, eax` in the error paths of the function
just before jumping to the epilogue.

[1] https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-certopenstore#return-value

Change-Id: I77c0b0319c13313212f8710785252c494da56ed5
Reviewed-on: https://go-review.googlesource.com/c/go/+/273827
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>

4 years agodoc/go1.16: cleanup crypto release notes
Filippo Valsorda [Fri, 4 Dec 2020 00:46:59 +0000 (01:46 +0100)]
doc/go1.16: cleanup crypto release notes

For #40700
Fixes #42897

Change-Id: Id3b87841a899818d6939dcc3edbaaa0bc183e913
Reviewed-on: https://go-review.googlesource.com/c/go/+/275313
Trust: Filippo Valsorda <filippo@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
4 years agocmd/vendor: sync pprof@v0.0.0-20201203190320-1bf35d6f28c2
zikaeroh [Fri, 4 Dec 2020 20:20:17 +0000 (12:20 -0800)]
cmd/vendor: sync pprof@v0.0.0-20201203190320-1bf35d6f28c2

Pulls in a fix to make versioned import paths more readable in pprof's
graph view.

Updated via the instructions in README.vendor.

Updates #36905

Change-Id: I6a91de0f4ca1be3fc69d8e1a39ccf4f5bd0387ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/275513
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years ago[dev.typeparams] test: enable some more errorcheck tests
Robert Griesemer [Fri, 4 Dec 2020 02:15:50 +0000 (18:15 -0800)]
[dev.typeparams] test: enable some more errorcheck tests

Change-Id: I103e3eeacd5b11efd63c965482a626878ba5ac81
Reviewed-on: https://go-review.googlesource.com/c/go/+/275216
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years ago[dev.regabi] cmd/compile: replace ir.Node with *ir.Name in Order
Cuong Manh Le [Fri, 4 Dec 2020 04:38:47 +0000 (11:38 +0700)]
[dev.regabi] cmd/compile: replace ir.Node with *ir.Name in Order

Passes buildall w/ toolstash -cmp.

Updates #42982

Change-Id: I7121c37f72ccbc141a7dd17fba1753f2c6289908
Reviewed-on: https://go-review.googlesource.com/c/go/+/275353
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>
4 years ago[dev.regabi] cmd/compile: replace ir.Node with *ir.Name in Liveness
Cuong Manh Le [Fri, 4 Dec 2020 04:07:25 +0000 (11:07 +0700)]
[dev.regabi] cmd/compile: replace ir.Node with *ir.Name in Liveness

Passes buildall w/ toolstash -cmp.

Updates #42982

Change-Id: Iad8df321adfd576da070c13ed16a9651d4e59ad8
Reviewed-on: https://go-review.googlesource.com/c/go/+/275352
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>
4 years ago[dev.regabi] cmd/compile: rewrite code to use DeclaredBy
Matthew Dempsky [Fri, 4 Dec 2020 00:57:56 +0000 (16:57 -0800)]
[dev.regabi] cmd/compile: rewrite code to use DeclaredBy

Passes buildall w/ toolstash -cmp.

Updates #42990.

[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex {
  import "cmd/compile/internal/ir"
  var x, stmt ir.Node
  x.Name() != nil && x.Name().Defn == stmt ->  ir.DeclaredBy(x, stmt)
  x.Name() == nil || x.Name().Defn != stmt -> !ir.DeclaredBy(x, stmt)
}
'

Change-Id: I222a757296dbcb5d0889d617d221a9d7319f2d74
Reviewed-on: https://go-review.googlesource.com/c/go/+/275306
Reviewed-by: Russ Cox <rsc@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>

4 years ago[dev.regabi] cmd/compile: add SameSource, Uses, and DeclaredBy helpers
Matthew Dempsky [Fri, 4 Dec 2020 00:52:45 +0000 (16:52 -0800)]
[dev.regabi] cmd/compile: add SameSource, Uses, and DeclaredBy helpers

Currently, because we use the same *Name to represent both declaration
and uses of an object, it's ambiguous what "n1 == n2" means when
comparing two Node values. It can mean any of: Are these the same
syntactic element? Is n1 a use of declared variable n2? Are n1 and n2
both uses of the same declared variable?

We'd like to introduce a new IdentExpr node to replace use of Name
within the AST, but that means those three cases need to be handled
differently. The first case needs to stay "n1 == n2", but the other
cases need to become "n1.Name() == n2" and "n1.Name() == n2.Name()",
respectively. ("n1.Name() == n2.Name()" also currently works for the
second case, but eventually we'll want to get rid of the Name.Name
method.)

This CL introduces helper functions SameSource and Uses to handle
these cases. It also introduces DeclaredBy, which is another somewhat
common case that the next CL introduces uses of.

Passes buildall w/ toolstash -cmp.

Updates #42990.

Change-Id: Ia816c124446e9067645d5820a8163f295968794f
Reviewed-on: https://go-review.googlesource.com/c/go/+/275305
Reviewed-by: Russ Cox <rsc@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>

4 years agodoc/go1.16: document no language changes
Dmitri Shuralyov [Thu, 3 Dec 2020 17:07:52 +0000 (17:07 +0000)]
doc/go1.16: document no language changes

There are no language changes in Go 1.16, so document that.

For #40700.
Fixes #42976.

Change-Id: I80b0d2ce6cf550c00c0f026ee59ac9fbce6310be
Reviewed-on: https://go-review.googlesource.com/c/go/+/275117
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years ago[dev.regabi] cmd/compile: remove DeepCopyNode interface
Russ Cox [Fri, 4 Dec 2020 05:30:53 +0000 (00:30 -0500)]
[dev.regabi] cmd/compile: remove DeepCopyNode interface

The only reason for the DeepCopyNode interface was to
allow the type syntaxes to avoid being constrained by
Left, Right etc. methods. Now those are gone, so the
general traversal methods they implement (doChildren, editChildren)
do the right thing for DeepCopy.

Passes buildall w/ toolstash -cmp.

Change-Id: I54672c011114a95efabff32dbcf02e6071f91b9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/275379
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: avoid general traversal in deadcode
Russ Cox [Fri, 4 Dec 2020 04:56:16 +0000 (23:56 -0500)]
[dev.regabi] cmd/compile: avoid general traversal in deadcode

deadcode is trying to walk the statements it can find,
but it can sweep in other nodes too. Stop doing that:
only walk known statements containing statements.

Otherwise, if we put panics in expression accessors that
shouldn't be used anymore, deadcode can trip them.

deadcode would be a good candidate to rewrite using
EditChildren, but that would certainly cause toolstash
changes, since deadcode is so ad-hoc about exactly
which parts of the function it looks at. For now just
remove the general traversal and leave as is.

Passes buildall w/ toolstash -cmp.

Change-Id: I06481eb87350905597600203c4fa724d55645b46
Reviewed-on: https://go-review.googlesource.com/c/go/+/275377
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: implement editChildren for nodes
Russ Cox [Fri, 4 Dec 2020 02:29:23 +0000 (21:29 -0500)]
[dev.regabi] cmd/compile: implement editChildren for nodes

Put each node in charge of its EditChildren implementation.
This removes the final generic use of Left, SetLeft, Right, SetRight,
and so on in package ir.

Passes buildall w/ toolstash -cmp.

Change-Id: I9821cc20f5b91cc9b44eb1f386cc82f20cd6770c
Reviewed-on: https://go-review.googlesource.com/c/go/+/275376
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: implement doChildren for nodes
Russ Cox [Fri, 4 Dec 2020 02:02:19 +0000 (21:02 -0500)]
[dev.regabi] cmd/compile: implement doChildren for nodes

Put each node in charge of its DoChildren implementation.
This removes a generic use of Left, Right, and so on
in func DoChildren, heading toward removing those even from
being used in package ir.

Passes buildall w/ toolstash -cmp.

Change-Id: Ibdf56f36801217cf24549e063da0078c1820a56b
Reviewed-on: https://go-review.googlesource.com/c/go/+/275375
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: implement copy for nodes
Russ Cox [Thu, 3 Dec 2020 23:43:18 +0000 (18:43 -0500)]
[dev.regabi] cmd/compile: implement copy for nodes

Put each node in charge of making copies of its own slices.
This removes a generic use of Body, SetBody, and so on
in func Copy, heading toward removing those even from
being used in package ir.

Passes buildall w/ toolstash -cmp.

Change-Id: I249b7fe54cf72e9d2f0467b10f3f257abf9b29b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/275374
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: use ir.EditChildren for inline rewriting
Russ Cox [Thu, 3 Dec 2020 19:06:41 +0000 (14:06 -0500)]
[dev.regabi] cmd/compile: use ir.EditChildren for inline rewriting

This CL rephrases the general inlining rewriter in terms of ir.EditChildren.
It is the final part of the code that was processing arbitrary nodes using
Left, SetLeft, and so on. After this CL, there should be none left except
for the implementations of DoChildren and EditChildren, which fall next.

Passes buildall w/ toolstash -cmp.

Change-Id: I9c36053360cd040710716f0b39397a80114be713
Reviewed-on: https://go-review.googlesource.com/c/go/+/275373
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: use ir.Find for "search" traversals
Russ Cox [Thu, 3 Dec 2020 01:18:47 +0000 (20:18 -0500)]
[dev.regabi] cmd/compile: use ir.Find for "search" traversals

This CL converts all the generic searching traversal to use ir.Find
instead of relying on direct access to Left, Right, and so on.

Passes buildall w/ toolstash -cmp.

Change-Id: I4d951aef630c00bf333f24be79565cc564694d04
Reviewed-on: https://go-review.googlesource.com/c/go/+/275372
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: introduce IR visitors
Russ Cox [Thu, 3 Dec 2020 17:57:38 +0000 (12:57 -0500)]
[dev.regabi] cmd/compile: introduce IR visitors

This CL introduces the general visitor functionality that will replace
the Left, SetLeft, Right, SetRight, etc methods in the Node interface.

For now, the CL defines the functionality in terms of those methods,
but eventually the Nodes themselves will implement DoChildren
and EditChildren and be relieved of implementing Left, SetLeft, and so on.

The CL also updates Inspect (which moved to visit.go) and DeepCopy
to use the new functionality.

The Find helper is not used in this CL but will be used in a future one.

Passes buildall w/ toolstash -cmp.

Change-Id: Id0eea654a884ab3ea25f48bd8bdd71712b5dcb44
Reviewed-on: https://go-review.googlesource.com/c/go/+/275311
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: replace inlcopy with ir.DeepCopy
Russ Cox [Thu, 3 Dec 2020 03:54:33 +0000 (22:54 -0500)]
[dev.regabi] cmd/compile: replace inlcopy with ir.DeepCopy

Now inlcopy and ir.DeepCopy are semantically the same,
so drop the inlcopy implementation.

Passes buildall w/ toolstash -cmp.

Change-Id: Id2abb39a412a8e57167a29be5ecf76e990dc9d3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/275310
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.regabi] cmd/compile: adjustments to Copy and DeepCopy
Russ Cox [Thu, 3 Dec 2020 03:42:24 +0000 (22:42 -0500)]
[dev.regabi] cmd/compile: adjustments to Copy and DeepCopy

DeepCopy is not called DeepSepCopy, so it should use Copy, not SepCopy.

Also, the old gc.treecopy, which became ir.DeepCopy, only copied
the Left, Right, and List fields - not Init, Rlist, Body - and I didn't
notice when I moved it over. A general utility function should of
course copy the whole node, so do that.

Finally, the semantics of Copy should not depend on whether a
particular child node is held directly in a field or in a slice,
so make Copy duplicate the slice backing arrays as well.
(Logically, those backing arrays are part of the node storage.)

Passes buildall w/ toolstash -cmp.

Change-Id: I18fbe3f2b40078f566ed6370684d5585052b36a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/275309
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>