1
0
mirror of https://github.com/golang/go synced 2024-11-13 20:10:32 -07:00
Commit Graph

46879 Commits

Author SHA1 Message Date
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
Matthew Dempsky
0de8eafd98 [dev.regabi] cmd/compile: remove SelectorExpr.Offset field
Now that the previous CL ensures we always set SelectorExpr.Selection,
we can replace the SelectorExpr.Offset field with a helper method that
simply returns SelectorExpr.Selection.Offset.

Passes toolstash -cmp.

Change-Id: Id0f22b8b1980397b668f6860d27cb197b90ff52a
Reviewed-on: https://go-review.googlesource.com/c/go/+/280433
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 03:39:08 +00:00
Matthew Dempsky
a4f335f420 [dev.regabi] cmd/compile: always use a Field for ODOTPTR expressions
During walk, we create ODOTPTR expressions to access runtime struct
fields. But rather than using an actual Field for the selection, we
were just directly setting the ODOTPTR's Offset field.

This CL changes walk to create proper struct fields (albeit without
the rest of their enclosing struct type) and use them for creating the
ODOTPTR expressions.

Passes toolstash -cmp.

Change-Id: I08dbac3ed29141587feb0905d15adbcbcc4ca49e
Reviewed-on: https://go-review.googlesource.com/c/go/+/280432
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 03:38:58 +00:00
Russ Cox
dd40bbc57b [dev.typeparams] cmd/compile: re-enable internal/types2 test
CL 279531 disabled these because they were causing
trouble with the automation for the big move.
The big move is over. Reenable them.

Change-Id: I2b06f619a114ebcc9b9af73ce0d5b68ebaeaac03
Reviewed-on: https://go-review.googlesource.com/c/go/+/279993
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>
2020-12-27 12:52:55 +00:00
Elias Naur
1d78139128 runtime/cgo: fix Android build with NDK 22
Fixes #42655

Change-Id: I7d2b70098a4ba4dcb325fb0be076043789b86135
Reviewed-on: https://go-review.googlesource.com/c/go/+/280312
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Elias Naur <mail@eliasnaur.com>
2020-12-26 19:08:56 +00:00
Ian Lance Taylor
2018b68a65 net/mail: don't use MDT in test
When time.Parse sees a timezone name that matches the local timezone,
it uses the local timezone. The tests weren't expecting that,
so using MDT broke with TZ=America/Boise (where MDT means Mountain
Daylight Time). Just use GMT instead.

Fixes #43354

Change-Id: Ida70c8c867e2568b1535d1dfbf1fb0ed9e0e5c1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/280072
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2020-12-25 23:54:24 +00:00
Matthew Dempsky
e4f293d853 [dev.regabi] cmd/compile: fix OCALLMETH desugaring
During walkCall, there's a half-hearted attempt at rewriting OCALLMETH
expressions into regular function calls by moving the receiver
argument into n.Args with the rest of the arguments. But the way it
does this leaves the AST in an inconsistent state (an ODOTMETH node
with no X expression), and leaves a lot of duplicate work for the rest
of the backend to deal with.

By simply rewriting OCALLMETH expressions into proper OCALLFUNC
expressions, we eliminate a ton of unnecessary code duplication during
SSA construction and avoid creation of invalid method-typed variables.

Passes toolstash -cmp.

Change-Id: I4d5c5f90a79f8994059b2d0ae472182e08096c0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/280294
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-12-25 11:15:41 +00:00
Matthew Dempsky
1d9a1f67d5 [dev.regabi] cmd/compile: don't emit reflect data for method types
Within the compiler, we represent the type of methods as a special
"method" type, where the receiver parameter type is kept separate from
the other parameters. This is convenient for operations like testing
whether a type implements an interface, where we want to ignore the
receiver type.

These method types don't properly exist within the Go language though:
there are only "function" types. E.g., method expressions (expressions
of the form Type.Method) are simply functions with the receiver
parameter prepended to the regular parameter list.

However, the compiler backend is currently a little sloppy in its
handling of these types, which results in temporary variables being
declared as having "method" type, which then end up in DWARF
data. This is probably harmless in practice, but it's still wrong.

The proper solution is to fix the backend code so that we use correct
types everywhere, and the next CL does exactly this. But as it fixes
the DWARF output, so it fails toolstash -cmp. So this prelim CL
bandages over the issue in a way that generates the same output as
that proper fix.

Change-Id: I37a127bc8365c3a79ce513bdb3cfccb945912762
Reviewed-on: https://go-review.googlesource.com/c/go/+/280293
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-25 11:15:22 +00:00
Matthew Dempsky
396b6c2e7c [dev.regabi] cmd/compile: cleanup assignment typechecking
The assignment type-checking code previously bounced around a lot
between the LHS and RHS sides of the assignment. But there's actually
a very simple, consistent pattern to how to type check assignments:

1. Check the RHS expression.

2. If the LHS expression is an identifier that was declared in this
statement and it doesn't have an explicit type, give it the RHS
expression's default type.

3. Check the LHS expression.

4. Try assigning the RHS expression to the LHS expression, adding
implicit conversions as needed.

This CL implements this algorithm, and refactors tcAssign and
tcAssignList to use a common implementation. It also fixes the error
messages to consistently say just "1 variable" or "1 value", rather
than occasionally "1 variables" or "1 values".

Fixes #43348.

Passes toolstash -cmp.

Change-Id: I749cb8d6ccbc7d22cd7cb0a381f58a39fc2696b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/280112
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-25 09:18:20 +00:00
Cuong Manh Le
e24d2f3d05 [dev.regabi] cmd/compile: remove typ from RangeStmt
We can use RangeStmt.X.Type() instead.

Passes buildall w/ toolstash -cmp.

