aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/reader.go
AgeCommit message (Collapse)Author
2022-08-10cmd/compile/internal/noder: prune unified IR's dictionary logicMatthew Dempsky
Unified IR uses static dictionaries for some itabs and function/method expressions, and they're roughly the right idea. But at the same time, they're actually somewhat brittle and I need to reorganize some ideas anyway to get shaped-based stenciling working. So this CL just rips them out entirely. Note: the code for emitting runtime dictionaries with *runtime._type symbols is still present, and continues to demonstrate that basic runtime dictionary handling is working. Change-Id: I44eb1c7974fb397909ad5db12987659e7505c2ad Reviewed-on: https://go-review.googlesource.com/c/go/+/421819 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-10cmd/compile/internal/noder: explicitly handle separate selectorsMatthew Dempsky
This CL separates out the handling of selector expressions for field values, method values, and method expressions. Again part of refactoring to make it possible to access runtime dictionaries where needed. No behavioral change; just duplicating and then streamlining the existing code paths. Change-Id: I53b2a344f4bdba2c9f37ef370dc9a091a3941021 Reviewed-on: https://go-review.googlesource.com/c/go/+/421818 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com>
2022-08-10cmd/compile/internal/noder: explicitly handle function instantiationsMatthew Dempsky
This CL changes unified IR to explicitly handle function instantiations within expression handling, rather than leaving it to the underlying object reading logic. Change-Id: I009a56013fbe9fbc4dabf80eea98993d34af4272 Reviewed-on: https://go-review.googlesource.com/c/go/+/421817 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: David Chase <drchase@google.com>
2022-08-09cmd/compile: do not write implicit conversion for append in Unified IRCuong Manh Le
Same as CL 418475, but for Unified IR. Updates #53888 Fixes #54337 Change-Id: I31d5a7af04d8e3902ed25db85009d46ea4c38dbe Reviewed-on: https://go-review.googlesource.com/c/go/+/422040 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Than McIntosh <thanm@google.com>
2022-08-08cmd/compile: treat constants to type parameter conversion as non-constant in ↵Cuong Manh Le
Unified IR Fixes #54307 Change-Id: Idcbdb3b1cf7c7fd147cc079659f29a9b5d17e6e0 Reviewed-on: https://go-review.googlesource.com/c/go/+/421874 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-08-03[dev.unified] cmd/compile: start using runtime dictionariesMatthew Dempsky
This CL switches unified IR to start using runtime dictionaries, rather than pure stenciling. In particular, for each instantiated function `F[T]`, it now: 1. Generates a global variable `F[T]-dict` of type `[N]uintptr`, with all of the `*runtime._type` values needed by `F[T]`. 2. Generates a function `F[T]-shaped`, with an extra `.dict *[N]uintptr` parameter and indexing into that parameter for derived types. (N.B., this function is not yet actually using shape types.) 3. Changes `F[T]` to instead be a wrapper function that calls `F[T]-shaped` passing `&F[T]-dict` as the `.dict` parameter. This is done in one pass to make sure the overall wiring is all working (especially, function literals and inlining). Subsequent CLs will write more information into `F[T]-dict` and update `F[T]-shaped` to use it instead of relying on `T`-derived information itself. Once that's done, `F[T]-shaped` can be changed to `F[shapify(T)]` (e.g., `F[go.shape.int]`) and deduplicated. Change-Id: I0e802a4d9934794e01a6bfc367820af893335155 Reviewed-on: https://go-review.googlesource.com/c/go/+/420416 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com>
2022-07-28[dev.unified] cmd/compile: implement simple inline body pruning heuristicMatthew Dempsky
An important optimization in the existing export data format is the pruning of unreachable inline bodies. That is, when re-exporting transitively imported types, omitting the inline bodies for methods that can't actually be needed due to importing that package. The existing logic (implemented in typecheck/crawler.go) is fairly sophisticated, but also relies on actually expanding inline bodies in the process, which is undesirable. However, including all inline bodies is also prohibitive for testing GOEXPERIMENT=unified against very large Go code bases that impose size limits on build action inputs. As a short-term solution, this CL implements a simple heuristic for GOEXPERIMENT=unified: include the inline bodies for all locally-declared functions/methods, and for any imported functions/methods that were inlined into this package. Change-Id: I686964a0cd9262b77d3d5587f89cfbcfe8b2e521 Reviewed-on: https://go-review.googlesource.com/c/go/+/419675 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2022-07-28[dev.unified] cmd/compile: allow inlining to fail gracefullyMatthew Dempsky
Change-Id: I20c7df52d110fb88eb22d57bdad9264d0c5e22fe Reviewed-on: https://go-review.googlesource.com/c/go/+/419674 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-28[dev.unified] cmd/compile: extract nil handling from exprTypeMatthew Dempsky
Type switches are the only context where exprType was used and `nilOK` was true. It'll simplify subsequent dictionary work somewhat if exprType doesn't need to worry about `nil`, so extract this logic and move it into switchStmt instead. Change-Id: I3d810f465173f5bb2e2dee7bbc7843fff6a62ee5 Reviewed-on: https://go-review.googlesource.com/c/go/+/419474 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2022-07-28[dev.unified] cmd/compile: write iface conversion RTTI into unified IRMatthew Dempsky
This CL changes convRTTI into a serialization method too, like the previous CL's rtype method. And again, currently this just builds on the existing type serialization logic, but will eventually be changed to use dictionary lookups where appropriate. Change-Id: I551aef8ade24b08dc6206f06ace86d91e665f5c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/419457 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2022-07-28[dev.unified] cmd/compile: write RTTI into unified IR export dataMatthew Dempsky
This CL adds `rtype` methods for unified IR for writing/reading types that need to have their *runtime._type value available. For now, this just builds on the existing type writing/reading mechanics and calling reflectdata.TypePtrAt; but longer term, reading of derived types can be changed to use dictionary lookups instead. Change-Id: I6f803b84546fa7df2877a8a3bcbf2623e4b03449 Reviewed-on: https://go-review.googlesource.com/c/go/+/419456 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com>
2022-07-25[dev.unified] cmd/compile: add method expressions to dictionariesMatthew Dempsky
This CL changes method expressions that use derived-type receiver parameters to use dictionary lookups. Change-Id: Iacd09b6d77a2d3000438ec8bc9b5af2a0b068aa7 Reviewed-on: https://go-review.googlesource.com/c/go/+/419455 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-25[dev.unified] cmd/compile: remove obsolete RTTI wiringMatthew Dempsky
Comparisons between interface-typed and non-interface-typed expressions no longer happen within Unified IR since CL 415577, so this code path is no longer needed. Change-Id: I075dfd1e6c34799f32766ed052eab0710bc6cbd5 Reviewed-on: https://go-review.googlesource.com/c/go/+/419454 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-19[dev.unified] cmd/compile/internal/noder: simplify mixed tag/case RTTI wiringMatthew Dempsky
The previous CL largely removed the need for worrying about mixed tag/case comparisons in switch statements by ensuring they're always converted to a common type, except for one annoying case: switch statements with an implicit `true` tag, and case values of interface type (which must be empty interface, because `bool`'s method set is empty). It would be simpler to have writer.go desugar the implicit `true` itself, because we already handle explicit `true` correctly. But the existing code already works fine, and I don't want to add further complexity to writer.go until dictionaries and stenciling is done. Change-Id: Ia8d44c425b1be7fc578cd570d15a7560fe9d2674 Reviewed-on: https://go-review.googlesource.com/c/go/+/418102 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2022-07-19[dev.unified] cmd/compile/internal/noder: explicit nil handlingMatthew Dempsky
Currently, uses of "nil" are handling as references to cmd/compile's own untyped "nil" object, and then we rely on implicitly converting that to its appropriate type. But there are cases where this can subtly go wrong (e.g., the switch test case added in the previous CL). Instead, explicitly handling "nil" expressions so that we can construct them directly with the appropriate type, as computed already by types2. Change-Id: I587f044f60f24e87525dde6d7dad6c58f14478de Reviewed-on: https://go-review.googlesource.com/c/go/+/418100 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2022-07-19[dev.unified] cmd/compile/internal/noder: preserve RTTI for select statementsMatthew Dempsky
In a select statement, `case i = <-c: ...` may require an implicit conversion of the received value to i's type, but walk does not expect a conversion here. Instead, typecheck actually discards the conversion (resulting in ill-typed IR), and then relies on it being reinserted later when walk desugars the assignment. However, that might lose the explicit RTTI operands we've set for conversions to interface type, so explicitly introduce a temporary variable and rewrite as `case tmp := <-c: i = tmp; ...`, which is semantically equivalent and allows the `i = tmp` assignment to maintain the explicit RTTI without confusing the rest of the compiler frontend. Change-Id: Ie6c4dc9b19437e83970cd3ce83420813b8a47dc4 Reviewed-on: https://go-review.googlesource.com/c/go/+/418098 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2022-07-19[dev.unified] cmd/compile/internal/noder: wire RTTI for implicit conversionsMatthew Dempsky
This CL updates Unified IR to set the TypeWord and SrcRType fields on interface conversions, which will be necessary for dictionary support shortly. Change-Id: I9486b417f514ba4ec2ee8036194aa9ae3ad0ad93 Reviewed-on: https://go-review.googlesource.com/c/go/+/415575 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-19[dev.unified] cmd/compile/internal/noder: prefer *At functionsMatthew Dempsky
Unified IR tries to avoid depending on base.Pos, so we should prefer explicit position arguments wherever possible. Change-Id: I7163b1b8c5244fe7c2a7989e6a3f459a21a23e81 Reviewed-on: https://go-review.googlesource.com/c/go/+/418096 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-12internal/pkgbits: change EnableSync into a dynamic knobMatthew Dempsky
Rather than requiring users to recompile the compiler and all tools to enable/disable sync markers, this CL adds a flag word into the Unified IR file format to allow indicating whether they're enabled or not. This in turn requires bumping the file format version. Thanks to drchase@ for benchmarks showing this isn't as expensive as I feared it would be. Change-Id: I99afa0ee0b6ef5f30ed8ca840805ff9fd46b1857 Reviewed-on: https://go-review.googlesource.com/c/go/+/417097 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-30[dev.unified] cmd/compile/internal/noder: implicit conversions for ↵Matthew Dempsky
multi-valued expressions This CL changes GOEXPERIMENT=unified to insert implicit conversions for multi-valued expressions. Unfortunately, IR doesn't have strong, first-class support for multi-valued expressions, so this CL takes the approach of spilling them to temporary variables, which can then be implicitly converted. This is the same approach taken by walk, but doing it this early does introduce some minor complications: 1. For select case clauses with comma-ok assignments (e.g., `case x, ok := <-ch:`), the compiler middle end wants to see the OAS2RECV assignment is the CommClause.Comm statement. So when constructing select statements, we need to massage this around a little. 2. The extra temporary variables and assignments skew the existing inlining heuristics. As mentioned, the temporaries/assignments will eventually be added (and often optimized away again) anyway, but now they're visible to the inliner. So this CL also kludges the inlining heuristics in this case to keep things comparable. Change-Id: I3e3ea756ad92472ebe28bae3963be61ed7684a75 Reviewed-on: https://go-review.googlesource.com/c/go/+/415244 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-30[dev.unified] cmd/compile/internal/noder: refactor N:1 expression handlingMatthew Dempsky
Pull all multi-value expression handling logic into a new multiExpr helper method. Change-Id: I78ec2dfc523abcfa3368a1064df7045aade8e468 Reviewed-on: https://go-review.googlesource.com/c/go/+/415243 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2022-06-27[dev.unified] cmd/compile: drop package height from Unified IR importerCuong Manh Le
CL 410342 removed package height, but still needs to keep writing out 0 for iexport for compatibility with existing importers. With Unified IR, we don't have to, so get rid of the package height completely. Change-Id: I84a285cbaddd7bb0833d45a24a6818231b4d2b71 Reviewed-on: https://go-review.googlesource.com/c/go/+/411014 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-06-23[dev.unified] cmd/compile/internal/noder: start writing implicit conversionsMatthew Dempsky
This CL adds support for implicit conversions to the unified IR export data format, and starts inserting them in a few low-hanging places (send statements, index expressions). Subsequentl CLs will handle the remaining trickier cases. Change-Id: Iaea9d1c5df8432b61bd82578ab2ef02adaf26367 Reviewed-on: https://go-review.googlesource.com/c/go/+/413396 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-23[dev.unified] cmd/compile: special case f(g()) calls in Unified IRMatthew Dempsky
For f(g()) calls where g() is multi-valued, we may need to insert implicit conversions to convert g()'s result values to f()'s parameter types. This CL refactors code slightly so this will be easier to handle. Change-Id: I3a432220dcb62daecf9a66030e8fa1f097e95f95 Reviewed-on: https://go-review.googlesource.com/c/go/+/413362 Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2022-06-23[dev.unified] cmd/compile: plumb rtype through OSWITCH/OCASE clausesMatthew Dempsky
For (value) switch statements, we may generate OEQ comparisons between values of interface and concrete type, which in turn may require access to the concrete type's RType. To plumb this through, this CL adds CaseClause.RTypes to hold the rtype values, updates the GOEXPERIMENT=unified frontend to set it, and updates walk to plumb rtypes through into generated OEQ nodes. Change-Id: I6f1de2a1167ce54f5770147498a0a591efb3f012 Reviewed-on: https://go-review.googlesource.com/c/go/+/413361 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-23[dev.unified] cmd/compile: plumb rtype through for OMAPLITMatthew Dempsky
OMAPLIT gets lowered into a bunch of OINDEXMAP operations, which in general may require a *runtime._type argument. This CL adds CompLitExpr.RType, updates the GOEXPERIMENT=unified frontend to start setting it, and updates walk to propagate it through to any generated OINDEXMAP operations. Change-Id: I278e7e8e615ea6d01f65a5eba6d6fc8e00045735 Reviewed-on: https://go-review.googlesource.com/c/go/+/413360 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-23[dev.unified] cmd/compile: start setting RType fields for Unified IRMatthew Dempsky
This CL switches the GOEXPERIMENT=unified frontend to set RType fields in the simpler cases, and to make it fatal if they're missing. Subsequent CLs will handle the remaining more complex cases (e.g., expressions from later desugaring, and implicit conversions to interface type). Change-Id: If6257dcb3916905afd9b8371ea64b85f108ebbfb Reviewed-on: https://go-review.googlesource.com/c/go/+/413359 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com>
2022-06-14[dev.unified] cmd/compile: more Unified IR docs and reviewMatthew Dempsky
This adds more documentation throughout the core Unified IR logic and removes their UNREVIEWED notices. Updates #48194. Change-Id: Iddd30edaee1c6ea8a05a5a7e013480e02be00d29 Reviewed-on: https://go-review.googlesource.com/c/go/+/411917 Auto-Submit: 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> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-09[dev.unified] cmd/compile/internal/noder: stop handling type expressions as ↵Matthew Dempsky
expressions There are two places currently where we rely on type expressions as generic expressions: the first argument to "make" and "new", and the selectable operand within a method expression. This CL makes that code responsible for handling the type expressions directly. Longer term, this will be relevant to appropriately handling derived types, because it will provide additional context about how the derived type is to be used. Change-Id: I9d7dcf9d32dada032ff411cd103b9df413c298a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/410101 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-09[dev.unified] cmd/compile: set base.Pos when process assignDef in Unified IRCuong Manh Le
CL 410343 changes Unified IR to visit LHS before RHS/X in assign/for statement. Thus, it needs to set base.Pos before processing assignee expression, so invalid type can be reported with correct position. Updates #53058 Change-Id: Ic9f60cbf35c8bd71cb391e806396572c37811af7 Reviewed-on: https://go-review.googlesource.com/c/go/+/410794 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-09[dev.unified] cmd/compile: fix unified IR don't report type size too large errorCuong Manh Le
For error reported during type size calculation, base.Pos needs to be set, otherwise, the compiler will treat them as the same error and only report once. Old typechecker and irgen all set base.Pos before processing types, this CL do the same thing for unified IR. Updates #53058 Change-Id: I686984ffe4aca3e8b14d2103018c8d3c7d71fb02 Reviewed-on: https://go-review.googlesource.com/c/go/+/410345 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2022-06-07[dev.unified] cmd/compile: visit LHS before RHS/X in assign/for statementCuong Manh Le
Unified IR used to visit RHS/X before LHS in assign/for statements for satisfying toolstash in quirksmode. After CL 385998, unified IR quirks mode was gone, the constraint to visit RHS/X first is no longer necessary. Change-Id: I1c3825168b67fb094928f5aa21748a3c81b118ce Reviewed-on: https://go-review.googlesource.com/c/go/+/410343 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-06[dev.unified] cmd/compile: fix missing method value wrapper in unified IRCuong Manh Le
Unified IR uses to generate wrappers after the global inlining pass, so it needs to apply inlining for the wrappers itself. However, inlining may reveal new method value nodes which have not been seen yet, thus unified IR never generates wrappers for them. To fix it, just visiting the wrapper function body once more time after inlining, and generate wrappers for any new method value nodes. Fixes #52128 Change-Id: I78631c4faa0b00357d4f84704d3525fd38a52cd7 Reviewed-on: https://go-review.googlesource.com/c/go/+/410344 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-06[dev.unified] cmd/compile: remove package heightCuong Manh Le
After CL 410654, symbols are now sorted by package path, package height is not necessary anymore. Updates #51734 Change-Id: I976edd2e574dda68eb5c76cf95645b9dce051393 Reviewed-on: https://go-review.googlesource.com/c/go/+/410342 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-06[dev.unified] cmd/compile/internal/noder: push exprBlank up into assignment ↵Matthew Dempsky
handling Blanks can only appear on the LHS of an assignment. Instead of handling them as an arbitrary expression, handle them as part of assignee expression lists. Change-Id: Iaeb0a5c471ffa1abd2bbbd9c95f7876533e5a607 Reviewed-on: https://go-review.googlesource.com/c/go/+/410100 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-06-06[dev.unified] cmd/compile/internal/noder: add optExpr for optional expressionsMatthew Dempsky
Previously, {writer,reader}.expr would allow for nil expressions (i.e., no expression at all, not a "nil" identifier). But only a few contexts allow this, and it simplifies some logic if we can assume the expression is non-nil. So this CL introduces optExpr as a wrapper method for handling nil expressions specially. Change-Id: I438bae7a3191126f7790ec0bf5b77320fe855514 Reviewed-on: https://go-review.googlesource.com/c/go/+/410099 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-06-06[dev.unified] cmd/compile/internal/noder: rename exprName to exprGlobalMatthew Dempsky
More descriptive. Change-Id: I70a07adbe1d395da797fe15b54d2a1106f5f36a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/410098 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2022-05-25internal/pkgbits: add Index typeMatthew Dempsky
Element indices are very common in the pkgbits API, so introduce a new defined type to help make that clearer. Change-Id: I8f9493e2335601c740eb403d1fdcd11183122907 Reviewed-on: https://go-review.googlesource.com/c/go/+/407435 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-16cmd/compile/internal/ir: more idiomatic DynamicType{,AssertExpr}Matthew Dempsky
Rename DynamicType's "X" field to "RType". Split DynamicTypeAssertExpr's "T" field into "RType" and "ITab", the same as DynamicType, updating all uses accordingly. Change-Id: I8cec8171349c93234a10ac50708f800dee6fb1d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/405334 Auto-Submit: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2022-05-13cmd/compile/internal/noder: remove unified IR assumptions on LocalPkg.Path == ""Matthew Dempsky
Replace `pkg.Path == ""` check with `pkg == types.LocalPkg`. This is a prep refactoring for CL 393715, which will properly initialize types.LocalPkg. Updates #51734. Change-Id: I7a5428ef1f422de396762b6bc6d323992834b27c Reviewed-on: https://go-review.googlesource.com/c/go/+/406056 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-05cmd/compile: remove ir.TypeAssertExpr.NtypeMatthew Dempsky
As with ir.CompLitExpr.Ntype, there's no need for ir.TypeAssertExpr.Ntype in a pure-types2 world. Change-Id: Iff48c98330f072fd6b26099e13a19c56adecdc42 Reviewed-on: https://go-review.googlesource.com/c/go/+/403842 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-05-05cmd/compile: change ir.NewCompLitExpr from Ntype to *types.TypeMatthew Dempsky
All callers were already using TypeNode to get an Ntype anyway, so just push the TypeNode constructor down into NewCompLitExpr. Prep refactoring for next CL to remove the Ntype field. Change-Id: I671935afca707aaab11d1c46e39902bd37a485ba Reviewed-on: https://go-review.googlesource.com/c/go/+/403840 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-05-05cmd/compile: remove ir.Name.NtypeMatthew Dempsky
No longer needed now that IR construction uses types2. Change-Id: If8b7aff80cd8472be7d87fd3a36da911a5df163c Reviewed-on: https://go-review.googlesource.com/c/go/+/403839 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-04cmd/compile: enable Asan check for global variablesfanzha02
With this patch, -asan option can detect the error memory access to global variables. So this patch makes a few changes: 1. Add the asanregisterglobals runtime support function, which calls asan runtime function _asan_register_globals to register global variables. 2. Create a new initialization function for the package being compiled. This function initializes an array of instrumented global variables and pass it to function runtime.asanregisterglobals. An instrumented global variable has trailing redzone. 3. Writes the new size of instrumented global variables that have trailing redzones into object file. 4. Notice that the current implementation is only compatible with the ASan library from version v7 to v9. Therefore, using the -asan option requires that the gcc version is not less than 7 and the clang version is less than 4, otherwise a segmentation fault will occur. So this patch adds a check on whether the compiler being used is a supported version in cmd/go. (This is a redo of CL 401775 with a fix for a build break due to an intervening commit that removed the internal/execabs package.) Updates #44853. Change-Id: I719d4ef2b22cb2d5516e1494cd453c3efb47d6c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/403851 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-04Revert "cmd/compile: enable Asan check for global variables"Bryan Mills
This reverts CL 401775. Reason for revert: broke build. Change-Id: I4f6f2edff1e4afcf31cd90e26dacf303979eb10c Reviewed-on: https://go-review.googlesource.com/c/go/+/403981 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2022-05-04cmd/compile: enable Asan check for global variablesfanzha02
With this patch, -asan option can detect the error memory access to global variables. So this patch makes a few changes: 1. Add the asanregisterglobals runtime support function, which calls asan runtime function _asan_register_globals to register global variables. 2. Create a new initialization function for the package being compiled. This function initializes an array of instrumented global variables and pass it to function runtime.asanregisterglobals. An instrumented global variable has trailing redzone. 3. Writes the new size of instrumented global variables that have trailing redzones into object file. 4. Notice that the current implementation is only compatible with the ASan library from version v7 to v9. Therefore, using the -asan option requires that the gcc version is not less than 7 and the clang version is less than 4, otherwise a segmentation fault will occur. So this patch adds a check on whether the compiler being used is a supported version in cmd/go. Updates #44853. Change-Id: Ib877a817209ab2be68a8e22c418fe4a4a20880fc Reviewed-on: https://go-review.googlesource.com/c/go/+/401775 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-29cmd/compile: consistent unified IR handling of package unsafeMatthew Dempsky
Within the unified IR export format, I was treating package unsafe as a normal package, but expecting importers to correctly handle deduplicating it against their respective representation of package unsafe. However, the surrounding importer logic differs slightly between cmd/compile/internal/noder (which unified IR was originally implemented against) and go/importer (which it was more recently ported to). In particular, noder initializes its packages map as `map[string]*types2.Package{"unsafe": types2.Unsafe}`, whereas go/importer initializes it as just `make(map[string]*types.Package)`. This CL makes them all consistent. In particular, it: 1. changes noder to initialize packages to an empty map to prevent further latent issues from the discrepency, 2. adds the same special handling of package unsafe already present in go/internal/gcimporter's unified IR reader to both of cmd/compile's implementations, and 3. changes the unified IR writer to treat package unsafe as a builtin package, to force that readers similarly handle it correctly. Fixes #52623. Change-Id: Ibbab9b0a1d2a52d4cc91b56c5df49deedf81295a Reviewed-on: https://go-review.googlesource.com/c/go/+/403196 Auto-Submit: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-22Revert "cmd/compile: enable Asan check for global variables"Bryan Mills
This reverts CL 321715. Reason for revert: broke cmd/go.TestScript/install_msan_and_race_require_cgo on several builders. Change-Id: Ia0392de555d6e973960769a0e4709f0193d16706 Reviewed-on: https://go-review.googlesource.com/c/go/+/401755 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2022-04-22cmd/compile: enable Asan check for global variablesfanzha02
With this patch, -asan option can detect the error memory access to global variables. So this patch makes a few changes: 1. Add the asanregisterglobals runtime support function, which calls asan runtime function _asan_register_globals to register global variables. 2. Create a new initialization function for the package being compiled. This function initializes an array of instrumented global variables and pass it to function runtime.asanregisterglobals. An instrumented global variable has trailing redzone. 3. Writes the new size of instrumented global variables that have trailing redzones into object file. 4. Notice that the current implementation is only compatible with the ASan library from version v7 to v9. Therefore, using the -asan option requires that the gcc version is not less than 7 and the clang version is less than 4, otherwise a segmentation fault will occur. So this patch adds a check on whether the compiler being used is a supported version in cmd/go. Change-Id: I664e74dcabf5dc7ed46802859174606454e8f1d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/321715 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Fannie Zhang <Fannie.Zhang@arm.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-04cmd/compile: switch to final unified IR export formatMatthew Dempsky
Now that there's a native go/types importer for unified IR, the compiler no longer needs to stay backwards compatible with old iexport importers. This CL also updates the go/types and go/internal/gcimporter tests to expect that the unified IR importer sets the receiver parameter type to the underlying Interface type, rather than the Named type. This is a temporary workaround until we make a decision on #49906. Notably, this makes `GOEXPERIMENT=unified go test` work on generics code without requiring `-vet=off` (because previously cmd/vet was relying on unified IR's backwards-compatible iexport data, which omitted generic types). Change-Id: Iac7a2346bb7a91e6690fb2978fb702fadae5559d Reviewed-on: https://go-review.googlesource.com/c/go/+/386004 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>