1
0
mirror of https://github.com/golang/go synced 2024-11-17 09:54:46 -07:00
Commit Graph

46129 Commits

Author SHA1 Message Date
Keith Randall
178c667db2 [dev.regabi] cmd/compile: fix OSLICEARR comments
Change-Id: Ia6e734977a2cd80c91c28f4525be403f062dccc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/280651
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-30 16:37:51 +00:00
Keith Randall
f0d99def5b [dev.regabi] cmd/compile: add newline to ir.Dump
If you do two ir.Dumps in a row, there's no newline between them.

Change-Id: I1a80dd22da68cb677eb9abd7a50571ea33584010
Reviewed-on: https://go-review.googlesource.com/c/go/+/280672
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-30 16:37:09 +00:00
Matthew Dempsky
451693af71 [dev.regabi] cmd/compile: simplify typecheckdef
Reorganize code to be a little clearer. Also allows tightening
typecheckdefstack from []ir.Node to []*ir.Name.

Passes toolstash -cmp.

Change-Id: I43df1a5e2a72dd3423b132d3afe363bf76700269
Reviewed-on: https://go-review.googlesource.com/c/go/+/280649
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>
2020-12-30 05:00:09 +00:00
Matthew Dempsky
0c1a899a6c [dev.regabi] cmd/compile: fix defined-pointer method call check
The compiler has logic to check whether we implicitly dereferenced a
defined pointer while trying to select a method. However, rather than
checking whether there were any implicit dereferences of a defined
pointer, it was finding the innermost dereference/selector expression
and checking whether that was dereferencing a named pointer. Moreover,
it was only checking defined pointer declared in the package block.

This CL restructures the code to match go/types and gccgo's behavior.

Fixes #43384.

Change-Id: I7bddfe2515776d9480eb2c7286023d4c15423888
Reviewed-on: https://go-review.googlesource.com/c/go/+/280392
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
2020-12-30 04:38:20 +00:00
Matthew Dempsky
f9b67f76a5 [dev.regabi] cmd/compile: change ir.DoChildren to use bool result type
After using the IR visitor code for a bit, it seems clear that a
simple boolean result type is adequate for tree traversals. This CL
updates ir.DoChildren to use the same calling convention as ir.Any,
and updates mknode.go to generate code accordingly.

There were only two places where the error-based DoChildren API was
used within the compiler:

1. Within typechecking, marking statements that contain "break". This
code never returns errors anyway, so it's trivially updated to return
false instead.

2. Within inlining, the "hairy visitor" actually does make use of
returning errors. However, it threads through a reference to the
hairyVisitor anyway, where it would be trivial to store any needed
information instead. For the purpose of this CL, we provide
"errChildren" and "errList" helper functions that provide the previous
error-based semantics on top of the new bool-based API.

Passes toolstash -cmp.

Change-Id: I4bac9a697b4dbfb5f66eeac37d4a2ced2073d7d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/280675
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>
2020-12-30 04:24:02 +00:00
Matthew Dempsky
499851bac8 [dev.regabi] cmd/compile: generalize ir/mknode.go
This CL generalizes ir/mknode.go to get rid of most of almost all of
its special cases for node field types. The only remaining speciale
case now is Field, which doesn't implement Node any more, but perhaps
should.

To help with removing special cases, node fields can now be tagged
with `mknode:"-"` so that mknode ignores them when generating its
helper methods. Further, to simplify skipping all of the orig fields,
a new origNode helper type is added which declares an orig field
marked as `mknode:"-"` and also provides the Orig and SetOrig methods
needed to implement the OrigNode interface.

Passes toolstash -cmp.

Change-Id: Ic68d4f0a9d2ef6e57e9fe87cdc641e5c4859830b
Reviewed-on: https://go-review.googlesource.com/c/go/+/280674
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>
2020-12-30 03:38:02 +00:00
Cuong Manh Le
82ab3d1448 [dev.regabi] cmd/compile: use *ir.Name for Decl.X
Passes toolstash -cmp.

Change-Id: I505577d067eda3512f6d78618fc0eff061a71e3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/280732
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>
2020-12-30 00:48:19 +00:00
Cuong Manh Le
9958b7ed3e [dev.regabi] cmd/compile: unexport ir.FmtNode
It's only used inside package ir now.

[git-generate]