Change-Id: Id63ce9cb046c3b39bcc35453b1602c986794dfe1
Reviewed-on: https://go-review.googlesource.com/c/go/+/279437
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-25 05:18:05 +00:00
Matthew Dempsky
2785c691c2 [dev.regabi] cmd/compile: cleanup devirtualization docs
Change-Id: I8e319f55fad6e9ed857aa020a96f3a89ccaadcea
Reviewed-on: https://go-review.googlesource.com/c/go/+/280213
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-25 00:39:43 +00:00
Matthew Dempsky
4b1d0fe66f [dev.regabi] cmd/compile: new devirtualization pkg [generated]
The devirtualization code was only in inl.go because it reused some of
the same helper functions as inlining (notably staticValue), but that
code all ended up in package ir instead anyway. Beyond that minor
commonality, it's entirely separate from inlining.

It's definitely on the small side, but consistent with the new
micropass-as-a-package approach we're trying.

[git-generate]
cd src/cmd/compile/internal/inline
rf '
  mv Devirtualize Func
  mv devirtualizeCall Call
  mv Func Call devirtualize.go
  mv devirtualize.go cmd/compile/internal/devirtualize
'

Change-Id: Iff7b9fe486856660a8107d5391c54b7e8d238706
Reviewed-on: https://go-review.googlesource.com/c/go/+/280212
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-25 00:39:24 +00:00
Cuong Manh Le
082cc8b7d9 [dev.regabi] cmd/compile: change ir.IsAssignable -> ir.IsAddressable
ir.IsAssignable does not include map index expression, so it should be
named ir.IsAddressable instead.

[git-generate]

cd src/cmd/compile/internal/ir
rf '
  mv IsAssignable IsAddressable
'

Change-Id: Ief6188e7b784ba9592d7b0cbec33b5f70d78f638
Reviewed-on: https://go-review.googlesource.com/c/go/+/279436
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-24 16:56:19 +00:00
Cuong Manh Le
27b248b307 [dev.regabi] cmd/compile: separate range stmt Vars to Key, Value nodes
Passes buildall w/ toolstash -cmp.

Change-Id: I9738fcabc8ebf3afa34d102afadf1b474b50db35
Reviewed-on: https://go-review.googlesource.com/c/go/+/279435
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-24 11:15:02 +00:00
Matthew Dempsky
40818038bf [dev.regabi] cmd/compile: change CaseStmt.Vars to Var
There's only ever one variable implicitly declared by a CaseStmt. It's
only a slice because we previous used Rlist for this.

Passes toolstash -cmp.

Change-Id: Idf747f3ec6dfbbe4e94d60546ba04a81754df3fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/280012
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-23 20:54:11 +00:00
Michael Anthony Knyszek
b116404444 runtime: shift timeHistogram buckets and allow negative durations
Today, timeHistogram, when copied, has the wrong set of counts for the
bucket that should represent (-inf, 0), when in fact it contains [0, 1).
In essence, the buckets are all shifted over by one from where they're
supposed to be.

But this also means that the existence of the overflow bucket is wrong:
the top bucket is supposed to extend to infinity, and what we're really
missing is an underflow bucket to represent the range (-inf, 0).

We could just always zero this bucket and continue ignoring negative
durations, but that likely isn't prudent.

timeHistogram is intended to be used with differences in nanotime, but
depending on how a platform is implemented (or due to a bug in that
platform) it's possible to get a negative duration without having done
anything wrong. We should just be resilient to that and be able to
detect it.

So this change removes the overflow bucket and replaces it with an
underflow bucket, and timeHistogram no longer panics when faced with a
negative duration.

Fixes #43328.
Fixes #43329.

Change-Id: If336425d7d080fd37bf071e18746800e22d38108
Reviewed-on: https://go-review.googlesource.com/c/go/+/279468
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2020-12-23 17:31:18 +00:00
Michael Anthony Knyszek
8db7e2fecd runtime: fix allocs-by-size and frees-by-size buckets
Currently these two metrics are reported incorrectly, going by the
documentation in the runtime/metrics package. We just copy in the
size-class-based values from the runtime wholesale, but those implicitly
have an inclusive upper-bound and exclusive lower-bound (e.g. 48-byte
size class contains objects in the size range (32, 48]) but the API
declares inclusive lower-bounds and exclusive upper-bounds.

Also, the bottom bucket representing (-inf, 1) should always be empty.
Extend the consistency check to verify this.

Updates #43329.

Change-Id: I11b5b062a34e13405ab662d15334bda91f779775
Reviewed-on: https://go-review.googlesource.com/c/go/+/279467
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2020-12-23 17:31:08 +00:00
Michael Anthony Knyszek
fb96f07e1a runtime: fix nStackRoots comment about stack roots
A comment in mgcmark.go indicates that we scan stacks a second time but
we don't, at least not since changing to the hybrid write barrier.

Change-Id: I9376adbb6d8b6dd9dc3cee62e077b5dfb8a3fdde
Reviewed-on: https://go-review.googlesource.com/c/go/+/279797
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2020-12-23 17:30:35 +00:00
Alberto Donizetti
d1502b3c72 lib/time, time/tzdata: update tzdata to 2020e
Changelog:

  Volgograd switches to Moscow time on 2020-12-27 at 02:00.
  Small changes to past timestamps and abbreviations.

See

  http://mm.icann.org/pipermail/tz-announce/2020-December/000063.html

Updates #22487

Change-Id: I709abe899ca498698463e945ccbcf4bc5fe60b92
Reviewed-on: https://go-review.googlesource.com/c/go/+/279794
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-23 17:29:16 +00:00
markruler
30c99cbb7a cmd/go: add the Retract field to 'go help mod edit' definition of the GoMod struct
Fixes #43281

