Closures have their own ONAMEs for captured variables, which their
function bodies refer to. So during inlining, we need to account for
this and ensure the references still work.
The previous inlining handled this by actually declaring the variables
and then either copying the original value or creating a pointer to
them, as appropriate for variables captured by value or by reference.
But this is needlessly complicated. When inlining the function body,
we need to rewrite all variable references anyway. We can just detect
closure variables and change them to directly point to the enclosing
function's version of this variable. No need for copying or further
indirection.
Does not pass toolstash -cmp. Presumably because we're able to
generate better code in some circumstances.
Change-Id: I8f0ccf7b098f39b8cd33f3bcefb875c8132d2c62
Reviewed-on: https://go-review.googlesource.com/c/go/+/280996
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>
The previous code was way overcomplicating things. To find out if a
variable is a closure pseudo-variable, one only needs to check
IsClosureVar. Checking Captured and Byval are only meant to be used by
closure conversion.
Passes toolstash -cmp.
Change-Id: I22622cba36ba7f60b3275d17999a8b6bb7c6719a
Reviewed-on: https://go-review.googlesource.com/c/go/+/280995
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>
We can easily compute this on demand.
Passes toolstash -cmp.
Change-Id: I433d8adb2b1615ae05b2764e69904369a59542c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/280994
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>
I keep getting these confused and having to look at how the code
actually uses them.
Change-Id: I86baf22b76e7dddada6830df0fac241092f716bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/280993
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>
This CL moves the general deadcode-removal pass to before computing
Addrtaken, which allows variables to still be converted to SSA if
their address is only taken in unreachable code paths (e.g., the "&mp"
expression in the "if false" block in runtime/os_linux.go:newosproc).
This doesn't pass toolstash -cmp, because it allows SSA to better
optimize some code.
Change-Id: I43e54acc02fdcbad8eb6493283f355aa1ee0de84
Reviewed-on: https://go-review.googlesource.com/c/go/+/280992
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>
This CL fixes package initialization order by creating the init task
before the general deadcode-removal pass.
It also changes noder to emit zero-initialization assignments (i.e.,
OAS with nil RHS) for package-block variables, so that initOrder can
tell the variables still need initialization. To allow this, we need
to also extend the static-init code to recognize zero-initialization
assignments.
This doesn't pass toolstash -cmp, because it reorders some package
initialization routines.
Fixes#43444.
Change-Id: I0da7996a62c85e15e97ce965298127e075390a7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/280976
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>
More minor reshuffling of passes.
Passes toolstash -cmp.
Change-Id: I22633b3741f668fc5ee8579d7d610035ed57df1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/280975
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>
This commit splits up typecheck.Package and moves the code
elsewhere. The type-checking code is moved into noder, so that it can
eventually be interleaved with the noding process. The
non-type-checking code is moved back into package gc, so that it can
be incorporated into appropriate compiler backend phases.
While here, deadcode removal is moved into its own package.
Passes toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/typecheck
: Split into two functions.
sed -i -e '/Phase 6/i}\n\nfunc postTypecheck() {' typecheck.go
rf '
# Export needed identifiers.
mv deadcode Deadcode
mv loadsys InitRuntime
mv declareUniverse DeclareUniverse
mv dirtyAddrtaken DirtyAddrtaken
mv computeAddrtaken ComputeAddrtaken
mv incrementalAddrtaken IncrementalAddrtaken
# Move into new package.
mv Deadcode deadcodeslice deadcodeexpr deadcode.go
mv deadcode.go cmd/compile/internal/deadcode
# Move top-level type-checking code into noder.
# Move DeclVars there too, now that nothing else uses it.
mv DeclVars Package noder.go
mv noder.go cmd/compile/internal/noder
# Move non-type-checking code back into gc.
mv postTypecheck main.go
mv main.go cmd/compile/internal/gc
'
cd ../deadcode
rf '
# Destutter names.
mv Deadcode Func
mv deadcodeslice stmts
mv deadcodeexpr expr
'
cd ../noder
rf '
# Move functions up, next to their related code.
mv noder.go:/func Package/-1,$ \
noder.go:/makeSrcPosBase translates/-1
mv noder.go:/func DeclVars/-3,$ \
noder.go:/constState tracks/-1
'
cd ../gc
rf '
# Inline postTypecheck code back into gc.Main.
mv main.go:/func postTypecheck/+0,/AllImportedBodies/+1 \
main.go:/Build init task/-1
rm postTypecheck
'
Change-Id: Ie5e992ece4a42204cce6aa98dd6eb52112d098c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/280974
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>
Unused variables are a type-checking error, so they should be reported
during typecheck rather than walk.
One catch is that we only want to report unused-variable errors for
functions that type check successfully, but some errors are reported
during noding, so we don't have an easy way to detect that
currently. As an approximate solution, we simply check if we've
reported any errors yet.
Passes toolstash -cmp.
Change-Id: I9400bfc94312c71d0c908a491e85c16d62224c9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/280973
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>
copyExpr just calls copyExpr1 with "clear" is false, so make it return
*ir.Name directly instead of ir.Node
Passes toolstash -cmp.
Change-Id: I31ca1d88d9eaf8ac37517022f1c74285ffce07d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/280714
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>
Back to pre Russquake, Node.Nbody of OCALL* node is used to attach
variables which must be kept alive during that call.
Now after Russquake, we have CallExpr to represent a function call,
so use a dedicated field for those variables instead.
Passes toolstash -cmp.
Change-Id: I4f40ebefcc7c41cdcc4e29c7a6d8496a083b68f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/280733
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>
OTYPE and OMETHEXPR were missing from OpPrec. So add them with the
same precedences as OT{ARRAY,MAP,STRUCT,etc} and
ODOT{,METH,INTER,etc}, respectively. However, ODEREF (which is also
used for pointer types *T) has a lower precedence than other types, so
pointer types need to be specially handled to assign them their
correct, lower precedence.
Incidentally, this also improves the error messages in issue15055.go,
where we were adding unnecessary parentheses around the types in
conversion expressions.
Thanks to Cuong Manh Le for writing the test cases for #43428.
Fixes#43428.
Change-Id: I57e7979babe3ed9ef8a8b5a2a3745e3737dd785f
Reviewed-on: https://go-review.googlesource.com/c/go/+/280873
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>
It isn't necessary on darwin/arm64 (macOS).
It was probably leftover from the old code when darwin/arm64
meant iOS. The test passes on iOS builder. Apparently this is
not needed either. Remove.
Change-Id: I6fa0c55d6086325d4b722862c4fe6c30bcd6e6e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/280158
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Changelog
'make rearguard_tarballs' no longer generates a bad rearguard.zi,
fixing a 2020e bug.
No actual changes to timezones data. See
http://mm.icann.org/pipermail/tz-announce/2020-December/000064.html
Updates #22487
Change-Id: I78f7adba1c3c1d3489b0da870601117b9b8cb0d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/280455
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
The original Darwin/ARM port is gone. For ARM64, it works fine
without the flags on macOS/ARM64. Remove the flags.
Change-Id: I9cc00c49dd71376dd9c52abb78c2d8cec656b3db
Reviewed-on: https://go-review.googlesource.com/c/go/+/280157
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Somehow I missed that one. It works fine.
Change-Id: I0b1286bf1e6a8f40b9f3f114f49b3034079e0b85
Reviewed-on: https://go-review.googlesource.com/c/go/+/280156
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
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>
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>
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>
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>
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>
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>
A typo was made, which I noticed while looking through the recent master
commits.
Change-Id: Ieed5d6664a1f3ff5892d59abf194963b44ef0e55
Reviewed-on: https://go-review.googlesource.com/c/go/+/280454
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>