cd src/cmd/compile/internal/ir
rf 'mv FmtNode fmtNode'
sed -i 's/FmtNode/fmtNode/g' mknode.go
go generate

Change-Id: Ib8f6c6984905a4d4cfca1b23972a39c5ea30ff42
Reviewed-on: https://go-review.googlesource.com/c/go/+/279451
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>
2020-12-30 00:48:01 +00:00
Cuong Manh Le
f5816624cd [dev.regabi] cmd/compile: change AddrExpr.Alloc to AddrExpr.Prealloc
For being consistent with other Prealloc fields.

[git-generate]

cd src/cmd/compile/internal/ir
rf '
  mv AddrExpr.Alloc AddrExpr.Prealloc
'
go generate

Change-Id: Id1b05119092036e3f8208b73b63bd0ca6ceb7b15
Reviewed-on: https://go-review.googlesource.com/c/go/+/279450
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-29 19:37:00 +00:00
Cuong Manh Le
850aa7c60c [dev.regabi] cmd/compile: use *ir.Name instead of ir.Node for CaseClause.Var
Passes toolstash -cmp.

Change-Id: Ib0b6ebf5751ffce2c9500dc67d78e54937ead208
Reviewed-on: https://go-review.googlesource.com/c/go/+/279449
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>
2020-12-29 19:21:18 +00:00
Cuong Manh Le
37babc97bb [dev.regabi] cmd/compile: allow visitor visits *ir.Name
So future CLs can refactor ir.Node to *ir.Name when possible.

Passes toolstash -cmp.

Change-Id: I91ae38417ba10de207ed84b65d1d69cf64f24456
Reviewed-on: https://go-review.googlesource.com/c/go/+/279448
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>
2020-12-29 19:21:07 +00:00
Cuong Manh Le
5cf3c87fa6 [dev.regabi] cmd/compile: generate case/comm clause functions in mknode.go
Passes toolstash -cmp.

Change-Id: I52e9d6f35f22d5d59ac6aad02011c5abaac45739
Reviewed-on: https://go-review.googlesource.com/c/go/+/279446
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>
2020-12-29 18:29:47 +00:00
Keith Randall
b3e1ec97fd [dev.regabi] cmd/compile: move new addrtaken bit back to the old name
Change-Id: I2732aefe95a21c23d73a907d5596fcb1626d6dd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/275697
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2020-12-29 18:05:07 +00:00
Keith Randall
0620c674dd [dev.regabi] cmd/compile: remove original addrtaken bit
Switch the source of truth to the new addrtaken bit. Remove the old one.

Change-Id: Ie53679ab14cfcd34b55e912e7ecb962a22db7db3
Reviewed-on: https://go-review.googlesource.com/c/go/+/275696
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2020-12-29 18:04:37 +00:00
Keith Randall
0523d525ae [dev.regabi] cmd/compile: separate out address taken computation from typechecker
This CL computes a second parallel addrtaken bit that we check
against the old way of doing it. A subsequent CL will rip out the
typechecker code and just use the new way.

Change-Id: I62b7342c44f694144844695386f80088bbd40bf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/275695
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2020-12-29 18:04:10 +00:00
Matthew Dempsky
9ea272e5ec [dev.regabi] cmd/compile: simplify ir.Func somewhat
Two simplifications:

1. Statements (including ODCLFUNC) don't have types, and the
Func.Nname already has a type. There's no need for a second one.
However, there is a lot of code that expects to be able to call
Func.Type, so leave a forwarding method, like with Sym and Linksym.

2. Inline and remove ir.NewFuncNameAt. It doesn't really save any
code, and it's only used a handful of places.

Passes toolstash -cmp.

Change-Id: I51acaa341897dae0fcdf2fa576a10174a2ae4d1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/280648
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>
2020-12-29 11:54:34 +00:00
Matthew Dempsky
e40cb4d4ae [dev.regabi] cmd/compile: remove more unused code
Change-Id: I60ac28e3ab376cb0dac23a9b4f481f8562ad8c56
Reviewed-on: https://go-review.googlesource.com/c/go/+/280647
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-12-29 11:54:25 +00:00
Matthew Dempsky
6f30c95048 [dev.regabi] cmd/compile: remove unneeded indirection
Thanks to package reorganizing, we can remove types.TypeLinkSym by
simply having its only callers use reflectdata.TypeLinksym directly.