Change-Id: Ife26ca174a8818b56aaea9547976d97978478a5f
GitHub-Last-Rev: 85a3d30001
GitHub-Pull-Request: golang/go#43315
Reviewed-on: https://go-review.googlesource.com/c/go/+/279592
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
2020-12-23 17:26:56 +00:00
Andrey Bokhanko
49d0b239cb doc: fix a typo in contribute.html
A fix for a trivial (yet still confusing for neophytes like me!) typo in
contribute.html.

Change-Id: Ic68673fb2a3855c2b9e8042047087450e8793e6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/279452
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-23 17:01:35 +00:00
Cuong Manh Le
9eeed291bc [dev.regabi] cmd/compile: eliminate usage of ir.Node in liveness
All function parameters and return values in liveness have explicit
*ir.Name type, so use it directly instead of casting from ir.Node. While
at it, rename "affectedNode" to "affectedVar" to reflect this change.

Passes buildall w/ toolstash -cmp.

Change-Id: Id927e817a92ddb551a029064a2a54e020ca27074
Reviewed-on: https://go-review.googlesource.com/c/go/+/279434
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-23 15:15:29 +00:00
Matthew Dempsky
d1d64e4cea [dev.regabi] cmd/compile: split SliceExpr.List into separate fields
Passes toolstash -cmp.

Change-Id: I4e31154d04d99f2b80bec6a2c571a2a4a3f2ec99
Reviewed-on: https://go-review.googlesource.com/c/go/+/279959
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
2020-12-23 14:38:23 +00:00
Jay Conrod
98a73030b0 cmd/go: in 'go get', promote named implicit dependencies to explicit
'go get pkg@vers' will now add an explicit requirement for the module
providing pkg if that version was already indirectly required.

'go get mod@vers' will do the same if mod is a module path but not a
package.

Requirements promoted this way will be marked "// indirect" because
'go get' doesn't know whether they're needed to build packages in the
main module. So users should prefer to run 'go get ./pkg' (where ./pkg
is a package in the main module) to promote requirements.

Fixes #43131

Change-Id: Ifbb65b71274b3cc752a7a593d6ddd875f7de23b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/278812
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-12-23 14:16:32 +00:00
Matthew Dempsky
d19018e8f1 [dev.regabi] cmd/compile: split SliceHeaderExpr.LenCap into separate fields
Passes toolstash -cmp.

Change-Id: Ifc98a408c154a05997963e2c731466842ebbf50e
Reviewed-on: https://go-review.googlesource.com/c/go/+/279958
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-23 14:09:23 +00:00
Matthew Dempsky
53f082b0ee [dev.regabi] cmd/compile: cleanup export code further
This CL rips off a number of toolstash bandages:

- Fixes position information for string concatenation.

- Adds position information for struct literal fields.

- Removes unnecessary exprsOrNil calls or replaces them with plain
  expr calls when possible.

- Reorders conversion expressions to put type first, which matches
  source order and also the order the importer needs for calling the
  ConvExpr constructor.

Change-Id: I44cdc6035540d9ecefd9c1bcd92b8711d6ed813c
Reviewed-on: https://go-review.googlesource.com/c/go/+/279957
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-23 12:01:07 +00:00
Matthew Dempsky
31267f82e1 [dev.regabi] cmd/compile: simplify function/interface/struct typechecking
After the previous CL, the only callers to NewFuncType, tointerface,
or NewStructType are the functions for type-checking the type literal
ASTs. So just inline the code there.

While here, refactor the Field type-checking logic a little bit, to
reduce some duplication.

Passes toolstash -cmp.

Change-Id: Ie12d14b87ef8b6e528ac9dccd609604bd09b98ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/279956
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-23 11:59:32 +00:00
Matthew Dempsky
addade2cce [dev.regabi] cmd/compile: prefer types constructors over typecheck
Similar to the earlier mkbuiltin cleanup, there's a bunch of code that
calls typecheck.NewFuncType or typecheck.NewStructType, which can now
just call types.NewSignature and types.NewStruct, respectively.

Passes toolstash -cmp.

Change-Id: Ie6e09f1a7efef84b9a2bb5daa7087a6879979668
Reviewed-on: https://go-review.googlesource.com/c/go/+/279955
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-23 11:59:23 +00:00
Matthew Dempsky
18ebfb49e9 [dev.regabi] cmd/compile: cleanup noder
Similar to previous CL: take advantage of better constructor APIs for
translating ASTs from syntax to ir.

Passes toolstash -cmp.

Change-Id: I40970775e7dd5afe2a0b7593ce3bd73237562457
Reviewed-on: https://go-review.googlesource.com/c/go/+/279972
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-23 10:46:45 +00:00
Matthew Dempsky
87a592b356 [dev.regabi] cmd/compile: cleanup import/export code
Now that we have concrete AST node types and better constructor APIs,
we can more cleanup a lot of the import code and some export code too.

Passes toolstash -cmp.

Change-Id: Ie3425d9dac11ac4245e5da675dd298984a926df4
Reviewed-on: https://go-review.googlesource.com/c/go/+/279954
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-23 10:29:05 +00:00
Matthew Dempsky
5898025026 [dev.regabi] cmd/compile: update mkbuiltin.go to use new type constructors
We recently added new functions to types like NewSignature and
NewField, so we can use these directly rather than depending on the
typecheck and ir wrappers.

Passes toolstash -cmp.

Change-Id: I32676aa9a4ea71892216017756e72bcf90297219
Reviewed-on: https://go-review.googlesource.com/c/go/+/279953
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-23 09:51:23 +00:00
Matthew Dempsky
63c96c2ee7 [dev.regabi] cmd/compile: update mkbuiltin.go and re-enable TestBuiltin
Update's mkbuiltin.go to match builtin.go after the recent rf
rewrites.

