aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder
AgeCommit message (Collapse)Author
2021-09-24cmd/compile: move all usage of delayTransform out of helpers.goCuong Manh Le
So next CL will make delayTransform to become irgen's method, because the delay transform logic also depends on irgen.topFuncIsGeneric field. For #48609 Change-Id: I660ed19856bd06c3b6f4279a9184db96175dea2d Reviewed-on: https://go-review.googlesource.com/c/go/+/351854 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-09-24cmd/compile: fix case in dictPass where OMETHVALUE should become ODOTMETHDan Scales
When I separate out the dictionary transformations to dictPass, I missed duplicating a conditional that deals with OMETHVALUE nodes that are actually called. We create the OMETHVALUE when transforming bounds function reference (before we know whether that reference will be called), and we need to call transformDot() again to convert the OMETHVALUE to ODOTMETH if the reference is actually called (the usual case). Without this change, we leave the OMETHVALUE in, and extra *-fm are created and used unncessarily. Also, fixed a few places where we were missing ir.MarkFunc(), which sets the class of a function node properly. Change-Id: I6b02613039b16b507b44525faa2cd7031afb6982 Reviewed-on: https://go-review.googlesource.com/c/go/+/352069 Trust: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2021-09-22cmd/compile: break out constants for local and global dictionary prefixesDan Scales
Create constant LocalDictName for the pname/refix for dictionary parameters or local variables, and constant GlobalDictPrefix for the prefix for names of global dictionaries. I wanted to make sure these constants were set up as we add more reference to dictionaries for debugging, etc. Change-Id: Ide801f842383300a2699c96943ec06decaecc358 Reviewed-on: https://go-review.googlesource.com/c/go/+/351450 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> Reviewed-by: Than McIntosh <thanm@google.com>
2021-09-21cmd/compile/internal/types2: export Named.Orig as Named.OriginRobert Griesemer
This is a slightly adjusted port of CL 350996 from go/types to types2. Change-Id: I8f5902ecb20a4b4d2a5ef0d3641d857bc3a618e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/351170 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-21cmd/compile/internal/types2: instantiate methods when instantiating Named typesRobert Griesemer
This is a port of CL 349412 from go/types to types2 with minor adjustments for types2 names, plus CL 350143 (slightly simplified) to make sure we always get a new signature in instantiated methods, plus CL 350810 to take care of pointer receivers. It also contains adjustments to the compiler (provided by Dan Scales) make it work with the types2 changes. Change-Id: Ia683a3a8adba3c369701c411d786092f02e77efe Reviewed-on: https://go-review.googlesource.com/c/go/+/349998 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-20cmd/link: generate DIE for types referenced only through dictionariesAlessandro Arzilli
Generate debug_info entries for types that are only referenced through dictionaries. Change-Id: Ic36c2e6d9588ec6746793bb213c2dc0e17a8a850 Reviewed-on: https://go-review.googlesource.com/c/go/+/350532 Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Trust: Dan Scales <danscales@google.com> Trust: David Chase <drchase@google.com>
2021-09-20cmd/compile: delay all transforms for generic funcs/methodsDan Scales
This change cleans up the code, by just delaying all transforms on generic function methods/functions until stenciling time. That way, we don't have extra code to decide whether to delay, or an extra value for the typecheck flag. We are already doing all possible transforms at stencil time anyway, so no changes to the stenciling code. transform.go includes a change for one case where we check for shape rather than tparam, now that we only apply transforms to stenciled functions, not generic functions. This change is to allow CONVIFACE node to be correctly inserted (needed for dictionaries), even with this strange code that doesn't add the CONVIFACE node if the concrete type is NOT huge... Change-Id: I5f1e71fab11b53385902074915b3ad85f8e753fa Reviewed-on: https://go-review.googlesource.com/c/go/+/350736 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
2021-09-20cmd/compile: fix transform.AssignOp to deal with tricky caseDan Scales
When going to dictionary formats derived from the function instantiations, I had broken out noder.Assignop() to deal specially with shape types, but didn't quite get the tricky case right. We still need to allow conversion between shape types, but if the destination is an interface, we need to use CONVIFACE rather than CONVNOP. Fixes #48453. Change-Id: I8c4b39c2e628172ac34f493f1dd682cbac1e55ae Reviewed-on: https://go-review.googlesource.com/c/go/+/350949 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2021-09-17cmd/compile: delay transformAssign if lhs/rhs have typeparamDan Scales
This also requires that we sometimes delay transformSelect(), if the assignments in the Comm part of the select have not been transformed. Fixes #48137 Change-Id: I163aa1f999d1e63616280dca807561b12b2aa779 Reviewed-on: https://go-review.googlesource.com/c/go/+/347915 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-09-17cmd/compile/internal/noder: hide TestUnifiedCompare behind -cmp flagMatthew Dempsky
This test is fragile and is starting to impede others' work. This CL disables it until I have time to either find a solution for the issues or decide to just delete the test altogether. Change-Id: Icefabb6d3fbedec5d16536de78be4ca20d63133c Reviewed-on: https://go-review.googlesource.com/c/go/+/350729 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-09-16cmd/compile: fixing writebarrier.go for -G=3wdvxdr
This is caused by some nodes didn't carry the real line number. Noder1 wraps these node with ir.ParenExpr. To fix this issue, wraps this node like what noder1 does. Change-Id: I212cad09b93b8bf1a7adfad416d229d15711918a Reviewed-on: https://go-review.googlesource.com/c/go/+/349769 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Keith Randall <khr@golang.org>
2021-09-15cmd/compile: remove unneeded early transforms, with dictionary changeDan Scales
Now that we are computing the dictionary format on the instantiated functions, we can remove the early transformation code that was needed to create the implicit CONVIFACE nodes in the generic function. Change-Id: I1695484e7d59bccbfb757994f3e40e84288759a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/349614 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2021-09-15cmd/compile: switch to computing dict format on instantiated functionsDan Scales
Change to computing the dictionary form on each shape-instantiated function, rather than once on the underlying generic function/method. The problem with computing the dictionary format on the generic function is that we had to force early transformations to create all the needed/implicit CONVIFACE nodes, since many of these nodes cause the need for a dictionary entry. Also, the dictionary entries needed can different with different instantiations of the same generic function, especially depending on whether a type argument is a non-interface or interface type, or a instantiated type vs. a non-instantiated type. By computing the dictionary format on the instantiated function, we are scanning a function where all the transformations have been done to create implicit CONVFIFACE nodes, and we know the above relevant information about the type params (which are shapes). Much of the change is more mechanical changes from typeparams to shapes, and generic functions/info to instantiated functions/info. Some of the most important non-mechanical changes are: - Separated out the dictionary transformations to nodes into a separate dictPass, since we need to analyze instantiated functions after stenciling, but before the dictionary transformations. - Added type param index to shape types, since we need to be able distinguish type params of an instantiation which are different but happen to have the same shape. - Allow the type substituter to work with shapes again (since for the dictionary entries we need to substitute shape params to the concrete type args). - Support types.IdentityStrict() that does strict type comparison (no special case for shapes). This needed for type substitution, formatting and creating dictionaries, etc. We can maybe create better names for this function. - Add new information to instInfo to contain a mapping from the shape type params to their instantiated type bound. This is needed when doing the dictionary transformations related to type bounds. Change-Id: I1c3ca312c5384f318c4dd7d0858dba9766396ff6 Reviewed-on: https://go-review.googlesource.com/c/go/+/349613 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-09-15cmd/compile: emit DWARF info about dictionary entriesAlessandro Arzilli
When emitting the DIE of the instantiation of a generic function also emit one DW_TAG_typedef_type entry for each dictionary entry in use, referencing the shape type and having a custom attribute containing the index inside the dictionary. When emitting the DIE of variables that have an instantiated parametric type, instead of referencing the shape type directly go through the DW_TAG_typedef_type entry emitted for the dictionary entry describing the real type of the variable. Change-Id: Ia45d157ecd4c25e2b60300469e43bbb27a663582 Reviewed-on: https://go-review.googlesource.com/c/go/+/344929 Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Trust: Dan Scales <danscales@google.com> Trust: Jeremy Faller <jeremy@golang.org>
2021-09-09cmd/compile: fix implement for closure in a global assignmentkorzhao
If closure in a global assignment and has a method receiver. We should assign receiver as a global variable, not a local variable. Fixes #48225 Change-Id: I8f65dd6e8baf66a5eff24028d28ad0a594091add Reviewed-on: https://go-review.googlesource.com/c/go/+/348512 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
2021-09-09cmd/compile: fix case where init info of OAS node is droppedDan Scales
When an OAS node is converted to an OSELRECV2 node in tcSelect(), the possible DCL node in the Init field was being dropped, since a completely new node was being created and the Init field was not set. I don't expect n.Init() to be set for the ORECV case, but the code now deals with that too. Fixed bug in both tcSelect() and transformSelect(). Fixes #48289 Change-Id: I09918a70f7cbaa4aa9a17546169f908a8787df15 Reviewed-on: https://go-review.googlesource.com/c/go/+/348569 Trust: Dan Scales <danscales@google.com> 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> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-09-09go/types, types2: rename RParams -> RecvTypeParamsRobert Findley
To be consistent with CL 348376, spell out 'RecvTypeParams' in go/types and types2 API. Updates #47916 Change-Id: If8b3fd4274ccb944bd0ff04d7007e94e5fba61c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/348810 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-09-09cmd/compile: stenciled conversions might be NOPsKeith Randall
A generic conversion might be required for when converting T->interface{}. When stenciled with T=interface{}, then that conversion doesn't need to do anything. Fixes #48276 Change-Id: Ife65d01c99fbd0895cb7eec79df9e93e752b1fa5 Reviewed-on: https://go-review.googlesource.com/c/go/+/348736 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-09-09cmd/compile: fix unified IR panic when expanding nested inline functionCuong Manh Le
When reading body of inlining function, which has another inlined function in the body, the reader still add this inlined function to todoBodies, which it shouldn't because the inlined function was read already. To fix this, introduce new flag to signal that we are done construting all functions in todoBodies, thus the addBody shouldn't add anything to todoBodies then. Updates #48094 Change-Id: I45105dd518f0a7b69c6dcbaf23b957623f271203 Reviewed-on: https://go-review.googlesource.com/c/go/+/347529 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-09-09cmd/compile: fix wrong instantiated type for embedded receiverCuong Manh Le
In case of embedded field, if the receiver was fully instantiated, we must use its instantiated type, instead of passing the type params of the base receiver. Fixes #47797 Fixes #48253 Change-Id: I97613e7e669a72605137e82406f7bf5fbb629378 Reviewed-on: https://go-review.googlesource.com/c/go/+/348549 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-09-09cmd/compile: remove 'ext' fields from unified IR reader/writer typesMatthew Dempsky
This is a vestigial artifact of how I initially split apart the public and private data for objects. But now objects are split into more parts, and it's proven easier to just keep them as separate variables. So it's time to cleanup the initial public/private code to follow the same approach. Change-Id: I3976b19fb433cbe21d299d3799ec616f9e59561e Reviewed-on: https://go-review.googlesource.com/c/go/+/348412 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-09-09cmd/compile: simplify value coding for unified IRMatthew Dempsky
In indexed export, values are always exported along with their type and are encoded in a type-sensitive manner, because this matches how cmd/compile handled constants internally. However, go/types intentionally differs from this, decoupling type from value representation. As unified IR strives to be more go/types-centric, it makes sense to embrace this and make values a more first-class encoding. Change-Id: If21d849c4f610358bd776d5665469d180bcd5f6e Reviewed-on: https://go-review.googlesource.com/c/go/+/348014 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-09-09cmd/compile: extrapolate $GOROOT in unified IRMatthew Dempsky
This ensures that diagnostics for files within $GOROOT continue to be reported using their full filepath, rather than the abbreviated filepath. Notably, this is necessary for test/run.go, which has tests that expect to see the full filepath. Updates #48247. Change-Id: I440e2c6dd6109ca059d81cee49e476bba805d703 Reviewed-on: https://go-review.googlesource.com/c/go/+/348670 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-09-08go/types, types2: add Environment to ConfigRobert Griesemer
Port to types2 and adjust compiler accordingly. Change-Id: I2e72b151ef834977dca64cb2e62cedcac4e46062 Reviewed-on: https://go-review.googlesource.com/c/go/+/348578 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-09-08cmd/compile/internal/types2: spell out 'Type' in type parameter APIsRobert Griesemer
This is a port of CL 348376 with the necessary adjustments in the compiler. Change-Id: Ib11ee841b194746ff231ee493aa56bf9b3a4a67f Reviewed-on: https://go-review.googlesource.com/c/go/+/348577 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-08cmd/compile/internal/types2: move NewTypeParam off of CheckerRobert Griesemer
This is a port of CL 347561. A comment was corrected both in types2 and go/types, and the compiler adjusted for the updated NewTypeParameter function. Change-Id: I4381f0dd8e43228e1d037c5d997d421b7838f905 Reviewed-on: https://go-review.googlesource.com/c/go/+/348574 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-08cmd/compile/internal/types2: implement deduplication of instances using the ↵Robert Griesemer
Environment This is a port of CL 344390 with adjustments to names to make it work for types2. Change-Id: I05c33d9858f973adfbf48d8a1faaf377280f6985 Reviewed-on: https://go-review.googlesource.com/c/go/+/348572 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-07cmd/compile: add CONVIFACE nodes needed in generic code due to assignmentsDan Scales
Added new function earlyTransformAssign() to add needed CONVIFACE nodes due to assignments in generic functions. Fixes #48049 Change-Id: I7cd9cee6ecf34ed2ef0743d1b17645b9f520fa00 Reviewed-on: https://go-review.googlesource.com/c/go/+/347914 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-09-07cmd/compile: make sure imported instantiated types have their methods createdDan Scales
We should be putting a newly instantiated imported type in Instantiate/doInst onto the instTypeList, so its methods/dictionaries are instantiated. To do this, we needed a more general way to add a type to instTypeList, so add NeedInstType(), analogous to NeedRuntimeType(). This has the extra advantage that now all types created by the type substituter are added to instTypeList without any extra code, which was easy to forget. doInst() now correctly calls NeedInstType(). This is a bit aggressive, since a fully instantiated type in a generic function/method may never be used, if the generic method is never instantiated in the local package. But it should be fairly uncommon for a generic method to mention a fully instantiated type (but it does happen in this bug). Fixes both cases mentioned in the bug. Fixed #48185 Change-Id: I19b5012dfac17e306c8005f8595a648b0ab280d0 Reviewed-on: https://go-review.googlesource.com/c/go/+/347909 Trust: Dan Scales <danscales@google.com> Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2021-09-07cmd/compile: fix lazy loading in reader2Matthew Dempsky
Calling reader2.obj fully loads the referenced object, which is necessary in general; but for reading the package index, we just need to setup the name->index mapping. This CL adds this, so that lazy loading works as intended. Change-Id: Ie51d59e2247d99b46f9dc69fba7ce89e2584b7c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/348011 Trust: Matthew Dempsky <mdempsky@google.com> Trust: Cuong Manh Le <cuong.manhle.vn@gmail.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-09-07cmd/compile: make sure that the names created for instantiated type are the samekorzhao
Now we have two functions that create names for instantiated types. They are inconsistent when dealing with byte/rune type. This CL makes instTypeName2 reuse the code of typecheck.InstTypeName Fixes #48198 Change-Id: I4c216b532cba6618ef9b63fd0b76e8f1c0ed7a75 Reviewed-on: https://go-review.googlesource.com/c/go/+/347491 Reviewed-by: Dan Scales <danscales@google.com> Trust: Dan Scales <danscales@google.com> Trust: Keith Randall <khr@golang.org> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-09-06cmd/compile: fix delay transformation in *subster.node()korzhao
Add OCALL, OCALLFUNC, OCALLMETH, OCALLINTER, ODYNAMICDOTTYPE transformations to the CALL check switch statement. Fixes #48042 Change-Id: Ied93efd979c5b2c56b72fad26fccfd9f887361d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/345949 Trust: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Reviewed-by: Dan Scales <danscales@google.com>
2021-09-02cmd/compile: use types2.Unsafe to represent package unsafe in gcimportsCuong Manh Le
Followup todo in CL 346769. Change-Id: I6c870014523426d65d135da999f97a818a997237 Reviewed-on: https://go-review.googlesource.com/c/go/+/347270 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-09-02cmd/compile: allow objStub from unsafe packageCuong Manh Le
CL 346469 added support for unsafe.Sizeof and friends to operate on generic parameters for compiler importer/exporter. This CL adds support for unified IR. Updates #48094 Change-Id: I63af1a7c3478f59b03ecc23229ac2254d3457868 Reviewed-on: https://go-review.googlesource.com/c/go/+/346769 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: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-09-01cmd/compile: optimize unified IR handling of imported functionsMatthew Dempsky
This CL skips reading of imported function bodies except from the local package or for inlining. Previously, we wasted a bunch of CPU and memory by reading in normal function bodies for all imported functions and methods. Change-Id: I0b3df3f4a3e2819117dac11a1f9e4526288c14d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/347030 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-09-01cmd/compile: emit unified IR wrappers after inliningMatthew Dempsky
This CL delays unified IR's wrapper generation to after inlining. Change-Id: Idfe496663489d6b797a647eb17200c6322d0334a Reviewed-on: https://go-review.googlesource.com/c/go/+/347029 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-09-01cmd/compile: remove useless fcountLeonard Wang
Change-Id: Ibc23b43dc9a7fabb27d7991977b283459f3deae3 Reviewed-on: https://go-review.googlesource.com/c/go/+/333009 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-09-01cmd/compile: fix irgen mis-handling invalid function declarationCuong Manh Le
In -G=3 mode, irgen use its own generated IR, which is mis-handling of bodyless function and declared function with //go:noescape pragma. Fix this by adopting the same logic in noder.funcDecl, which minor change in linkname detection. Fixes #48097 Change-Id: Ibef921c1f75e071ca61685e0cb4543f2ee5efc7f Reviewed-on: https://go-review.googlesource.com/c/go/+/346470 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: Cherry Mui <cherryyz@google.com> Reviewed-by: Dan Scales <danscales@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-09-01cmd/compile: assign results of transformAssign back to source locationKeith Randall
Otherwise the modifications of transformAssign are dropped on the floor. Change-Id: Id40782564952ed53f9ade1dba4e85290c8522abc Reviewed-on: https://go-review.googlesource.com/c/go/+/346590 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>
2021-09-01cmd/compile: fix missing case for shape double-check functionDan Scales
Missing case types.TUNSAFEPTR in parameterizedBy(). Also realized there was the same missing case in the type substituter (*Tsubster).Typ(). Fixes #48103 Change-Id: If71f1a6ef80932f0e2120d4c18b39a30189fd8fe Reviewed-on: https://go-review.googlesource.com/c/go/+/346669 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
2021-08-31cmd/compile: fix handling of Defn field during stencilingDan Scales
When the Defn field of a name node is not an ONAME (for a closure variable), then it points to a body node of the same function/closure. Therefore, we should not attempt to substitute it at the time we are substituting the local variables. Instead, we remember a mapping from the Defn node to the nodes that reference it, and update the Defn fields of the copied name nodes at the time that we create the new copy of the Defn node. Added some comments to the Defn field of ir.Name. Moved the Defn (and Outer code, for consistency) from namelist() to localvar(), since Defn needs to updated for all local variables, not just those in a closure. Fixed case where .Defn was not being set properly in noder2 for type switches. Fixed another case where the Defn field had to be updated during transformSelect() because the Defn node was being completely changed to a new node. Fixed some spacing in typeswitch2.go Fixes #47676 Fixes #48016 Change-Id: Iae70dd76575f4a647c1db79e1eba9bbe44bfc226 Reviewed-on: https://go-review.googlesource.com/c/go/+/346290 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-08-31cmd/compile: make unified IR more selective about method wrappersMatthew Dempsky
This CL makes two changes to how unified IR emits method wrappers: 1. It no longer emits wrappers for defined types' underlying types. Previously, a declaration like `type T struct { U }` would emit wrappers for both `T` and `struct { U }`. Now they're only emitted for `T`. 2. It emits method value wrappers only when OMETHVALUE nodes are actually created, like how -G=0 works. Method values are relatively rare, aren't needed for runtime type descriptors (unlike method expression wrappers), and large projects end up spending a non-trivial amount of time compiling these unneeded wrappers. Change-Id: I21da97df3132ec12cc67debf62b5b2d282f481cf Reviewed-on: https://go-review.googlesource.com/c/go/+/346230 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-08-30cmd/compile: fix bug with Inferred targsDan Scales
We were using the type from the wrong Node (the partially filled-in FUNCINST) rather than the original function node - which is pointed to by the OFUNCINST)) to set the final fully-substituted type of the OFUNCINST. So fixed the node reference. Also, added check so we don't do any work at all if the OFUNCINST already has all type args filled in. Added few extra cases to the test file issue48030.go, to cover fully-specified type args, partially inferred type args, and fully inferred type args. Fixes #48030 Change-Id: If9e4f2e0514d68b9d241f30c423259133932b25b Reviewed-on: https://go-review.googlesource.com/c/go/+/346229 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-08-30cmd/compile: fix error when revcType is ptr in selectorExprkorzhao
Fixes #48056 Change-Id: I13ca4caadbabf02084f66ab28b4cf0c4a3705370 Reviewed-on: https://go-review.googlesource.com/c/go/+/346049 Reviewed-by: Dan Scales <danscales@google.com> Trust: Dan Scales <danscales@google.com> Trust: Keith Randall <khr@golang.org> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-08-27cmd/compile: use Type.OrigSym getter/setters [generated]Matthew Dempsky
Automated CL to rewrite existing code to use OrigSym getters and setters. Afterwards, we also unexported OrigSym, and then rename the getter to OrigSym. [git-generate] cd src/cmd/compile/internal : Workaround rf issue with types2 tests. rm types2/*_test.go rf ' ex ./noder ./typecheck { import "cmd/compile/internal/types" var s *types.Sym var t *types.Type t.OrigSym = s -> t.SetOrigSym(s) t.OrigSym -> t.OrigSym_() } ' cd types rf ' mv Type.OrigSym Type.origSym mv Type.OrigSym_ Type.OrigSym ' : Revert types2 hack. cd ../types2 git checkout HEAD^ . Change-Id: I8eb17098613b1575df56b8189b1615823071d3d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/345485 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-08-27cmd/compile: unexport Type.Width and Type.Align [generated]Matthew Dempsky
[git-generate] cd src/cmd/compile/internal : Workaround rf issue with types2 tests. rm types2/*_test.go : Rewrite uses. First a type-safe rewrite, : then a second pass to fix unnecessary conversions. rf ' ex ./abi ./escape ./gc ./liveness ./noder ./reflectdata ./ssa ./ssagen ./staticinit ./typebits ./typecheck ./walk { import "cmd/compile/internal/types" var t *types.Type t.Width -> t.Size() t.Align -> uint8(t.Alignment()) } ex ./abi ./escape ./gc ./liveness ./noder ./reflectdata ./ssa ./ssagen ./staticinit ./typebits ./typecheck ./walk { import "cmd/compile/internal/types" var t *types.Type int64(uint8(t.Alignment())) -> t.Alignment() } ' : Rename fields to lower case. ( cd types rf ' mv Type.Width Type.width mv Type.Align Type.align ' ) : Revert types2 changes. git checkout HEAD^ types2 Change-Id: I42091faece104c4ef619d9d4d50514fd48c8f029 Reviewed-on: https://go-review.googlesource.com/c/go/+/345480 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-08-27cmd/compile: fix stenciling of conversions between interfacesKeith Randall
Conversions need to allow nil through. We do that using a CONVIFACE instead of a DOTTYPE. Also reorganize how nonempty interfaces are handled. For nonempty to empty, a simple CONVIFACE suffices. For nonempty to nonempty, we need to call the runtime to get the new itab. Use the entry from the dictionary to identify the target interface type (if parameterized). Fixes #47925 Change-Id: I4ffeed964318bb3e270b06f558e6ab9c5bfc7188 Reviewed-on: https://go-review.googlesource.com/c/go/+/344830 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>
2021-08-27cmd/compile: delay fillinMethods to deal with mutually-recursive typesDan Scales
We need to delay fillinMethods until we get to a top-level type, so we know all the TFORW types have been filled in, and we can do the substitutions required by fillinMethods. Fixes #47710 Change-Id: I298de7e7753ed31a2c2b1ff04f35177a8afc7a66 Reviewed-on: https://go-review.googlesource.com/c/go/+/345149 Trust: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2021-08-27cmd/compile: add types.RecalcSizeMatthew Dempsky
This is the only case where Align is assigned outside of package types. Rather than adding a SetAlign method, adding a RecalcSize function is a bit more descriptive. Change-Id: I1b3c01ebd0e41183665baa63c926592865bbbd0b Reviewed-on: https://go-review.googlesource.com/c/go/+/345479 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-08-26cmd/compile: move types init code into package typesMatthew Dempsky
This moves the package types setup code from package typecheck into package types itself. This is a prereq for making types.Type more opaque, because some unit tests depend on being able to init the basic universal types. A few notable details of this CL: 1. Creating the builtin types requires being able to create the ir.Name/ir.OTYPE that represents it, but package types can't depend on package ir. So we add a callback function to handle creating the ir.Name. 2. This CL moves ir.Pkgs.Unsafe to types.UnsafePkg. Package unsafe is part of the language, not like the other ir.Pkgs packages that are purely implementation details. 3. This CL also moves typecheck.FakeRecv to types.FakeRecv, addressing an outstanding TODO. Change-Id: I64de04ce82fbcd1bb59f547e2eea3cda52d89429 Reviewed-on: https://go-review.googlesource.com/c/go/+/345474 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>