Passes toolstash -cmp.

Change-Id: I5bc5dbb6bf0664af43ae5130cfe1f19bd23b2bfe
Reviewed-on: https://go-review.googlesource.com/c/go/+/280644
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>
2020-12-29 09:57:31 +00:00
Matthew Dempsky
171fc6f223 [dev.regabi] cmd/compile: remove workarounds for go/constant issues
These were fixed in CLs 273086 and 273126, which have been merged back
into dev.regabi already.

Passes toolstash -cmp.

Change-Id: I011e9ed7062bc034496a279e21cc163267bf83fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/280643
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>
2020-12-29 09:12:55 +00:00
Matthew Dempsky
33801cdc62 [dev.regabi] cmd/compile: use Ntype where possible
For nodes that are always a type expression, we can use Ntype instead
of Node.

Passes toolstash -cmp.

Change-Id: I28f9fa235015ab48d0da06b78b30c49d74c64e3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/280642
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>
2020-12-29 08:22:45 +00:00
Cuong Manh Le
82ad3083f8 [dev.regabi] cmd/compile: remove typ from AssignOpStmt
Previous detached logic of typechecking AssignOpStmt from tcArith, the
typ field of it is not used anymore.

Pass toolstash -cmp.

Change-Id: I407507a1c4c4f2958fca4d6899875564e54bf1f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/279443
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>
2020-12-29 07:56:08 +00:00
Cuong Manh Le
e34c44a7c4 [dev.regabi] cmd/compile: refactoring typecheck arith
Currently, the tcArith logic is complicated and involes many
un-necessary checks for some ir.Op. This CL refactors how it works:

 - Add a new tcShiftOp function, which only does necessary works for
   typechecking OLSH/ORSH. That ends up moving OLSH/ORSH to a separated
   case in typecheck1.

 - Move OASOP to separated case, so its logic is detached from tcArith.

 - Move OANDAND/OOROR to separated case, which does some validation
   dedicated to logical operators only.

Passes toolstash -cmp.

Change-Id: I0db7b7c7a3e52d6f9e9d87eee6967871f1c32200
Reviewed-on: https://go-review.googlesource.com/c/go/+/279442
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>
2020-12-29 07:55:55 +00:00
Matthew Dempsky
a5ec920160 [dev.regabi] cmd/compile: more Linksym cleanup
This largely gets rid of the remaining direct Linksym calls, hopefully
enough to discourage people from following bad existing practice until
Sym.Linksym can be removed entirely.

Passes toolstash -cmp.

Change-Id: I5d8f8f703ace7256538fc79648891ede0d879dc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/280641
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>
2020-12-29 07:55:00 +00:00
Matthew Dempsky
ec59b197d5 [dev.regabi] cmd/compile: rewrite to use linksym helpers [generated]
Passes toolstash -cmp.