Change-Id: I80cf5d7c27b36fe28553406819cb4263de84e5ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/279952
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-23 09:51:13 +00:00
Russ Cox
d99dd17827 [dev.typeparams] all: merge dev.regabi (37f138d) into dev.typeparams
Conflicts:

* src/cmd/compile/fmtmap_test.go
* src/cmd/compile/internal/gc/go.go
* src/cmd/compile/internal/gc/main.go
* src/cmd/compile/internal/noder/noder.go

Merge List:

* 2020-12-23 37f138df6b [dev.regabi] cmd/compile: split out package test [generated]
* 2020-12-23 3d8a3cb06b [dev.regabi] cmd/compile: split out package pkginit [generated]
* 2020-12-23 3f04d964ab [dev.regabi] cmd/compile: split up walkexpr1, walkstmt [generated]
* 2020-12-23 e4895ab4c0 [dev.regabi] cmd/compile: split out package walk [generated]
* 2020-12-23 01fd2d05c8 [dev.regabi] cmd/compile: split out package dwarfgen [generated]
* 2020-12-23 6c34d2f420 [dev.regabi] cmd/compile: split out package ssagen [generated]
* 2020-12-23 de65151e50 [dev.regabi] cmd/compile: split out package reflectdata [generated]
* 2020-12-23 4dfb5d91a8 [dev.regabi] cmd/compile: split out package staticdata [generated]
* 2020-12-23 fbc82f03b1 [dev.regabi] cmd/compile: split out package noder [generated]
* 2020-12-23 de454eef5f [dev.regabi] cmd/compile: split out package escape [generated]
* 2020-12-23 071ab0a14c [dev.regabi] cmd/compile: split out package liveness [generated]
* 2020-12-23 0ced54062e [dev.regabi] cmd/compile: split out package objw [generated]
* 2020-12-23 575fd6ff0a [dev.regabi] cmd/compile: split out package inline [generated]
* 2020-12-23 0256ba99a8 [dev.regabi] cmd/compile: split up typecheck1 [generated]
* 2020-12-23 b9693d7627 [dev.regabi] cmd/compile: split out package typecheck [generated]
* 2020-12-23 dac0de3748 [dev.regabi] cmd/compile: move type size calculations into package types [generated]
* 2020-12-23 527a1895d6 [dev.regabi] cmd/compile: move helpers into package ir [generated]
* 2020-12-23 65c4c6dfb2 [dev.regabi] cmd/compile: group known symbols, packages, names [generated]
* 2020-12-23 9ee309255a [dev.regabi] cmd/compile: move helpers into package types [generated]
* 2020-12-23 ead4957892 [dev.regabi] cmd/compile: move helpers into package base [generated]
* 2020-12-23 440308ffd7 [dev.regabi] cmd/compile: simplify Nodes usage [generated]
* 2020-12-23 f9d373720e [dev.regabi] cmd/compile: remove Left, Right etc methods [generated]
* 2020-12-23 14d667341f [dev.regabi] cmd/compile: remove Node.Left etc [generated]
* 2020-12-23 6f27d29be0 [dev.regabi] cmd/compile: remove ir.Nod [generated]
* 2020-12-23 69cf39089f [dev.regabi] cmd/compile: do not die in early base.FlushErrors

Change-Id: Ic4686e77c6ee38b3cd7d37fc7f3e93aaa9017b7a
2020-12-23 01:43:22 -05:00
Russ Cox
37f138df6b [dev.regabi] cmd/compile: split out package test [generated]
[git-generate]
cd src/cmd/compile/internal/gc
rf '
	mv bench_test.go constFold_test.go dep_test.go \
		fixedbugs_test.go iface_test.go float_test.go global_test.go \
		inl_test.go lang_test.go logic_test.go \
		reproduciblebuilds_test.go shift_test.go ssa_test.go \
		truncconst_test.go zerorange_test.go \
		cmd/compile/internal/test
'
mv testdata ../test

Change-Id: I041971b7e9766673f7a331679bfe1c8110dcda66
Reviewed-on: https://go-review.googlesource.com/c/go/+/279480
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:40:04 +00:00
Russ Cox
3d8a3cb06b [dev.regabi] cmd/compile: split out package pkginit [generated]
[git-generate]
cd src/cmd/compile/internal/gc
rf '
	mv fninit Task
	mv init.go initorder.go cmd/compile/internal/pkginit
'

Change-Id: Ie2a924784c7a6fa029eaef821384eef4b262e1af
Reviewed-on: https://go-review.googlesource.com/c/go/+/279479
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:39:57 +00:00
Russ Cox
3f04d964ab [dev.regabi] cmd/compile: split up walkexpr1, walkstmt [generated]
walkexpr1 is the second largest non-machine-generated function in the compiler.
weighing in at 1,164 lines. Since we are destroying the git blame history
anyway, now is a good time to split each different case into its own function,
making future work on this function more manageable.
Do the same to walkstmt too for consistency, even though it is a paltry 259 lines.

