aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/inline
AgeCommit message (Collapse)Author
2021-07-04[dev.typeparams] cmd/compile: set Func.ClosureCalled in escape analysisMatthew Dempsky
The Func.ClosureCalled flag is an optimization used by escape analysis to detect closures that were directly called, so we know we have visibility of the result flows. It's not needed by any other phases of the compiler, so we might as well calculate it within escape analysis too. This saves some trouble during IR construction and trying to maintain the ClosureCalled flag through inlining and copying. Passes toolstash -cmp. Change-Id: Ic53cecb7ac439745c0dfba2cd202b9cc40f1e47c Reviewed-on: https://go-review.googlesource.com/c/go/+/332691 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Trust: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-07-03[dev.typeparams] cmd/compile: flatten OINLCALL in walkMatthew Dempsky
Inlining replaces inlined calls with OINLCALL nodes, and then somewhat clumsily tries to rewrite these in place without messing up order-of-evaluation rules. But handling these rules cleanly is much easier to do during order, and escape analysis is the only major pass between inlining and order. It's simpler to teach escape analysis how to analyze OINLCALL nodes than to try to hide them from escape analysis. Does not pass toolstash -cmp, but seems to just be line number changes. Change-Id: I1986cea39793e3e1ed5e887ba29d46364c6c532e Reviewed-on: https://go-review.googlesource.com/c/go/+/332649 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Matthew Dempsky <mdempsky@google.com>
2021-06-27[dev.typeparams] cmd/compile: rename OCALLPART to OMETHVALUECuong Manh Le
Go spec call them "method values", not "partial calls". Note that we use "OMETHVALUE" (as opposed to "OMETHODVALUE") to be consistent with "OMETHEXPR". Change-Id: I1efd985d4b567a1b4b20aeb603eb82db579edbd5 Reviewed-on: https://go-review.googlesource.com/c/go/+/330837 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-26[dev.typeparams] cmd/compile: rewrite method calls during typecheckCuong Manh Le
CL 330671 move rewriting method call to method expression to escape analysis. This CL move the rewriting up further, into typecheck. It helps simplify the code for dowstream passes, as they now only have to deal with OCALLFUNC. There're two notes: - For -G=3, we can't rewrite d.M() where d is an instantiated receiver in transformCall, but let irgen.stencil to rewrite it. - Escape analysis still have to check for rewriting method calls, as the devirtualization pass can still generate OCALLMETH. Does not pass toolstash, since when the export data now contains method expression calls instead of method calls. Change-Id: I77465ef04d50dc4efedddca7eb55b3fc9483db0e Reviewed-on: https://go-review.googlesource.com/c/go/+/330831 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-12[dev.typeparams] cmd/compile: simplify NewClosureFuncMatthew Dempsky
I initially made NewClosureFunc take an "outerfn *Func" parameter because I was planning on having it handle closure naming, until remembering that naming needs to wait until typecheck for noder. We don't actually need the *Func yet, just to know whether it's non-nil. So change the parameter to a bool, which simplifies callers a little. Change-Id: Ie83ee4a1ed0571ac6d3879ffd8474c6c3c1a9ff9 Reviewed-on: https://go-review.googlesource.com/c/go/+/327450 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>
2021-06-12[dev.typeparams] cmd/compile: refactor closure constructionMatthew Dempsky
typecheck.tcClosure is complicated with many code flows because all of its callers setup the closure funcs in slightly different ways. E.g., it's non-obvious who's responsible for setting the underlying func's Sym or adding it to target.Decls, or how to write new code that constructs a closure without interfering with existing code. This CL refactors everything to use three common functions in package ir: NewClosureFunc (which handle creating the Func, Name, and ClosureExpr and wiring them together), NameClosure (which generates and assigns its unique Sym), and UseClosure (which handles adding the Func to target.Decls). Most IR builders can actually name the closure right away, but the legacy noder+typecheck path may not yet know the name of the enclosing function. In particular, for methods declared with aliased receiver parameters, we need to wait until after typechecking top-level declarations to know the method's true name. So they're left anonymous until typecheck. UseClosure does relatively little work today, but it serves as a useful spot to check that the code setting up closures got it right. It may also eventually serve as an optimization point for early lifting of trivial closures, which may or may not ultimately be beneficial. Change-Id: I7da1e93c70d268f575b12d6aaeb2336eb910a6f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/327051 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>
2021-06-05[dev.typeparams] cmd/compile: refactor export writingMatthew Dempsky
This CL reorganizes export writing in preparation for unified IR: 1. It moves dumpexport into noder as noder.WriteExports so that it can be extended to include unified IR's export data. 2. Adds an "extensions" flag to typecheck.WriteExports to control whether the compiler-only extension data (e.g., function bodies and linker symbol info) is included in the exports. 3. It moves the gc.exporter type into typecheck and renames it to "crawler". The type originated as the implementation of the (pre-iexport) binary exporter, but since the removal of bexport it's been relegated to simply crawling the exported functions/bodies graph to identify which inline bodies need to be included. 4. It changes inline.Inline_Flood into the method crawler.markInlBody. Inline_Flood doesn't actually have anything to do with the rest of inlining; its current name and location are just historical quirks. Passes toolstash -cmp. Change-Id: I6445e2de9d3ce500a3aded5a8e20b09f46d23dbc Reviewed-on: https://go-review.googlesource.com/c/go/+/325212 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Trust: Matthew Dempsky <mdempsky@google.com> Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-05-27[dev.typeparams] cmd/compile/internal/inline: refactor mkinlcallMatthew Dempsky
This CL refactors mkinlcall by extracting the core InlinedCallExpr construction code into a new "oldInline" function, and adds a new "NewInline" hook point that can be overriden with a new inliner implementation that only needs to worry about the details of constructing the InlinedCallExpr. It also moves the delayretvars optimization check into CanInline, so it's performed just once per inlinable function rather than once for each inlined call. Finally, it skips printing the function body about to be inlined (and updates the couple of regress tests that expected this output). We already report the inline body as it was saved, and this diagnostic is only applicable to the current inliner, which clones existing function body instances. In the unified IR inliner, we'll directly construct inline bodies from the serialized representation. Change-Id: Ibdbe617da83c07665dcbda402cc8d4d4431dde2f Reviewed-on: https://go-review.googlesource.com/c/go/+/323290 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>
2021-05-26[dev.typeparams] cmd/compile: inlining tweaks for toolstashMatthew Dempsky
This CL makes to minor changes motivated by making it easier to make large-scale changes to the inliner while satisfying toolstash -cmp: 1. When creating inlining variables, make sure to preserve the AutoTemp flag. This is necessary so that temporary variables introduced by rewriting f(g()) calls during typecheck stay autotemp after inlining and are (correctly) omitted from DWARF debugging information. 2. When sorting variables for stack frame layout, use a stable sort. This ensures that layout is insensitive to whether deadcode elimination happens before or after inlining. Change-Id: I672e752a873c7e16749b9873fd6573607e074309 Reviewed-on: https://go-review.googlesource.com/c/go/+/323011 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>
2021-05-26[dev.typeparams] cmd/compile: simplify inlining variadic callsMatthew Dempsky
We already have and use FixVariadicCall to normalize non-dotted calls to variadic functions elsewhere in the compiler to simplify rewriting of function calls. This CL updates inl.go to use it too. A couple tests need to be updated to (correctly) expect diagnostics about "... argument" instead of a slice literal. This is because inl.go previously failed to set Implicit on the slice literal node. Change-Id: I76bd79b95ae1f16e3b26ff7e9e1c468f538fd1f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/323009 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>
2021-05-25[dev.typeparams] all: merge master (f22ec51) into dev.typeparamsMatthew Dempsky
Merge List: + 2021-05-25 f22ec51deb doc: add Go 1.17 release note about inlining functions with closures + 2021-05-25 8b462d7567 cmd/go: add a -compat flag to 'go mod tidy' + 2021-05-24 c89f1224a5 net: verify results from Lookup* are valid domain names + 2021-05-24 08a8fa9c47 misc/wasm: ensure correct stack pointer in catch clauses + 2021-05-24 32b73ae180 cmd/go: align checks of module path during initialization. + 2021-05-24 15d9d4a009 cmd/go: add tests illustrating what happens when Go 1.16 is used in a Go 1.17 main module + 2021-05-24 873401df5b cmd/compile: ensure equal functions don't do unaligned loads + 2021-05-24 b83610699a cmd/compile: record regabi status in DW_AT_producer + 2021-05-24 a22e317220 cmd/compile: always include underlying type for map types + 2021-05-24 4356e7e85f runtime: account for spill slots in Windows callback compilation + 2021-05-24 52d7033ff6 cmd/go/internal/modload: set the default GoVersion in a single location + 2021-05-24 05819bc104 cmd/go/internal/modcmd: factor out a type for flags whose arguments are Go versions + 2021-05-22 cca23a7373 cmd/compile: revert CL/316890 + 2021-05-21 f87194cbd7 doc/go1.17: document changes to net/http package + 2021-05-21 217f5dd496 doc: document additional atomic.Value methods + 2021-05-21 3c656445f1 cmd/go: in TestScript/mod_replace, download an explicit module path + 2021-05-21 76b2d6afed os: document that StartProcess puts files into blocking mode + 2021-05-21 e4d7525c3e cmd/dist: display first class port status in json output + 2021-05-21 4fb10b2118 cmd/go: in 'go mod download' without args, don't save module zip sums + 2021-05-21 4fda54ce3f doc/go1.17: document database/sql changes for Go 1.17 + 2021-05-21 8876b9bd6a doc/go1.17: document io/fs changes for Go 1.17 + 2021-05-21 5fee772c87 doc/go1.17: document archive/zip changes for Go 1.17 + 2021-05-21 3148694f60 cmd/go: remove warning from module deprecation notice printing + 2021-05-21 7e63c8b765 runtime: wait for Go runtime to initialize in Windows signal test + 2021-05-21 831573cd21 io/fs: added an example for io/fs.WalkDir + 2021-05-20 baa934d26d cmd: go get golang.org/x/tools/analysis@49064d23 && go mod vendor + 2021-05-20 7c692cc7ea doc/go1.17: document changes to os package + 2021-05-20 ce9a3b79d5 crypto/x509: add new FreeBSD 12.2+ trusted certificate folder + 2021-05-20 f8be906d74 test: re-enable test on riscv64 now that it supports external linking + 2021-05-20 def5360541 doc/go1.17: add release notes for OpenBSD ports + 2021-05-20 ef1f52cc38 doc/go1.17: add release note for windows/arm64 port + 2021-05-20 bb7495a46d doc/go1.17: document new math constants + 2021-05-20 f07e4dae3c syscall: document NewCallback and NewCallbackCDecl limitations + 2021-05-20 a8d85918b6 misc/cgo/testplugin: skip TestIssue25756pie on darwin/arm64 builder + 2021-05-19 6c1c055d1e cmd/internal/moddeps: use filepath.SkipDir only on directories + 2021-05-19 658b5e66ec net: return nil UDPAddr from ReadFromUDP + 2021-05-19 15a374d5c1 test: check portable error message on issue46234.go + 2021-05-18 eeadce2d87 go/build/constraint: fix parsing of "// +build" (with no args) + 2021-05-18 6d2ef2ef2a cmd/compile: don't emit inltree for closure within body of inlined func + 2021-05-18 048cb4ceee crypto/x509: remove duplicate import Change-Id: Ib0442e3555493805f2aa1df26dfd6898df989a37
2021-05-24[dev.typeparams] cmd/compile: fix case where we were copying a raw NodeDan Scales
Replace the raw Node copy with the creation of a new node, and the copying of the needed flags and fields. Change-Id: I636bf228ba28c0d5dc25f8366d82379d86ecd731 Reviewed-on: https://go-review.googlesource.com/c/go/+/322189 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Trust: Dan Scales <danscales@google.com>
2021-05-18cmd/compile: don't emit inltree for closure within body of inlined funcThan McIntosh
When inlining functions with closures, ensure that we don't mark the body of the closure with a src.Pos marker that reflects the inline, since this will result in the generation of an inltree table for the closure itself (as opposed to the routine that the func-with-closure was inlined into). Fixes #46234. Change-Id: I348296de6504fc4745d99adab436640f50be299a Reviewed-on: https://go-review.googlesource.com/c/go/+/320913 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Than McIntosh <thanm@google.com>
2021-05-07cmd/compile: improving the documentation of various fields and functionsDan Scales
This is only changes to comments, so should be fine to go into 1.17. Change-Id: I01e28dc76b03fb3ca846d976f8ac84bc2acb2ea2 Reviewed-on: https://go-review.googlesource.com/c/go/+/318009 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-05-05cmd/compile: do not substitute OGOTO inside a closure when inliningCuong Manh Le
The inlsubst already does the same thing for OLABEL, so we must do the same thing for OGOTO. Otherwise, new inlined OGOTO node will be associated with non-existed label. Fixes #45947 Change-Id: I40eef095f57fd3438c38a0b5d9751d5d7ebf759e Reviewed-on: https://go-review.googlesource.com/c/go/+/316931 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Dan Scales <danscales@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
2021-04-26cmd/compile: workaround inlining of closures with type switchesMatthew Dempsky
Within clovar, n.Defn can also be *ir.TypeSwitchGuard. The proper fix here would be to populate m.Defn and have it filled in too, but we already leave it nil in inlvar. So for consistency, this CL does the same in clovar too. Eventually inl.go should be rewritten to fully respect IR invariants. Fixes #45743. Change-Id: I8b38e5d8b2329ad242de97670f2141f713954d28 Reviewed-on: https://go-review.googlesource.com/c/go/+/313289 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Trust: Dan Scales <danscales@google.com> Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-04-23cmd/compile: set correct Defn for inlined varsCuong Manh Le
Currently, when copying definition node of an inlined var, we do not update var Defn field to point to new copied node. That causes all inlined vars point to the same Defn, and ir.StaticValue can not find inlined var in the lhs of its definition. clovar creates new ONAME node for local variables or params of closure inside inlined function, by copying most of the old node fields. So the new Node.Defn is not modified, its lhs still refer to old node instead of new one. To fix this, we need to do two things: - In subst.clovar, set a dummy Defn node for inlvar - During subst.node, when seeing OAS/OAS2 nodes, after substituting, we check if any node in lhs has the dummy Defn, then set it to the current OAS/OAS2 node. Fixes #45606 Change-Id: Ib517b753a7643756dcd61d36deae60f1a0fc53c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/312630 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-14cmd/compile: set types properly for imported funcs with closuresDan Scales
For the new export/import of node types, we were just missing setting the types of the closure variables (which have the same types as the captured variables) and the OCLOSURE node itself (which has the same type as the Func node). Re-enabled inlining of functions with closures. Change-Id: I687149b061f3ffeec3244ff02dc6e946659077a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/308974 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2021-04-10cmd/compile: include typecheck information in export/importKeith Randall
Include type information on exported function bodies, so that the importer does not have to re-typecheck the body. This involves including type information in the encoded output, as well as avoiding some of the opcode rewriting and other changes that the old exporter did assuming there would be a re-typechecking pass. This CL could be considered a cleanup, but is more important than that because it is an enabling change for generics. Without this CL, we'd have to upgrade the current typechecker to understand generics. With this CL, the current typechecker can mostly go away in favor of the types2 typechecker. For now, inlining of functions that contain closures is turned off. We will hopefully resolve this before freeze. Object files are only 0.07% bigger. Change-Id: I85c9da09f66bfdc910dc3e26abb2613a1831634d Reviewed-on: https://go-review.googlesource.com/c/go/+/301291 Trust: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Reviewed-by: Dan Scales <danscales@google.com>
2021-04-09cmd/compile: don't set Ntype in noder2 anymoreDan Scales
Now that we are no longer calling the old typechecker at all during the noder2 pass, we don't need to create and set an Ntype node ((which is just a node representation of the type which we already know) for the Name and Closure nodes. This should reduce memory usage a bit for -G=3. Change-Id: I6b1345007ce067a89ee64955a53f25645c303f4d Reviewed-on: https://go-review.googlesource.com/c/go/+/308909 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-02-26cmd/compile: deal with closures in generic functions and instantiated ↵Dan Scales
function values - Deal with closures in generic functions by fixing the stenciling code - Deal with instantiated function values (instantiated generic functions that are not immediately called) during stenciling. This requires changing the OFUNCINST node to an ONAME node for the appropriately instantiated function. We do this in a second pass, since this is uncommon, but requires editing the tree at multiple levels. - Check global assignments (as well as functions) for generic function instantiations. - Fix a bug in (*subst).typ where a generic type in a generic function may definitely not use all the type args of the function, so we need to translate the rparams of the type based on the tparams/targs of the function. - Added new test combine.go that tests out closures in generic functions and instantiated function values. - Added one new variant to the settable test. - Enabling inlining functions with closures for -G=3. (For now, set Ntype on closures in -G=3 mode to keep compatibility with later parts of compiler, and allow inlining of functions with closures.) Change-Id: Iea63d5704c322e42e2f750a83adc8b44f911d4ec Reviewed-on: https://go-review.googlesource.com/c/go/+/296269 Reviewed-by: Robert Griesemer <gri@golang.org> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Dan Scales <danscales@google.com>
2021-02-26cmd/compile: fix missing descend in Addrtaken for closures.Dan Scales
ComputeAddrtaken needs to descend into closures, now that imported bodies can include closures. The bug was that we weren't properly setting Addrtaken for a variable inside a closure inside a function that we were importing. For now, still disable inlining of functions with closures for -G mode. I'll enable it in a later change -- there are just a few fixes related to the fact that we don't need to set Ntype for closure functions. Added a test derived from the cilium repro in the issue. Fixes #44370 Change-Id: Ida2a403636bf8740b471b3ad68b5474951811e19 Reviewed-on: https://go-review.googlesource.com/c/go/+/296649 Run-TryBot: Dan Scales <danscales@google.com> Trust: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-02-25cmd/compile: declare inlined result params early for empty returnsMatthew Dempsky
The code for delayed declaration of inlined result parameters only handles non-empty return statements. This is generally okay, because we already early declare if there are any (non-blank) named result parameters. But if a user writes a function with only blank result parameters and with exactly one return statement, which is empty, then they could end up hitting the dreaded "Value live at entry" ICE. This CL fixes the issue by ensuring we always early declare inlined result parameters if there are any empty return statements. Fixes #44355. Change-Id: I315f3853be436452883b1ce31da1bdffdf24d506 Reviewed-on: https://go-review.googlesource.com/c/go/+/293293 TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: David Chase <drchase@google.com>
2021-02-24cmd/compile: disable inlining functions with closures for nowDan Scales
Added a flag '-d=inlfuncswithclosures=1' to allow inlining functions with closures, and change the default to off for now, until #44370 is fixed. Updates #44370. Change-Id: Ic17723aa5c091d91f5f5004d8b63ec7125257acf Reviewed-on: https://go-review.googlesource.com/c/go/+/296049 Run-TryBot: Dan Scales <danscales@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Dan Scales <danscales@google.com>
2021-02-24cmd/compile: reduce inline cost of OCONVOPEgon Elbre
OCONVOP doesn't have effect in the compiled code so, it can be safely excluded from inline cost calculation. Also make sequence ODEREF OCONVNOP* OADDR cost 1. This is rather common conversion, such as *(*uint32)(unsafe.Pointer(&x)). Fixes #42788 Change-Id: I5001f7e89d985c198b6405694cdd5b819cf3f47a Reviewed-on: https://go-review.googlesource.com/c/go/+/281232 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Elias Naur <mail@eliasnaur.com>
2021-01-28[dev.typeparams] cmd/compile: start adding info needed for typeparams in ↵Dan Scales
types & ir We are focusing on generic functions first, and ignoring type lists for now. The signatures of types.NewSignature() and ir.NewCallExpr() changed (with addition of type args/params). Change-Id: I57480be3d1f65690b2946e15dd74929bf42873f2 Reviewed-on: https://go-review.googlesource.com/c/go/+/287416 Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com>
2021-01-24[dev.typeparams] all: merge dev.regabi (063c72f) into dev.typeparamsMatthew Dempsky
Eager re-sync-branch to keep Git history reasonably accurate, since Git lacks a better way of encoding partial merges like CL 286172. Conflicts: - src/cmd/compile/internal/inline/inl.go - src/cmd/compile/internal/noder/import.go - src/cmd/compile/internal/noder/noder.go Merge List: + 2021-01-25 063c72f06d [dev.regabi] cmd/compile: backport changes from dev.typeparams (9456804) + 2021-01-23 d05d6fab32 [dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet for SSA 2 + 2021-01-23 48badc5fa8 [dev.regabi] cmd/compile: fix escape analysis problem with closures + 2021-01-23 51e1819a8d [dev.regabi] cmd/compile: scan body of closure in tooHairy to check for disallowed nodes Change-Id: I48c0435f7aaf56f4aec26518a7459e9d95a51e9c
2021-01-22[dev.typeparams] all: merge dev.regabi (7e0a81d) into dev.typeparamsMatthew Dempsky
As with CL 285875, this required resolving some conflicts around handling of //go:embed directives. Still further work is needed to reject uses of //go:embed in files that don't import "embed", so this is left as a TODO. (When this code was written for dev.typeparams, we were still leaning towards not requiring the "embed" import.) Also, the recent support for inlining closures (CL 283112) interacts poorly with -G=3 mode. There are some known issues with this code already (#43818), so for now this CL disables inlining of closures when in -G=3 mode with a TODO to revisit this once closure inlining is working fully. Conflicts: - src/cmd/compile/internal/noder/noder.go - src/cmd/compile/internal/typecheck/dcl.go - src/cmd/compile/internal/typecheck/func.go - test/run.go Merge List: + 2021-01-22 7e0a81d280 [dev.regabi] all: merge master (dab3e5a) into dev.regabi + 2021-01-22 dab3e5affe runtime: switch runtime to libc for openbsd/amd64 + 2021-01-22 a1b53d85da cmd/go: add documentation for test and xtest fields output by go list + 2021-01-22 b268b60774 runtime: remove pthread_kill/pthread_self for openbsd + 2021-01-22 ec4051763d runtime: fix typo in mgcscavenge.go + 2021-01-22 7ece3a7b17 net/http: fix flaky TestDisableKeepAliveUpgrade + 2021-01-22 50cba0506f time: clarify Timer.Reset behavior on AfterFunc Timers + 2021-01-22 cf10e69f17 doc/go1.16: mention net/http.Transport.GetProxyConnectHeader + 2021-01-22 ec1b945265 doc/go1.16: mention path/filepath.WalkDir + 2021-01-22 11def3d40b doc/go1.16: mention syscall.AllThreadsSyscall + 2021-01-21 07b0235609 doc/go1.16: add notes about package-specific fs.FS changes + 2021-01-21 e2b4f1fea5 doc/go1.16: minor formatting fix + 2021-01-21 9f43a9e07b doc/go1.16: mention new debug/elf constants + 2021-01-21 3c2f11ba5b cmd/go: overwrite program name with full path + 2021-01-21 953d1feca9 all: introduce and use internal/execabs + 2021-01-21 b186e4d70d cmd/go: add test case for cgo CC setting + 2021-01-21 5a8a2265fb cmd/cgo: report exec errors a bit more clearly + 2021-01-21 46e2e2e9d9 cmd/go: pass resolved CC, GCCGO to cgo + 2021-01-21 3d40895e36 runtime: switch openbsd/arm64 to pthreads + 2021-01-21 d95ca91380 crypto/elliptic: fix P-224 field reduction + 2021-01-21 d7e71c01ad [dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet for dwarf + 2021-01-21 5248f59a22 [dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet for SSA + 2021-01-21 970d8b6cb2 [dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet in inlining + 2021-01-21 68a4664475 [dev.regabi] cmd/compile: remove tempAssigns in walkCall1 + 2021-01-21 fd9a391cdd [dev.regabi] cmd/compile: remove CallExpr.Rargs + 2021-01-21 19a6db6b63 [dev.regabi] cmd/compile: make sure mkcall* passed non-nil init + 2021-01-21 9f036844db [dev.regabi] cmd/compile: use ir.DoChildren directly in inlining + 2021-01-21 213c3905e9 [dev.regabi] cmd/compile: use node walked flag to prevent double walk for walkSelect + 2021-01-20 1760d736f6 [dev.regabi] cmd/compile: exporting, importing, and inlining functions with OCLOSURE + 2021-01-20 ecf4ebf100 cmd/internal/moddeps: check content of all modules in GOROOT + 2021-01-20 92cb157cf3 [dev.regabi] cmd/compile: late expansion of return values + 2021-01-20 d2d155d1ae runtime: don't adjust timer pp field in timerWaiting status + 2021-01-20 803d18fc6c cmd/go: set Incomplete field on go list output if no files match embed + 2021-01-20 6e243ce71d cmd/go: have go mod vendor copy embedded files in subdirs + 2021-01-20 be28e5abc5 cmd/go: fix mod_get_fallback test + 2021-01-20 928bda4f4a runtime: convert openbsd/amd64 locking to libc + 2021-01-19 824f2d635c cmd/go: allow go fmt to complete when embedded file is missing + 2021-01-19 0575e35e50 cmd/compile: require 'go 1.16' go.mod line for //go:embed + 2021-01-19 9423d50d53 [dev.regabi] cmd/compile: use '%q' for printing rune values less than 128 + 2021-01-19 ccb2e90688 cmd/link: exit before Asmb2 if error + 2021-01-19 ca5774a5a5 embed: treat uninitialized FS as empty + 2021-01-19 d047c91a6c cmd/link,runtime: switch openbsd/amd64 to pthreads + 2021-01-19 61debffd97 runtime: factor out usesLibcall + 2021-01-19 9fed39d281 runtime: factor out mStackIsSystemAllocated + 2021-01-19 a2f825c542 [dev.regabi] cmd/compile: directly create go.map and go.track symbols + 2021-01-19 4a4212c0e5 [dev.regabi] cmd/compile: refactor Linksym creation + 2021-01-19 4f5c603c0f [dev.regabi] cmd/compile: cleanup callTargetLSym + 2021-01-18 dbab079835 runtime: free Windows event handles after last lock is dropped + 2021-01-18 5a8fbb0d2d os: do not close syscall.Stdin in TestReadStdin + 2021-01-18 422f38fb6c [dev.regabi] cmd/compile: move stack objects to liveness + 2021-01-18 6113db0bb4 [dev.regabi] cmd/compile: convert OPANIC argument to interface{} during typecheck + 2021-01-18 4c835f9169 [dev.regabi] cmd/compile: use LinksymOffsetExpr in TypePtr/ItabAddr + 2021-01-18 0ffa1ead6e [dev.regabi] cmd/compile: use *obj.LSym instead of *ir.Name for staticdata functions + 2021-01-17 7e0fa38aad [dev.regabi] cmd/compile: remove unneeded packages from ir.Pkgs + 2021-01-17 99a5db11ac [dev.regabi] cmd/compile: use LinksymOffsetExpr in walkConvInterface + 2021-01-17 87845d14f9 [dev.regabi] cmd/compile: add ir.TailCallStmt + 2021-01-17 e3027c6828 [dev.regabi] cmd/compile: fix linux-amd64-noopt builder + 2021-01-17 59ff93fe64 [dev.regabi] cmd/compile: rename NameOffsetExpr to LinksymOffsetExpr + 2021-01-17 82b9cae700 [dev.regabi] cmd/compile: change ir.NameOffsetExpr to use *obj.LSym instead of *Name + 2021-01-17 88956fc4b1 [dev.regabi] cmd/compile: stop analyze NameOffsetExpr.Name_ in escape analysis + 2021-01-17 7ce2a8383d [dev.regabi] cmd/compile: simplify stack temp initialization + 2021-01-17 ba0e8a92fa [dev.regabi] cmd/compile: refactor temp construction in walk + 2021-01-17 78e5aabcdb [dev.regabi] cmd/compile: replace Node.HasCall with walk.mayCall + 2021-01-16 6de9423445 [dev.regabi] cmd/compile: cleanup OAS2FUNC ordering + 2021-01-16 a956a0e909 [dev.regabi] cmd/compile, runtime: fix up comments/error messages from recent renames + 2021-01-16 ab3b67abfd [dev.regabi] cmd/compile: remove ONEWOBJ + 2021-01-16 c9b1445ac8 [dev.regabi] cmd/compile: remove TypeAssertExpr {Src,Dst}Type fields + 2021-01-15 682a1d2176 runtime: detect errors in DuplicateHandle + 2021-01-15 9f83418b83 cmd/link: remove GOROOT write in TestBuildForTvOS + 2021-01-15 ec9470162f cmd/compile: allow embed into any string or byte slice type + 2021-01-15 54198b04db cmd/compile: disallow embed of var inside func + 2021-01-15 b386c735e7 cmd/go: fix go generate docs + 2021-01-15 bb5075a525 syscall: remove RtlGenRandom and move it into internal/syscall + 2021-01-15 1deae0b597 os: invoke processKiller synchronously in testKillProcess + 2021-01-15 03a875137f [dev.regabi] cmd/compile: unexport reflectdata.WriteType + 2021-01-15 14537e6e54 [dev.regabi] cmd/compile: move stkobj symbol generation to SSA + 2021-01-15 ab523fc510 [dev.regabi] cmd/compile: don't promote Byval CaptureVars if Addrtaken + 2021-01-15 ff196c3e84 crypto/x509: update iOS bundled roots to version 55188.40.9 + 2021-01-15 b7a698c73f [dev.regabi] test: disable test on windows because expected contains path separators. + 2021-01-15 4be7af23f9 [dev.regabi] cmd/compile: fix ICE during ir.Dump + 2021-01-14 e125ccd10e cmd/go: in 'go mod edit', validate versions given to -retract and -exclude + 2021-01-14 eb330020dc cmd/dist, cmd/go: pass -arch for C compilation on Darwin + 2021-01-14 84e8a06f62 cmd/cgo: remove unnecessary space in cgo export header + 2021-01-14 0c86b999c3 cmd/test2json: document passing -test.paniconexit0 + 2021-01-14 9135795891 cmd/go/internal/load: report positions for embed errors + 2021-01-14 35b9c66601 [dev.regabi] cmd/compile,cmd/link: additional code review suggestions for CL 270863 + 2021-01-14 d9b79e53bb cmd/compile: fix wrong complement for arm64 floating-point comparisons + 2021-01-14 c73232d08f cmd/go/internal/load: refactor setErrorPos to PackageError.setPos + 2021-01-14 6aa28d3e06 go/build: report positions for go:embed directives + 2021-01-14 9734fd482d [dev.regabi] cmd/compile: use node walked flag to prevent double walk for walkSwitch + 2021-01-14 f97983249a [dev.regabi] cmd/compile: move more PAUTOHEAP to SSA construction + 2021-01-14 4476300425 [dev.regabi] cmd/compile: use byte for CallExpr.Use + 2021-01-14 5a5ab24689 [dev.regabi] cmd/compile: do not rely on CallExpr.Rargs for detect already walked calls + 2021-01-14 983ac4b086 [dev.regabi] cmd/compile: fix ICE when initializing blank vars + 2021-01-13 7eb31d999c cmd/go: add hints to more missing sum error messages + 2021-01-13 d6d4673728 [dev.regabi] cmd/compile: fix GOEXPERIMENT=regabi builder + 2021-01-13 c41b999ad4 [dev.regabi] cmd/compile: refactor abiutils from "gc" into new "abi" + 2021-01-13 861707a8c8 [dev.regabi] cmd/compile: added limited //go:registerparams pragma for new ABI dev + 2021-01-13 c1370e918f [dev.regabi] cmd/compile: add code to support register ABI spills around morestack calls + 2021-01-13 2abd24f3b7 [dev.regabi] test: make run.go error messages slightly more informative + 2021-01-13 9a19481acb [dev.regabi] cmd/compile: make ordering for InvertFlags more stable + 2021-01-12 ba76567bc2 cmd/go/internal/modload: delete unused *mvsReqs.next method + 2021-01-12 665def2c11 encoding/asn1: document unmarshaling behavior for IMPLICIT string fields + 2021-01-11 81ea89adf3 cmd/go: fix non-script staleness checks interacting badly with GOFLAGS + 2021-01-11 759309029f doc: update editors.html for Go 1.16 + 2021-01-11 c3b4c7093a cmd/internal/objfile: don't require runtime.symtab symbol for XCOFF + 2021-01-08 59bfc18e34 cmd/go: add hint to read 'go help vcs' to GOVCS errors + 2021-01-08 cd6f3a54e4 cmd/go: revise 'go help' documentation for modules + 2021-01-08 6192b98751 cmd/go: make hints in error messages more consistent + 2021-01-08 25886cf4bd cmd/go: preserve sums for indirect deps fetched by 'go mod download' + 2021-01-08 6250833911 runtime/metrics: mark histogram metrics as cumulative + 2021-01-08 8f6a9acbb3 runtime/metrics: remove unused StopTheWorld Description field + 2021-01-08 6598c65646 cmd/compile: fix exponential-time init-cycle reporting + 2021-01-08 fefad1dc85 test: fix timeout code for invoking compiler + 2021-01-08 6728118e0a cmd/go: pass signals forward during "go tool" + 2021-01-08 e65c543f3c go/build/constraint: add parser for build tag constraint expressions + 2021-01-08 0c5afc4fb7 testing/fstest,os: clarify racy behavior of TestFS + 2021-01-08 32afcc9436 runtime/metrics: change unit on *-by-size metrics to match bucket unit + 2021-01-08 c6513bca5a io/fs: minor corrections to Glob doc + 2021-01-08 304f769ffc cmd/compile: don't short-circuit copies whose source is volatile + 2021-01-08 ae97717133 runtime,runtime/metrics: use explicit histogram boundaries + 2021-01-08 a9ccd2d795 go/build: skip string literal while findEmbed + 2021-01-08 d92f8add32 archive/tar: fix typo in comment + 2021-01-08 cab1202183 cmd/link: accept extra blocks in TestFallocate + 2021-01-08 ee4d32249b io/fs: minor corrections to Glob release date + 2021-01-08 54bd1ccce2 cmd: update to latest golang.org/x/tools + 2021-01-07 9ec21a8f34 Revert "reflect: support multiple keys in struct tags" + 2021-01-07 091414b5b7 io/fs: correct WalkDirFunc documentation + 2021-01-07 9b55088d6b doc/go1.16: add release note for disallowing non-ASCII import paths + 2021-01-07 fa90aaca7d cmd/compile: fix late expand_calls leaf type for OpStructSelect/OpArraySelect + 2021-01-07 7cee66d4cb cmd/go: add documentation for Embed fields in go list output + 2021-01-07 e60cffa4ca html/template: attach functions to namespace + 2021-01-07 6da2d3b7d7 cmd/link: fix typo in asm.go + 2021-01-07 df81a15819 runtime: check mips64 VDSO clock_gettime return code + 2021-01-06 4787e906cf crypto/x509: rollback new CertificateRequest fields + 2021-01-06 c9658bee93 cmd/go: make module suggestion more friendly + 2021-01-06 4c668b25c6 runtime/metrics: fix panic message for Float64Histogram + 2021-01-06 d2131704a6 net/http/httputil: fix deadlock in DumpRequestOut + 2021-01-05 3e1e13ce6d cmd/go: set cfg.BuildMod to "readonly" by default with no module root + 2021-01-05 0b0d004983 cmd/go: pass embedcfg to gccgo if supported + 2021-01-05 1b85e7c057 cmd/go: don't scan gccgo standard library packages for imports + 2021-01-05 6b37b15d95 runtime: don't take allglock in tracebackothers + 2021-01-04 9eef49cfa6 math/rand: fix typo in comment + 2021-01-04 b01fb2af9e testing/fstest: fix typo in error message + 2021-01-01 3dd5867605 doc: 2021 is the Year of the Gopher + 2020-12-31 95ce805d14 io/fs: remove darwin/arm64 special condition + 2020-12-30 20d0991b86 lib/time, time/tzdata: update tzdata to 2020f + 2020-12-30 ed301733bb misc/cgo/testcarchive: remove special flags for Darwin/ARM + 2020-12-30 0ae2e032f2 misc/cgo/test: enable TestCrossPackageTests on darwin/arm64 + 2020-12-29 780b4de16b misc/ios: fix wording for command line instructions + 2020-12-29 b4a71c95d2 doc/go1.16: reference misc/ios/README for how to build iOS programs + 2020-12-29 f83e0f6616 misc/ios: add to README how to build ios executables + 2020-12-28 4fd9455882 io/fs: fix typo in comment Change-Id: If24bb93f1e1e7deb1d92ba223c85940ab93b2732
2021-01-23[dev.regabi] cmd/compile: scan body of closure in tooHairy to check for ↵Dan Scales
disallowed nodes Several of the bugs in #43818 are because we were not scanning the body of an possibly inlined closure in tooHairy(). I think this scanning got lost in the rebase past some of the ir changes. This fixes the issue related to the SELRECV2 and the bug reported from cuonglm. There is at least one other bug related to escape analysis which I'll fix in another change. Change-Id: I8f38cd12a287881155403bbabbc540ed5fc2248e Reviewed-on: https://go-review.googlesource.com/c/go/+/285676 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-21[dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet in inliningBaokun Lee
As CL 282212 mentioned, we should clean all map[*ir.Name]bool with ir.NameSet. Passes toolstash -cmp. Updates #43819 Change-Id: I1ce5d2055f88539f807dc021cd8e3941b425bc4e Reviewed-on: https://go-review.googlesource.com/c/go/+/284897 Run-TryBot: Baokun Lee <bk@golangcn.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Baokun Lee <bk@golangcn.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-21[dev.regabi] cmd/compile: use ir.DoChildren directly in inliningBaokun Lee
Passes toolstash -cmp. Change-Id: Ie35e8163fa0e61ed9e1b259929c8cbe82ee5301e Reviewed-on: https://go-review.googlesource.com/c/go/+/282212 Run-TryBot: Baokun Lee <bk@golangcn.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Baokun Lee <bk@golangcn.org>
2021-01-20[dev.regabi] cmd/compile: exporting, importing, and inlining functions with ↵Dan Scales
OCLOSURE I have exporting, importing, and inlining of functions with closures working in all cases (issue #28727). all.bash runs successfully without errors. Approach: - Write out the Func type, Dcls, ClosureVars, and Body when exporting an OCLOSURE. - When importing an OCLOSURE, read in the type, dcls, closure vars, and body, and then do roughly equivalent code to (*noder).funcLit - During inlining of a closure within inlined function, create new nodes for all params and local variables (including closure variables), so they can have a new Curfn and some other field values. Must substitute not only on the Nbody of the closure, but also the Type, Cvars, and Dcl fields. Fixes #28727 Change-Id: I4da1e2567c3fa31a5121afbe82dc4e5ee32b3170 Reviewed-on: https://go-review.googlesource.com/c/go/+/283112 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Trust: Dan Scales <danscales@google.com>
2021-01-18[dev.regabi] cmd/compile: convert OPANIC argument to interface{} during ↵Matthew Dempsky
typecheck Currently, typecheck leaves arguments to OPANIC as their original type. This CL changes it to insert implicit OCONVIFACE operations to convert arguments to `interface{}` like how any other function call would be handled. No immediate benefits, other than getting to remove a tiny bit of special-case logic in order.go's handling of OPANICs. Instead, the generic code path for handling OCONVIFACE is used, if necessary. Longer term, this should be marginally helpful for #43753, as it reduces the number of cases where we need values to be addressable for runtime calls. However, this does require adding some hacks to appease existing tests: 1. We need yet another kludge in inline budgeting, to ensure that reflect.flag.mustBe stays inlinable for cmd/compile/internal/test's TestIntendedInlining. 2. Since the OCONVIFACE expressions are now being introduced during typecheck, they're now visible to escape analysis. So expressions like "panic(1)" are now seen as "panic(interface{}(1))", and escape analysis warns that the "interface{}(1)" escapes to the heap. These have always escaped to heap, just now we're accurately reporting about it. (Also, unfortunately fmt.go hides implicit conversions by default in diagnostics messages, so instead of reporting "interface{}(1) escapes to heap", it actually reports "1 escapes to heap", which is confusing. However, this confusing messaging also isn't new.) Change-Id: Icedf60e1d2e464e219441b8d1233a313770272af Reviewed-on: https://go-review.googlesource.com/c/go/+/284412 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Matthew Dempsky <mdempsky@google.com>
2021-01-17[dev.regabi] cmd/compile: add ir.TailCallStmtMatthew Dempsky
This CL splits out ORETJMP as a new TailCallStmt node, separate from the other BranchStmt nodes. In doing so, this allows us to change it from identifying a function by *types.Sym to identifying one by directly pointing to the *ir.Func. While here, also rename the operation to OTAILCALL. Passes toolstash -cmp. Change-Id: I273e6ea5d92bf3005ae02fb59b3240a190a6cf1b Reviewed-on: https://go-review.googlesource.com/c/go/+/284227 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>
2021-01-16[dev.regabi] cmd/compile, runtime: fix up comments/error messages from ↵Dan Scales
recent renames Went in a semi-automated way through the clearest renames of functions, and updated comments and error messages where it made sense. Change-Id: Ied8e152b562b705da7f52f715991a77dab60da35 Reviewed-on: https://go-review.googlesource.com/c/go/+/284216 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-14[dev.regabi] cmd/compile: move more PAUTOHEAP to SSA constructionMatthew Dempsky
This CL moves almost all PAUTOHEAP handling code to SSA construction. Instead of changing Names to PAUTOHEAP, escape analysis now only sets n.Esc() to ir.EscHeap, and SSA handles creating the "&x" pseudo-variables and associating them via Heapaddr. This CL also gets rid of n.Stackcopy, which was used to distinguish the heap copy of a parameter used within a function from the stack copy used in the function calling convention. In practice, this is always obvious from context: liveness and function prologue/epilogue want to know about the stack copies, and everywhere else wants the heap copy. Hopefully moving all parameter/result handling into SSA helps with making the register ABI stuff easier. Also, the only remaining uses of PAUTOHEAP are now for closure variables, so I intend to rename it to PCLOSUREVAR or get rid of those altogether too. But this CL is already big and scary enough. Change-Id: Ief5ef6205041b9d0ee445314310c0c5a98187e77 Reviewed-on: https://go-review.googlesource.com/c/go/+/283233 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com>
2021-01-04[dev.regabi] cmd/compile: remove Name.Class_ accessorsMatthew Dempsky
These aren't part of the Node interface anymore, so no need to keep them around. Passes toolstash -cmp. [git-generate] cd src/cmd/compile/internal/ir : Fix one off case that causes trouble for rf. sed -i -e 's/n.SetClass(ir.PAUTO)/n.Class_ = ir.PAUTO/' ../ssa/export_test.go pkgs=$(go list . ../...) rf ' ex '"$(echo $pkgs)"' { var n *Name var c Class n.Class() -> n.Class_ n.SetClass(c) -> n.Class_ = c } rm Name.Class rm Name.SetClass mv Name.Class_ Name.Class ' Change-Id: Ifb304bf4691a8c455456aabd8aa77178d4a49500 Reviewed-on: https://go-review.googlesource.com/c/go/+/281294 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>
2021-01-03[dev.regabi] cmd/compile: remove a couple CloneName callsMatthew Dempsky
In inl.go, that code path is unused, since we added ir.BasicLit to represent unnamed OLITERALs. In race.go, rather than cloning ir.RegFP, we can just create it from scratch again. Passes toolstash -cmp (incl. w/ -race). Change-Id: I8e063e4898d2acf056ceca5bc03df6b40a14eca9 Reviewed-on: https://go-review.googlesource.com/c/go/+/281192 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>
2021-01-02[dev.regabi] cmd/compile: remove Nodes.Set [generated]Matthew Dempsky
Just "=". It's cleaner. Passes toolstash -cmp. [git-generate] cd src/cmd/compile/internal/ir pkgs=$(go list . ../...) rf ' ex '"$(echo $pkgs)"' { var l Nodes var p *Nodes p.Set(l) -> *p = l } ex '"$(echo $pkgs)"' { var n InitNode var l Nodes *n.PtrInit() = l -> n.SetInit(l) } rm Nodes.Set ' Change-Id: Ic97219792243667146a02776553942ae1189ff7d Reviewed-on: https://go-review.googlesource.com/c/go/+/281002 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>
2021-01-02[dev.regabi] cmd/compile: remove {Ptr,Set}Init from Node interfaceMatthew Dempsky
This CL separates out PtrInit and SetInit into a new InitNode extension interface, and adds a new TakeInit helper function for taking and clearing the Init list (if any) from a Node. This allows removing miniNode.SetInit and miniNode.PtrInit, which in turn allow getting rid of immutableEmptyNodes, and will allow simplification of the Nodes API. It would be nice to get rid of the default Init method too, but there's way more code that expects to be able to call that at the moment, so that'll have to wait. Passes toolstash -cmp. Change-Id: Ia8c18fab9555b774376f7f43eeecfde4f07b5946 Reviewed-on: https://go-review.googlesource.com/c/go/+/281001 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>
2021-01-01[dev.regabi] cmd/compile: refactor redundant type conversion [generated]Cuong Manh Le
Passes toolstash -cmp. [git-generate] cd src/cmd/compile rf ' ex . '"$(printf '%s\n' ./internal/* | paste -sd' ')"' { type T interface{} var t T strict t t.(T) -> t } ' cd internal/ir go generate Change-Id: I492d50390e724a7216c3cd8b49d4aaf7d0c335da Reviewed-on: https://go-review.googlesource.com/c/go/+/280716 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>
2021-01-01[dev.regabi] cmd/compile: use *ir.Name where possible in inl.goCuong Manh Le
Passes toolstash -cmp. Change-Id: Ic99a5189ad0fca37bccb0e4b4d13793adc4f8fd8 Reviewed-on: https://go-review.googlesource.com/c/go/+/280715 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>
2021-01-01[dev.regabi] cmd/compile: simplify inlining of closuresMatthew Dempsky
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>
2020-12-30[dev.regabi] cmd/compile: change ir.DoChildren to use bool result typeMatthew Dempsky
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[dev.regabi] cmd/compile: use *ir.Name for Decl.XCuong Manh Le
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-29[dev.regabi] cmd/compile: move new addrtaken bit back to the old nameKeith Randall
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[dev.regabi] cmd/compile: remove original addrtaken bitKeith Randall
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[dev.regabi] cmd/compile: separate out address taken computation from ↵Keith Randall
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[dev.regabi] cmd/compile: rewrite to use linksym helpers [generated]Matthew Dempsky
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[dev.regabi] cmd/compile: merge {Selector,CallPart,Method}ExprMatthew Dempsky
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>