[git-generate]
cd src/cmd/compile/internal/gc
pkgs=$(grep -l -w Linksym ../*/*.go | xargs dirname | grep -v '/gc$' | sort -u)
rf '
	ex . '"$(echo $pkgs)"' {
		import "cmd/compile/internal/ir"
		import "cmd/compile/internal/reflectdata"
		import "cmd/compile/internal/staticdata"
		import "cmd/compile/internal/types"

		avoid reflectdata.TypeLinksym
		avoid reflectdata.TypeLinksymLookup
		avoid reflectdata.TypeLinksymPrefix
		avoid staticdata.FuncLinksym

		var f *ir.Func
		var n *ir.Name
		var s string
		var t *types.Type

		f.Sym().Linksym() -> f.Linksym()
		n.Sym().Linksym() -> n.Linksym()

		reflectdata.TypeSym(t).Linksym() -> reflectdata.TypeLinksym(t)
		reflectdata.TypeSymPrefix(s, t).Linksym() -> reflectdata.TypeLinksymPrefix(s, t)
		staticdata.FuncSym(n.Sym()).Linksym() -> staticdata.FuncLinksym(n)
		types.TypeSymLookup(s).Linksym() -> reflectdata.TypeLinksymLookup(s)
	}
'

Change-Id: I7a3ae1dcd61bcdf4a29f708ff12f7f80c2b280c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/280640
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>
2020-12-29 07:54:55 +00:00
Matthew Dempsky
25c613c02d [dev.regabi] cmd/compile: add Linksym helpers
Syms are meant to be just interned (pkg, name) tuples, and are a
purely abstract, Go-language concept. As such, associating them with
linker symbols (a low-level, implementation-oriented detail) is
inappropriate.

There's still work to be done before linker symbols can be directly
attached to their appropriate, higher-level objects instead. But in
the mean-time, we can at least add helper functions and discourage
folks from using Sym.Linksym directly. The next CL will mechanically
rewrite code to use these helpers where possible.

Passes toolstash -cmp.

Change-Id: I413bd1c80bce056304f9a7343526bd153f2b9c7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/280639
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>
2020-12-29 07:54:40 +00:00
Matthew Dempsky
289da2b33e [dev.regabi] cmd/compile: move Node.Opt to Name
Escape analysis uses Node.Opt to map nodes to their "location", so
that other references to the same node use the same location
again. But in the current implementation of escape analysis, we never
need to refer back to a node's location except for named nodes (since
other nodes are anonymous, and have no way to be referenced).

This CL moves Opt from Node down to Name, turns it into a directly
accessed field, and cleans up escape analysis to avoid setting Opt on
non-named expressions.

One nit: in walkCheckPtrArithmetic, we were abusing Opt as a way to
detect/prevent loops. This CL adds a CheckPtr bit flag instead.

Passes toolstash -cmp.

Change-Id: If57d5ad8d972fa63bedbe69b9ebb6753e31aba85
Reviewed-on: https://go-review.googlesource.com/c/go/+/280638
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>
2020-12-29 07:45:00 +00:00
Matthew Dempsky
6acbae4fcc [dev.regabi] cmd/compile: address some ir TODOs
Previously, ODOTTYPE/ODOTTYPE2 were forced to reuse some available
Node fields for storing pointers to runtime type descriptors. This
resulted in awkward field types for TypeAssertExpr and AddrExpr.

This CL gives TypeAssertExpr proper fields for the runtime type
descriptors, and also tightens the field types as
possible/appropriate.

Passes toolstash -cmp.

Change-Id: I521ee7a1462affc5459de33a0de6c68a7d6416ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/280637
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2020-12-29 02:49:00 +00:00
Matthew Dempsky
4629f6a51d [dev.regabi] cmd/compile: merge {Selector,CallPart,Method}Expr
These three expression nodes all represent the same syntax, and so
they're represented the same within types2. And also they're not
handled that meaningfully differently throughout the rest of the
compiler to merit unique representations.

Method expressions are somewhat unique today that they're very
frequently turned into plain function names. But eventually that can
be handled by a post-typecheck desugaring phase that reduces the
number of redundant AST forms.

Passes toolstash -cmp.

Change-Id: I20df91bbd0d885c1f18ec67feb61ae1558670719
Reviewed-on: https://go-review.googlesource.com/c/go/+/280636
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2020-12-29 02:35:04 +00:00
Matthew Dempsky
e563715b30 [dev.regabi] cmd/compile: remove Sym.Importdef
Evidently it hasn't been needed since circa 2018, when we removed the
binary export data format.

Change-Id: I4e4c788d6b6233340fb0de0a56d035c31d96f761
Reviewed-on: https://go-review.googlesource.com/c/go/+/280634
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2020-12-29 02:34:53 +00:00
Matthew Dempsky
3f370b75fb [dev.regabi] cmd/compile: cleanup //go:generate directives
During recent refactoring, we moved mkbuiltin.go to package typecheck,
but accidentally duplicated its //go:generate directive into a bunch
of other files/directories. This CL cleans up the unnecessary
duplicates.

Also, update all of the stringer invocations to use an explicit file
name, and regenerate their files.

Updates #43369.

Change-Id: I4e493c1fff103d742de0a839d7a3375659270b50
Reviewed-on: https://go-review.googlesource.com/c/go/+/280635
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
2020-12-29 02:28:24 +00:00
Matthew Dempsky
07569dac4e [dev.regabi] all: merge master (1d78139) into dev.regabi
Merge List:

+ 2020-12-26 1d78139128 runtime/cgo: fix Android build with NDK 22
+ 2020-12-25 2018b68a65 net/mail: don't use MDT in test
+ 2020-12-23 b116404444 runtime: shift timeHistogram buckets and allow negative durations
+ 2020-12-23 8db7e2fecd runtime: fix allocs-by-size and frees-by-size buckets
+ 2020-12-23 fb96f07e1a runtime: fix nStackRoots comment about stack roots
+ 2020-12-23 d1502b3c72 lib/time, time/tzdata: update tzdata to 2020e
+ 2020-12-23 30c99cbb7a cmd/go: add the Retract field to 'go help mod edit' definition of the GoMod struct
+ 2020-12-23 49d0b239cb doc: fix a typo in contribute.html
+ 2020-12-23 98a73030b0 cmd/go: in 'go get', promote named implicit dependencies to explicit
+ 2020-12-23 fd6ba1c8a2 os/signal: fix a deadlock with syscall.AllThreadsSyscall() use
+ 2020-12-23 b0b0d98283 runtime: linux iscgo support for not blocking nptl signals
+ 2020-12-22 223331fc0c cmd/go/internal/modload: add hint for missing implicit dependency

Change-Id: I76d79f17c546cab03fab1facc36cc3f834d9d126
2020-12-28 00:12:16 -08:00
Matthew Dempsky
76136be027 [dev.regabi] cmd/compile: check for recursive import in ImportBody
After earlier importer refactorings, most of the importer is now
reentrant, so we don't need to guard against it at Resolve. The only
remaining part that is still not reentrant is inline body importing,
so move the recursive-import check there.

Passes toolstash -cmp.

Change-Id: Ia828f880a03e6125b102668c12a155d4c253d26b
Reviewed-on: https://go-review.googlesource.com/c/go/+/280515
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>
2020-12-28 08:09:20 +00:00
Matthew Dempsky
fda7ec3a3f [dev.regabi] cmd/compile: remove Name.IsDDD, etc
These are never used.

Change-Id: I58f7359f20252ca942f59bc7593c615a7b9de105
Reviewed-on: https://go-review.googlesource.com/c/go/+/280514
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>
2020-12-28 08:08:25 +00:00
Matthew Dempsky
098a6490b9 [dev.regabi] cmd/compile: remove Declare in makepartialcall
This is the only remaining late call to Declare. By changing it to use
Temp, we'll be able to move the legacy lexical scoping logic by moving
it to noder and iimport.

Passes toolstash -cmp.

Change-Id: Id7cf7a08e3138e50816f515fef3088785a10aaf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/280513
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>
2020-12-28 08:07:51 +00:00
Matthew Dempsky
137f0d2e06 [dev.regabi] cmd/compile: remove unnecessary Name.Sym call
Since the introduction of ir.BasicLit, we no longer create Names
without Syms.

Passes toolstash -cmp.

Change-Id: I82de3fd65455e3756ff56e52febb512c0a2128f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/280512
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>
2020-12-28 08:06:35 +00:00
Matthew Dempsky
3383b5c74a [dev.regabi] cmd/compile: flatten dependency graph [generated]
This CL shuffles a couple functions around to help flatten the package
dependency graph somewhat:

1. ssa.LosesStmtMark is only ever used in associated with an
objw.Prog, so we might as well move it to that package. This removes a
dependency from objw (a relatively low-level utility package that
wraps cmd/internal/obj) on ssa (a large and relatively high-level
package).

2. Moves liveness.SetTypeBits into a new package typebits. A
single-function package is a bit on the silly side, but reflectdata
shouldn't need to depend on liveness (nor vice versa).

[git-generate]
cd src/cmd/compile/internal/ssa
rf '
	mv LosesStmtMark prog.go
	mv prog.go cmd/compile/internal/objw
'

cd ../liveness
rf '
	mv SetTypeBits Set
	mv Set typebits.go
	rm typebits.go:/Copyright/+4,/^package/-0
	mv typebits.go cmd/compile/internal/typebits
'

Change-Id: Ic9a983f0ad6c0cf1a537f99889699a8444699e6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/280447
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>
2020-12-28 08:06:26 +00:00
Matthew Dempsky
f8afb8216a [dev.regabi] cmd/compile: rename CommStmt and CaseStmt [generated]
Rename these two AST nodes to match their cmd/compile/internal/syntax
and go/ast counterparts.

Passes toolstash -cmp.

[git-generate]
cd src/cmd/compile/internal/ir
rf '
	mv CaseStmt CaseClause
	mv CommStmt CommClause
'
sed -E -i -e 's/(Case|Comm)Stmt/\1Clause/g' mknode.go

Change-Id: I19fba0323a5de1e71346622857011b2f7879bcef
Reviewed-on: https://go-review.googlesource.com/c/go/+/280446
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>
2020-12-28 08:03:43 +00:00
Matthew Dempsky
5f3bd59a0d [dev.regabi] cmd/compile: remove some unneeded code in package ir
The deepCopy functions haven't been needed since we switched to using
Edit everywhere, and AddStringExpr no longer has an Alloc field that
needs special casing.

Passes toolstash -cmp.

Change-Id: I5bcc8c73d5cb784f7e57fb3162ae6e288e6c9392
Reviewed-on: https://go-review.googlesource.com/c/go/+/280445
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>
2020-12-28 08:02:51 +00:00
Matthew Dempsky
3bdafb0d82 [dev.regabi] cmd/compile: remove CommStmt.List
Package syntax's parser already ensures that select communication
clauses only have one statement, so there's no need for ir's CommStmt
to need to represent more than one. Instead, noder can just directly
populate Comm in the first place.

Incidentally, this also revealed a latent issue in the inline-body
exporter: we were exporting List (where the case statement is before
type-checking), rather than Comm (where the case statement would be
after type-checking, when export happens).

Passes toolstash -cmp.

Change-Id: Ib4eb711527bed297c7332c79ed6e6562a1db2cfa
Reviewed-on: https://go-review.googlesource.com/c/go/+/280444
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-12-28 08:02:30 +00:00
Matthew Dempsky
2ecf52b841 [dev.regabi] cmd/compile: separate CommStmt from CaseStmt
Like go/ast and cmd/compile/internal/syntax before it, package ir now
has separate concrete representations for switch-case clauses and
select-communication clauses.

Passes toolstash -cmp.

Change-Id: I32667cbae251fe7881be0f434388478433b2414f
Reviewed-on: https://go-review.googlesource.com/c/go/+/280443
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>
2020-12-28 08:01:27 +00:00
Meng Zhuo
ed9772e130 [dev.regabi] cmd/compile: add explicit file name in types generation
The stringer using `go list` for the type detection, which depends on
GOROOT. Unfortunally by changing GOROOT to develop path will raise
version mismatch with internal packages.

Update #43369

Change-Id: Id81334ea5f1ecdbfa81eb2d162944d65664ce727
Reviewed-on: https://go-review.googlesource.com/c/go/+/280572
Trust: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-28 07:45:19 +00:00
Matthew Dempsky
a59d26603f [dev.regabi] cmd/compile: use []*CaseStmt in {Select,Switch}Stmt
Select and switch statements only ever contain case statements, so
change their Cases fields from Nodes to []*CaseStmt. This allows
removing a bunch of type assertions throughout the compiler.

CaseStmt should be renamed to CaseClause, and SelectStmt should
probably have its own CommClause type instead (like in go/ast and
cmd/compile/internal/syntax), but this is a good start.

Passes toolstash -cmp.

Change-Id: I2d41d616d44512c2be421e1e2ff13d0ee8b238ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/280442
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>
2020-12-28 07:45:09 +00:00
Matthew Dempsky
fbc4458c06 [dev.regabi] cmd/compile: simplify some tree traversal code
When looking for referenced functions within bottomUpVisitor and
initDeps, the logic for ODOTMETH, OCALLPART, and OMETHEXPR are
basically identical, especially after previous refactorings to make
them use MethodExprName. This CL makes them exactly identical.

Passes toolstash -cmp.

Change-Id: I1f59c9be99aa9484d0397a0a6fb8ddd894a31c68
Reviewed-on: https://go-review.googlesource.com/c/go/+/280441
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>
2020-12-28 07:45:00 +00:00
Matthew Dempsky
6c67677541 [dev.regabi] cmd/compile: simplify FuncName and PkgFuncName
Now that we have proper types, these functions can be restricted to
only allowing *ir.Func, rather than any ir.Node. And even more
fortunately, all of their callers already happen to always
pass *ir.Func arguments, making this CL pretty simple.

Passes toolstash -cmp.

Change-Id: I21ecd4c8cee3ccb8ba86b17cedb2e71c56ffe87a
Reviewed-on: https://go-review.googlesource.com/c/go/+/280440
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>
2020-12-28 07:44:45 +00:00
Matthew Dempsky
676d794b81 [dev.regabi] cmd/compile: remove refersToCommonName
After reorder3's simplification, the only remaining use of
refersToCommonName is in oaslit, where the LHS expression is always a
single name. We can replace the now overly-generalized
refersToCommonName with a simple ir.Any traversal with ir.Uses.

Passes toolstash -cmp.

Change-Id: Ice3020cdbbf6083d52e07866a687580f4eb134b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/280439
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>
2020-12-28 07:44:35 +00:00
Matthew Dempsky
c98548e110 [dev.regabi] cmd/compile: merge ascompatee, ascompatee1, and reorder3
These functions are interelated and have arbitrarily overlapping
responsibilities. By joining them together, we simplify the code and
remove some redundancy.

Passes toolstash -cmp.

Change-Id: I7c42cb7171b3006bc790199be3fd0991e6e985f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/280438
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>
2020-12-28 07:44:25 +00:00
Matthew Dempsky
4c215c4fa9 [dev.regabi] cmd/compile: simplify and optimize reorder3
reorder3 is the code responsible for ensuring that evaluation of an
N:N parallel assignment statement respects the order of evaluation
rules specified for Go.

This CL simplifies the code and improves it from an O(N^2) algorithm
to O(N).

Passes toolstash -cmp.

Change-Id: I04cd31613af6924f637b042be8ad039ec6a924c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/280437
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>
2020-12-28 07:44:16 +00:00
Matthew Dempsky
e6c973198d [dev.regabi] cmd/compile: stop mangling SelectorExpr.Sel for ODOTMETH
ODOTMETH is unique among SelectorExpr expressions, in that Sel gets
mangled so that it no longer has the original identifier that was
selected (e.g., just "Foo"), but instead the qualified symbol name for
the selected method (e.g., "pkg.Type.Foo"). This is rarely useful, and
instead results in a lot of compiler code needing to worry about
undoing this change.

This CL changes ODOTMETH to leave the original symbol in place. The
handful of code locations where the mangled symbol name is actually
wanted are updated to use ir.MethodExprName(n).Sym() or (equivalently)
ir.MethodExprName(n).Func.Sym() instead.

Historically, the compiler backend has mistakenly used types.Syms
where it should have used ir.Name/ir.Funcs. And this change in
particular may risk breaking something, as the SelectorExpr.Sel will
no longer point at a symbol that uniquely identifies the called
method. However, I expect CL 280294 (desugar OCALLMETH into OCALLFUNC)
to have substantially reduced this risk, as ODOTMETH expressions are
now replaced entirely earlier in the compiler.

Passes toolstash -cmp.

Change-Id: If3c9c3b7df78ea969f135840574cf89e1d263876
Reviewed-on: https://go-review.googlesource.com/c/go/+/280436
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>
2020-12-28 07:44:07 +00:00
Matthew Dempsky
135ce1c485 [dev.regabi] cmd/compile: desugar OMETHEXPR into ONAME during walk
A subsequent CL will change FuncName to lazily create the ONAME nodes,
which isn't currently safe to do during SSA construction, because that
phase is concurrent.

Passes toolstash -cmp.

Change-Id: Ic24acc1d1160ad93b70ced3baa468f750e689ea6
Reviewed-on: https://go-review.googlesource.com/c/go/+/280435
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>
2020-12-28 07:43:31 +00:00
Matthew Dempsky
0f732f8c91 [dev.regabi] cmd/compile: minor walkExpr cleanups
This CL cleans up a few minor points in walkExpr:

1. We don't actually care about computing the type-size of all
expressions that are walked. We care about computing the type-size of
all expressions that are *returned* by walk, as these are the
expressions that will actually be seen by the back end.

2. There's no need to call typecheck.EvalConst anymore. EvalConst used
to be responsible for doing additional constant folding during walk;
but for a while a now, it has done only as much constant folding as is
required during type checking (because doing further constant folding
led to too many issues with Go spec compliance). Instead, more
aggressive constant folding is handled entirely by SSA.

3. The code for detecting string constants and generating their
symbols can be simplified somewhat.

Passes toolstash -cmp.

Change-Id: I464ef5bceb8a97689c8f55435369a3402a5ebc55
Reviewed-on: https://go-review.googlesource.com/c/go/+/280434
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>
2020-12-28 07:10:11 +00:00