[git-generate]
cd src/cmd/compile/internal/walk
rf '
	mv addstr walkAddString
	mv walkCall walkCall1
	mv walkpartialcall walkCallPart
	mv walkclosure walkClosure
	mv walkrange walkRange
	mv walkselect walkSelect
	mv walkselectcases walkSelectCases
	mv walkswitch walkSwitch
	mv walkExprSwitch walkSwitchExpr
	mv walkTypeSwitch walkSwitchType
	mv walkstmt walkStmt
	mv walkstmtlist walkStmtList
	mv walkexprlist walkExprList
	mv walkexprlistsafe walkExprListSafe
	mv walkexprlistcheap walkExprListCheap
	mv walkexpr walkExpr
	mv walkexpr1 walkExpr1
	mv walkprint walkPrint
	mv walkappend walkAppend
	mv walkcompare walkCompare
	mv walkcompareInterface walkCompareInterface
	mv walkcompareString walkCompareString

	mv appendslice appendSlice
	mv cheapexpr cheapExpr
	mv copyany walkCopy
	mv copyexpr copyExpr
	mv eqfor eqFor
	mv extendslice extendSlice
	mv finishcompare finishCompare
	mv safeexpr safeExpr

	mv walkStmt:/^\tcase ir.ORECV:/+2,/^\tcase /-2 walkRecv
	add walk.go:/^func walkRecv/-0 \
		// walkRecv walks an ORECV node.
	mv walkStmt:/^\tcase ir.ODCL:/+2,/^\tcase /-2 walkDecl
	add walk.go:/^func walkDecl/-0 \
		// walkDecl walks an ODCL node.
	mv walkStmt:/^\tcase ir.OGO:/+2,/^\tcase /-2 walkGoDefer
	add walk.go:/^func walkGoDefer/-0 \
		// walkGoDefer walks an OGO or ODEFER node.
	mv walkStmt:/^\tcase ir.OFOR,/+2,/^\tcase /-2 walkFor
	add walk.go:/^func walkFor/-0 \
		// walkFor walks an OFOR or OFORUNTIL node.
	mv walkStmt:/^\tcase ir.OIF:/+2,/^\tcase /-2 walkIf
	add walk.go:/^func walkIf/-0 \
		// walkIf walks an OIF node.
	mv walkStmt:/^\tcase ir.ORETURN:/+2,/^\tcase /-2 walkReturn
	add walk.go:/^func walkReturn/-0 \
		// walkReturn walks an ORETURN node.

	mv walkExpr1:/^\tcase ir.ODOT,/+2,/^\tcase /-2 walkDot
	add walk.go:/^func walkDot/-0 \
		// walkDot walks an ODOT or ODOTPTR node.
	mv walkExpr1:/^\tcase ir.ODOTTYPE,/+2,/^\tcase /-2 walkDotType
	add walk.go:/^func walkDotType/-0 \
		// walkDotType walks an ODOTTYPE or ODOTTYPE2 node.
	mv walkExpr1:/^\tcase ir.OLEN,/+2,/^\tcase /-2 walkLenCap
	add walk.go:/^func walkLenCap/-0 \
		// walkLenCap walks an OLEN or OCAP node.
	mv walkExpr1:/^\tcase ir.OANDAND,/+2,/^\tcase /-2 walkLogical
	add walk.go:/^func walkLogical/-0 \
		// walkLogical walks an OANDAND or OOROR node.
	mv walkExpr1:/^\tcase ir.OCALLINTER,/+2,/^\tcase /-2 walkCall
	add walk.go:/^func walkCall/-0 \
		// walkCall walks an OCALLFUNC, OCALLINTER, or OCALLMETH node.
	mv walkExpr1:/^\tcase ir.OAS,/+1,/^\tcase /-2 walkAssign
	add walk.go:/^func walkAssign/-0 \
		// walkAssign walks an OAS (AssignExpr) or OASOP (AssignOpExpr) node.
	mv walkExpr1:/^\tcase ir.OAS2:/+2,/^\tcase /-3 walkAssignList
	add walk.go:/^func walkAssignList/-0 \
		// walkAssignList walks an OAS2 node.
	mv walkExpr1:/^\tcase ir.OAS2FUNC:/+2,/^\tcase /-4 walkAssignFunc
	add walk.go:/^func walkAssignFunc/-0 \
		// walkAssignFunc walks an OAS2FUNC node.
	mv walkExpr1:/^\tcase ir.OAS2RECV:/+2,/^\tcase /-3 walkAssignRecv
	add walk.go:/^func walkAssignRecv/-0 \
		// walkAssignRecv walks an OAS2RECV node.
	mv walkExpr1:/^\tcase ir.OAS2MAPR:/+2,/^\tcase /-2 walkAssignMapRead
	add walk.go:/^func walkAssignMapRead/-0 \
		// walkAssignMapRead walks an OAS2MAPR node.
	mv walkExpr1:/^\tcase ir.ODELETE:/+2,/^\tcase /-2 walkDelete
	add walk.go:/^func walkDelete/-0 \
		// walkDelete walks an ODELETE node.
	mv walkExpr1:/^\tcase ir.OAS2DOTTYPE:/+2,/^\tcase /-2 walkAssignDotType
	add walk.go:/^func walkAssignDotType/-0 \
		// walkAssignDotType walks an OAS2DOTTYPE node.
	mv walkExpr1:/^\tcase ir.OCONVIFACE:/+2,/^\tcase /-2 walkConvInterface
	add walk.go:/^func walkConvInterface/-0 \
		// walkConvInterface walks an OCONVIFACE node.
	mv walkExpr1:/^\tcase ir.OCONV,/+2,/^\tcase /-2 walkConv
	add walk.go:/^func walkConv/-0 \
		// walkConv walks an OCONV or OCONVNOP (but not OCONVIFACE) node.
	mv walkExpr1:/^\tcase ir.ODIV,/+2,/^\tcase /-2 walkDivMod
	add walk.go:/^func walkDivMod/-0 \
		// walkDivMod walks an ODIV or OMOD node.
	mv walkExpr1:/^\tcase ir.OINDEX:/+2,/^\tcase /-2 walkIndex
	add walk.go:/^func walkIndex/-0 \
		// walkIndex walks an OINDEX node.
	# move type assertion above comment
	mv walkExpr1:/^\tcase ir.OINDEXMAP:/+/n := n/-+ walkExpr1:/^\tcase ir.OINDEXMAP:/+0
	mv walkExpr1:/^\tcase ir.OINDEXMAP:/+2,/^\tcase /-2 walkIndexMap
	add walk.go:/^func walkIndexMap/-0 \
		// walkIndexMap walks an OINDEXMAP node.
	mv walkExpr1:/^\tcase ir.OSLICEHEADER:/+2,/^\tcase /-2 walkSliceHeader
	add walk.go:/^func walkSliceHeader/-0 \
		// walkSliceHeader walks an OSLICEHEADER node.
	mv walkExpr1:/^\tcase ir.OSLICE,/+2,/^\tcase /-2 walkSlice
	add walk.go:/^func walkSlice/-0 \
		// walkSlice walks an OSLICE, OSLICEARR, OSLICESTR, OSLICE3, or OSLICE3ARR node.
	mv walkExpr1:/^\tcase ir.ONEW:/+2,/^\tcase /-2 walkNew
	add walk.go:/^func walkNew/-0 \
		// walkNew walks an ONEW node.
	# move type assertion above comment
	mv walkExpr1:/^\tcase ir.OCLOSE:/+/n := n/-+ walkExpr1:/^\tcase ir.OCLOSE:/+0
	mv walkExpr1:/^\tcase ir.OCLOSE:/+2,/^\tcase /-2 walkClose
	add walk.go:/^func walkClose/-0 \
		// walkClose walks an OCLOSE node.
	# move type assertion above comment
	mv walkExpr1:/^\tcase ir.OMAKECHAN:/+/n := n/-+ walkExpr1:/^\tcase ir.OMAKECHAN:/+0
	mv walkExpr1:/^\tcase ir.OMAKECHAN:/+2,/^\tcase /-2 walkMakeChan
	add walk.go:/^func walkMakeChan/-0 \
		// walkMakeChan walks an OMAKECHAN node.
	mv walkExpr1:/^\tcase ir.OMAKEMAP:/+2,/^\tcase /-2 walkMakeMap
	add walk.go:/^func walkMakeMap/-0 \
		// walkMakeMap walks an OMAKEMAP node.
	mv walkExpr1:/^\tcase ir.OMAKESLICE:/+2,/^\tcase /-2 walkMakeSlice
	add walk.go:/^func walkMakeSlice/-0 \
		// walkMakeSlice walks an OMAKESLICE node.
	mv walkExpr1:/^\tcase ir.OMAKESLICECOPY:/+2,/^\tcase /-2 walkMakeSliceCopy
	add walk.go:/^func walkMakeSliceCopy/-0 \
		// walkMakeSliceCopy walks an OMAKESLICECOPY node.
	mv walkExpr1:/^\tcase ir.ORUNESTR:/+2,/^\tcase /-2 walkRuneToString
	add walk.go:/^func walkRuneToString/-0 \
		// walkRuneToString walks an ORUNESTR node.
	mv walkExpr1:/^\tcase ir.OBYTES2STR,/+2,/^\tcase /-2 walkBytesRunesToString
	add walk.go:/^func walkBytesRunesToString/-0 \
		// walkBytesRunesToString walks an OBYTES2STR or ORUNES2STR node.
	mv walkExpr1:/^\tcase ir.OBYTES2STRTMP:/+2,/^\tcase /-2 walkBytesToStringTemp
	add walk.go:/^func walkBytesToStringTemp/-0 \
		// walkBytesToStringTemp walks an OBYTES2STRTMP node.
	mv walkExpr1:/^\tcase ir.OSTR2BYTES:/+2,/^\tcase /-2 walkStringToBytes
	add walk.go:/^func walkStringToBytes/-0 \
		// walkStringToBytes walks an OSTR2BYTES node.
	# move type assertion above comment
	mv walkExpr1:/^\tcase ir.OSTR2BYTESTMP:/+/n := n/-+ walkExpr1:/^\tcase ir.OSTR2BYTESTMP:/+0
	mv walkExpr1:/^\tcase ir.OSTR2BYTESTMP:/+2,/^\tcase /-2 walkStringToBytesTemp
	add walk.go:/^func walkStringToBytesTemp/-0 \
		// walkStringToBytesTemp walks an OSTR2BYTESTMP node.
	mv walkExpr1:/^\tcase ir.OSTR2RUNES:/+2,/^\tcase /-2 walkStringToRunes
	add walk.go:/^func walkStringToRunes/-0 \
		// walkStringToRunes walks an OSTR2RUNES node.
	mv walkExpr1:/^\tcase ir.OARRAYLIT,/+1,/^\tcase /-2 walkCompLit
	add walk.go:/^func walkCompLit/-0 \
		// walkCompLit walks a composite literal node: \
		// OARRAYLIT, OSLICELIT, OMAPLIT, OSTRUCTLIT (all CompLitExpr), or OPTRLIT (AddrExpr).
	mv walkExpr1:/^\tcase ir.OSEND:/+2,/^\tcase /-2 walkSend
	add walk.go:/^func walkSend/-0 \
		// walkSend walks an OSEND node.

	mv walkStmt walkStmtList \
		walkDecl \
		walkFor \
		walkGoDefer \
		walkIf \
		wrapCall \
		stmt.go

	mv walkExpr walkExpr1 walkExprList walkExprListCheap walkExprListSafe \
		cheapExpr safeExpr copyExpr \
		walkAddString \
		walkCall \
		walkCall1 \
		walkDivMod \
		walkDot \
		walkDotType \
		walkIndex \
		walkIndexMap \
		walkLogical \
		walkSend \
		walkSlice \
		walkSliceHeader \
		reduceSlice \
		bounded \
		usemethod \
		usefield \
		expr.go

	mv \
		walkAssign \
		walkAssignDotType \
		walkAssignFunc \
		walkAssignList \
		walkAssignMapRead \
		walkAssignRecv \
		walkReturn \
		fncall \
		ascompatee \
		ascompatee1 \
		ascompatet \
		reorder3 \
		reorder3save \
		aliased \
		anyAddrTaken \
		refersToName \
		refersToCommonName \
		appendSlice \
		isAppendOfMake \
		extendSlice \
		assign.go

	mv \
		walkCompare \
		walkCompareInterface \
		walkCompareString \
		finishCompare \
		eqFor \
		brcom \
		brrev \
		tracecmpArg \
		canMergeLoads \
		compare.go

	mv \
		walkConv \
		walkConvInterface \
		walkBytesRunesToString \
		walkBytesToStringTemp \
		walkRuneToString \
		walkStringToBytes \
		walkStringToBytesTemp \
		walkStringToRunes \
		convFuncName \
		rtconvfn \
		byteindex \
		walkCheckPtrAlignment \
		walkCheckPtrArithmetic \
		convert.go

	mv \
		walkAppend \
		walkClose \
		walkCopy \
		walkDelete \
		walkLenCap \
		walkMakeChan \
		walkMakeMap \
		walkMakeSlice \
		walkMakeSliceCopy \
		walkNew \
		walkPrint \
		badtype \
		callnew \
		writebarrierfn \
		isRuneCount \
		builtin.go

	mv \
		walkCompLit \
		sinit.go \
		complit.go

	mv subr.go walk.go
'

Change-Id: Ie0cf3ba4adf363c120c134d57cb7ef37934eaab9
Reviewed-on: https://go-review.googlesource.com/c/go/+/279430
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:39:50 +00:00
Russ Cox
e4895ab4c0 [dev.regabi] cmd/compile: split out package walk [generated]
[git-generate]
cd src/cmd/compile/internal/gc
rf '
	# Late addition to package ir.
	mv closuredebugruntimecheck ClosureDebugRuntimeCheck
	mv hasemptycvars IsTrivialClosure
	mv ClosureDebugRuntimeCheck IsTrivialClosure func.go
	mv func.go cmd/compile/internal/ir

	# Late addition to package reflectdata.
	mv markTypeUsedInInterface MarkTypeUsedInInterface
	mv markUsedIfaceMethod MarkUsedIfaceMethod
	mv MarkTypeUsedInInterface MarkUsedIfaceMethod reflect.go
	mv reflect.go cmd/compile/internal/reflectdata

	# Late addition to package staticdata.
	mv litsym InitConst
	mv InitConst data.go
	mv data.go cmd/compile/internal/staticdata

	# Extract staticinit out of walk into its own package.
	mv InitEntry InitPlan InitSchedule InitSchedule.append InitSchedule.staticInit \
		InitSchedule.tryStaticInit InitSchedule.staticcopy \
		InitSchedule.staticassign InitSchedule.initplan InitSchedule.addvalue \
		statuniqgen staticname stataddr anySideEffects getlit isvaluelit \
		sched.go
	mv InitSchedule.initplans InitSchedule.Plans
	mv InitSchedule.inittemps InitSchedule.Temps
	mv InitSchedule.out InitSchedule.Out
	mv InitSchedule.staticInit InitSchedule.StaticInit
	mv InitSchedule.staticassign InitSchedule.StaticAssign
	mv InitSchedule Schedule
	mv InitPlan Plan
	mv InitEntry Entry
	mv anySideEffects AnySideEffects
	mv staticname StaticName
	mv stataddr StaticLoc
	mv sched.go cmd/compile/internal/staticinit

	# Export API and unexport non-API.
	mv transformclosure Closure
	mv walk Walk

	mv Order orderState

	mv swt.go switch.go
	mv racewalk.go race.go

	mv closure.go order.go range.go select.go switch.go race.go \
		sinit.go subr.go walk.go \
		cmd/compile/internal/walk
'

: # Update format test.
cd ../../
go install cmd/compile/... cmd/internal/archive
go test -u || go test -u
rm -rf ../../../pkg/darwin_amd64/cmd

Change-Id: I11c7a45f74d4a9e963da15c080e1018caaa99c05
Reviewed-on: https://go-review.googlesource.com/c/go/+/279478
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:39:43 +00:00
Russ Cox
01fd2d05c8 [dev.regabi] cmd/compile: split out package dwarfgen [generated]
[git-generate]
cd src/cmd/compile/internal/gc

rf '
	# Inline and remove ngotype.
	ex {
		import "cmd/compile/internal/ir"
		import "cmd/compile/internal/reflectdata"
		var n ir.Node
		ngotype(n) -> reflectdata.TypeSym(n.Type())
	}
	rm ngotype

	mv recordFlags RecordFlags
	mv recordPackageName RecordPackageName
	mv RecordFlags RecordPackageName dwarf.go

	mv debuginfo Info
	mv genAbstractFunc AbstractFunc
	mv scope.go scope_test.go dwarf.go dwinl.go cmd/compile/internal/dwarfgen
'

Change-Id: I31fa982900dbba2066ca4c7a706af922e5481c70
Reviewed-on: https://go-review.googlesource.com/c/go/+/279477
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:39:36 +00:00
Russ Cox
6c34d2f420 [dev.regabi] cmd/compile: split out package ssagen [generated]
[git-generate]

cd src/cmd/compile/internal/gc
rf '
	# maxOpenDefers is declared in ssa.go but used only by walk.
	mv maxOpenDefers walk.go

	# gc.Arch -> ssagen.Arch
	# It is not as nice but will do for now.
	mv Arch ArchInfo
	mv thearch Arch
	mv Arch ArchInfo arch.go

	# Pull dwarf out of pgen.go.
	mv debuginfo declPos createDwarfVars preInliningDcls \
		createSimpleVars createSimpleVar \
		createComplexVars createComplexVar \
		dwarf.go

	# Pull high-level compilation out of pgen.go,
	# leaving only the SSA code.
	mv compilequeue funccompile compile compilenow \
		compileFunctions isInlinableButNotInlined \
		initLSym \
		compile.go

	mv BoundsCheckFunc GCWriteBarrierReg ssa.go
	mv largeStack largeStackFrames CheckLargeStacks pgen.go

	# All that is left in dcl.go is the nowritebarrierrecCheck
	mv dcl.go nowb.go

	# Export API and unexport non-API.
	mv initssaconfig InitConfig
	mv isIntrinsicCall IsIntrinsicCall
	mv ssaDumpInline DumpInline
	mv initSSATables InitTables
	mv initSSAEnv InitEnv
	mv compileSSA Compile
	mv stackOffset StackOffset
	mv canSSAType TypeOK
	mv SSAGenState State
	mv FwdRefAux fwdRefAux

	mv cgoSymABIs CgoSymABIs
	mv readSymABIs ReadSymABIs
	mv initLSym InitLSym
	mv useABIWrapGen symabiDefs CgoSymABIs ReadSymABIs InitLSym selectLSym makeABIWrapper setupTextLSym abi.go

	mv arch.go abi.go nowb.go phi.go pgen.go pgen_test.go ssa.go cmd/compile/internal/ssagen
'
rm go.go gsubr.go

Change-Id: I47fad6cbf1d1e583fd9139003a08401d7cd048a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/279476
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:39:29 +00:00
Russ Cox
de65151e50 [dev.regabi] cmd/compile: split out package reflectdata [generated]
[git-generate]

cd src/cmd/compile/internal/gc
rf '
	ex {
		import "cmd/compile/internal/base"
		thearch.LinkArch.Name -> base.Ctxt.Arch.Name
	}

	# Move out of reflect.go a few functions that should stay.
	mv addsignats obj.go
	mv deferstruct ssa.go

	# Export reflectdata API.
	mv zerosize ZeroSize
	mv hmap MapType
	mv bmap MapBucketType
	mv hiter MapIterType
	mv addsignat NeedRuntimeType
	mv typename TypePtr
	mv typenamesym TypeSym
	mv typesymprefix TypeSymPrefix
	mv itabsym ITabSym
	mv tracksym TrackSym
	mv zeroaddr ZeroAddr
	mv itabname ITabAddr
	mv ifaceMethodOffset InterfaceMethodOffset
	mv peekitabs CompileITabs
	mv addptabs CollectPTabs
	mv algtype AlgType
	mv dtypesym WriteType
	mv dumpbasictypes WriteBasicTypes
	mv dumpimportstrings WriteImportStrings
	mv dumpsignats WriteRuntimeTypes
	mv dumptabs WriteTabs
	mv eqinterface EqInterface
	mv eqstring EqString

	mv GCProg gcProg
	mv EqCanPanic eqCanPanic
	mv IsRegularMemory isRegularMemory
	mv Sig typeSig

	mv hashmem alg.go
	mv CollectPTabs genwrapper ZeroSize reflect.go
	mv alg.go reflect.go cmd/compile/internal/reflectdata
'

Change-Id: Iaae9da9e9fad5f772f5216004823ccff2ea8f139
Reviewed-on: https://go-review.googlesource.com/c/go/+/279475
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:39:23 +00:00
Russ Cox
4dfb5d91a8 [dev.regabi] cmd/compile: split out package staticdata [generated]
[git-generate]
cd src/cmd/compile/internal/gc

rf '
	# Export API and move to its own files.
	mv addrsym InitAddr
	mv pfuncsym InitFunc
	mv slicesym InitSlice
	mv slicebytes InitSliceBytes
	mv stringsym StringSym
	mv funcsym FuncSym
	mv makefuncsym NeedFuncSym
	mv dumpfuncsyms WriteFuncSyms
	mv InitAddr InitFunc InitSlice InitSliceBytes stringSymPrefix \
		StringSym fileStringSym slicedataGen slicedata dstringdata \
		funcsyms FuncSym NeedFuncSym WriteFuncSyms \
		data.go

	mv initEmbed WriteEmbed
	mv dumpembeds obj.go

	mv data.go embed.go cmd/compile/internal/staticdata
'

Change-Id: I209c5e597c8acfa29a48527695a9ddc1e9ea8e6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/279474
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:39:16 +00:00
Russ Cox
fbc82f03b1 [dev.regabi] cmd/compile: split out package noder [generated]
[git-generate]
cd src/cmd/compile/internal/gc

rf '
	mv ArhdrSize HeaderSize
	mv arsize ReadHeader
	mv formathdr FormatHeader
	mv HeaderSize ReadHeader FormatHeader archive.go
	mv archive.go cmd/internal/archive

	mv makePos main.go

	mv checkDotImports CheckDotImports
	mv parseFiles ParseFiles

	mv Pragma pragmas
	mv PragmaEmbed pragmaEmbed
	mv PragmaPos pragmaPos
	mv FuncPragmas funcPragmas
	mv TypePragmas typePragmas

	mv fakeRecv noder.funcLit renameinitgen renameinit oldname varEmbed noder.go
	mv isDriveLetter islocalname findpkg myheight importfile \
		reservedimports isbadimport \
		pkgnotused \
		mkpackage clearImports \
		CheckDotImports dotImports importDot \
		importName \
		import.go

	mv noder _noder
	mv import.go lex.go lex_test.go noder.go cmd/compile/internal/noder
'
cd ../noder
rf '
	mv _noder noder
'

Change-Id: Iac2b856f7b86143c666d818e4b7c5b261cf387d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/279473
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:39:06 +00:00