Commit graph

49437 commits

Author SHA1 Message Date
korzhao c981874a5a cmd/compile: fix implement for closure in a global assignment
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-09 21:28:56 +00:00
Paul E. Murphy 2c4f389c02 cmd/link: enable internal linker in more cases for ppc64le
The internal linker is capable of linking the ppc64le linux
race detector and approved cgo packages.

Likewise, ppc64/linux and ppc64/aix do not support the race
detector. Thus, extra code to enforce external linking when
using the race detector on ppc64/ppc64le can be removed
entirely.

Fixes #21961

Change-Id: I10db14f65ee616ee3291e17409e8333e3af7d4df
Reviewed-on: https://go-review.googlesource.com/c/go/+/304459
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-09 19:43:39 +00:00
Matthew Dempsky fb84e99eb7 test: add compiler regress tests for #46461
gri@ reports that types2 now correctly handles when type parameters
recursively refer back to the parameterized type, so we might as well
add tests to exercise that. Unified IR also correctly handles
importing and exporting these types, but -G=3 currently does not.

Updates #46461.

Change-Id: I272102aa08c40c980b9aeeca9f834291dfbbcc3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/348738
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-09-09 19:37:25 +00:00
Dan Scales b9e1a24581 cmd/compile: fix case where init info of OAS node is dropped
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-09 19:17:02 +00:00
Robert Findley f9271e4f85 go/types, types2: rename RParams -> RecvTypeParams
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-09 17:02:45 +00:00
Michael Anthony Knyszek ea434450c2 reflect: add hooks for dealing with narrow width floats
Currently on amd64 and arm64, float32 values just live in the bottom 32
bits of the register, so reflect simply places them there in a RegArgs
for reflectcall to load them. This works fine because both of these
platforms don't care what the upper 32 bits are, and have instructions
to operate on float32 values specifically that we use. In sum, the
representation of the float32 in memory is identical to that of the
representation in a register.

On other platforms, however, the representation of FP values differ
depending on whether they're in memory or in a register. For instance,
on ppc64, all floating point values get promoted to a float64 when
loaded to a register (i.e. there's only one set of FP instructions). As
another example, on riscv64, narrow-width floats in registers need to be
NaN-boxed.

What all this means is that for supporting the register ABI on these
platforms, reflect needs to do a little extra work to ensure that the
representation of FP values in a RegArgs matches the representation it
takes on in a register. For this purpose, this change abstracts away the
action of storing values into a RegArgs a little bit and adds a
platform-specific hook which currently does nothing but copy the value.

For #40724.

Change-Id: I65dcc7d86d5602a584f86026ac204564617f4c5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/347566
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-09 16:48:19 +00:00
Damien Neil a53e3d5f88 net: deprecate (net.Error).Temporary
Fixes #45729.

Change-Id: I819dd0cc79fc23baac46cafd78bb80f5133c992b
Reviewed-on: https://go-review.googlesource.com/c/go/+/340261
Trust: Damien Neil <dneil@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-09 16:32:28 +00:00
Keith Randall 19457a58e5 cmd/compile: stenciled conversions might be NOPs
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-09 15:34:08 +00:00
Matthew Dempsky a295b3cec8 test: re-enable AsmCheck tests for types2-based frontends
run.go has logic for being able to run tests with various -G flags,
but not all test types (in particular, "asmcheck" tests) support
configuring non-default -G levels. The intention was that these tests
would continue running in the default mode (at the time -G=0), but at
some point it seems like we accidentally disabled them all
together (if it ever worked correctly in the first place).

Fixes #48247.

Change-Id: I13917cb0012cbe522d29b23b888de6136872ead4
Reviewed-on: https://go-review.googlesource.com/c/go/+/348671
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@lowrisc.org>
2021-09-09 15:07:50 +00:00
Robert Findley 66f0d35f71 go/types: reduce number of delayed functions
This is a port of CL 348018 to go/types. It differs from that CL due to
the way that field lists are represented in go/ast.

Change-Id: Ib5a0243b44d0bf9e95d039f624c668f8c329f8fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/348691
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-09 12:57:26 +00:00
Robert Findley d2a77f1c76 go/types: handle recursive type parameter constraints
This is a port of CL 348090 to go/types. Notably, unlike in types2,
declareTypeParams was previously setting the default constraint to the
empty interface, not nil, because this was missed in CL 335034 (no
changes were made to declareTypeParams). This CL fixes this discrepancy.

Change-Id: I0fa54a660ba14c6cbefa81a27ab7eb193df3be20
Reviewed-on: https://go-review.googlesource.com/c/go/+/348690
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-09 12:56:36 +00:00
Robert Findley 9e1eea6f8b go/types: detect constraint type inference cycles
This is a port of CL 347300 to go/types. The test was adjusted to match
the differing error positioning in go/types: errors are placed on the
ast.CallExpr.Fun, rather than the Lparen.

Change-Id: I3dee5d7d75bae18817cc1f04ab0d357d3a6a8198
Reviewed-on: https://go-review.googlesource.com/c/go/+/348689
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-09 12:56:20 +00:00
Tobias Klauser b86e8dd0f3 test/typeparam: fix issue48094b test build
CL 347529 broke the longtest builders due to missing -G=3 flag when
compiling the added test.

Change-Id: I73007801dd6871a8cf3554e957d247f5f56fd641
Reviewed-on: https://go-review.googlesource.com/c/go/+/348330
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-09 09:06:46 +00:00
Tobias Klauser c84f3a4004 syscall: drop fallback to pipe in Pipe on linux/arm
Follow-up for CL 346789

The minimum required Linux kernel version for Go 1.18 will be changed to
2.6.32, see #45964. The pipe2 syscall was added in 2.6.27, so the
fallback to use pipe in Pipe on linux/arm can be removed.

For #45964

Change-Id: I8b18244ca1f849f10e90565b4fef80ce777fef69
Reviewed-on: https://go-review.googlesource.com/c/go/+/347349
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-09 04:47:41 +00:00
Cuong Manh Le 376a079762 cmd/compile: fix unified IR panic when expanding nested inline function
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-09 04:37:47 +00:00
Ian Lance Taylor 6edc57983a internal/poll: report open fds when TestSplicePipePool fails
For #48066

Change-Id: I1152a1c15756df35b71b27d3e7025d97da9e70b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/348579
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-09-09 04:23:56 +00:00
Cuong Manh Le 2481f6e367 cmd/compile: fix wrong instantiated type for embedded receiver
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-09 03:31:51 +00:00
Cuong Manh Le d62866ef79 cmd/compile: move checkptr alignment to SSA generation
This is followup of CL 343972, moving the checkptr alignment
instrumentation during SSA generation instead of walk.

Change-Id: I29b2953e4eb8631277fe2e0f44b9d987dd7a69f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/345430
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-09 01:25:40 +00:00
Cuong Manh Le 8fad81cd62 cmd/compile: fold handling OCONV logic to separate function
So next CL can re-use the logic to perform checkptr instrumentation.

Change-Id: I3241e9c3c84da04db71fd1d4fd83cb76b2e18521
Reviewed-on: https://go-review.googlesource.com/c/go/+/345435
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-09 01:25:00 +00:00
fanzha02 9cbc76bdf9 cmd/internal/obj/arm64: add checks for incorrect use of REGTMP register
The current assembler uses REGTMP as a temporary destination register,
when optimizing one instruction into a multi-instruction sequence. But
in some cases, when the source register is REGTMP, this behavior is
incorrect.

For example:
  ADD	$0x1234567, R27, R3

The current assembler encodes it into
  MOVD	$17767, R27
  MOVK	$(291<<16), R27
  ADD	R27, R27, R3

It is illegal to overwrite R27. This CL adds the related checks.

Add test cases.

Change-Id: I0af373d9fd23d8f067c093778dd4cc76748faf38
Reviewed-on: https://go-review.googlesource.com/c/go/+/344689
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: fannie zhang <Fannie.Zhang@arm.com>
2021-09-09 01:23:30 +00:00
Matthew Dempsky 42563f89d7 cmd/compile: remove 'ext' fields from unified IR reader/writer types
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-09 01:07:21 +00:00
Matthew Dempsky 4c52eac49b cmd/compile: simplify value coding for unified IR
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-09 00:29:35 +00:00
Matthew Dempsky e30a09013b cmd/compile: extrapolate $GOROOT in unified IR
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-09 00:10:46 +00:00
Robert Griesemer a1f6208e56 go/types, types2: add Environment to Config
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-08 23:59:02 +00:00
Robert Griesemer f5f8a911d8 cmd/compile/internal/types2: spell out 'Type' in type parameter APIs
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-08 23:35:19 +00:00
Josh Bleecher Snyder bff39cf6cb cmd/compile: add automated rewrite cycle detection
A common bug during development is to introduce rewrite rule cycles.
This is annoying because it takes a while to notice that
make.bash is a bit too slow this time, and to remember why.
And then you have to manually arrange to debug.

Make this all easier by automating it.
Detect cycles, and when we detect one, print the sequence
of rewrite rules that occur within a single cycle before crashing.

Change-Id: I8dadda13990ab925a81940d4833c9e5243368435
Reviewed-on: https://go-review.googlesource.com/c/go/+/347829
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-08 22:47:57 +00:00
Robert Griesemer b61e1ed863 cmd/compile/internal/types2: temporarily pin the Checker to Interface during checking
This is a clean port of CL 348371.

Change-Id: I3a61a5a8928279bc783ef16739f7607de3b6ecf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/348575
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-08 22:41:32 +00:00
Robert Griesemer 47f3e1e02c cmd/compile/internal/types2: move NewTypeParam off of Checker
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-08 22:41:27 +00:00
Robert Griesemer ccc927b8f6 cmd/compile/internal/types2: move typeHash to environment.go
This is a clean port of CL 347560.

Change-Id: I0d56f5a818df1a66e603415d5198d909b0aef228
Reviewed-on: https://go-review.googlesource.com/c/go/+/348573
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-08 22:41:22 +00:00
Robert Griesemer 30e9bfbcef cmd/compile/internal/types2: implement deduplication of instances using the 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-08 22:41:16 +00:00
Robert Findley 0406d3a8e5 go/ast: rename MultiIndexExpr to IndexListExpr
As discussed in #47781, IndexListExpr is one character shorter and has
the advantage of being next to IndexExpr in documentation.

Updates #47781

Change-Id: I709d5c1a79b4f9aebcd6445e4ab0cd6dae45bab7
Reviewed-on: https://go-review.googlesource.com/c/go/+/348609
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-08 20:14:03 +00:00
Michael Matloob 65f0d24f73 cmd/go: print offending -mod value in workspace mode
Workspace mode only allows -mod to be set to 'readonly'. When returning
the error for other values of -mod, specify the the value in the error
so it's easier to see what's going on when the go command is invoked
through another tool.

For #45713, #48186

Change-Id: I3ba206a71c7a20c18aeccfa48f3c9dc935a180a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/347593
Trust: Michael Matloob <matloob@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-09-08 18:48:02 +00:00
Michael Matloob 37c9552e06 cmd/go: improve the creation and editing of go.work files
This change changes go.work files so that directory paths are clearly
distinguished from module paths by either being rooted absolute paths or
starting with '.' or '..' path elements if they are relative paths.
go mod initwork now checks that the go.work file doesn't already exist
before creating it, and gomod initwork and gomod editwork look up the
module path corresponding to a directory and write it to the directory
directive's comment.

For #45713

Change-Id: I6983779059b7de6fc83d359280ceffb263f6b641
Reviewed-on: https://go-review.googlesource.com/c/go/+/347591
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-09-08 18:47:32 +00:00
Robert Findley c8d4fe2adc go/types: temporarily pin the Checker to Interface during checking
While type checking expressions involving interface types, it is
possible that their type set is used before delayed actions are
processed. As a result, computeInterfaceTypeSet is called with a nil
checker, and errors in the interface type definition result in panics
(see #48234).

To avoid the panics, store a *Checker on Interface for use in between
checking of the interface type expression and processing of delayed
actions.

Fixes #48234

Change-Id: I5509bc1c01b55edac52446b9e075fbe8fcc01874
Reviewed-on: https://go-review.googlesource.com/c/go/+/348371
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-08 17:35:45 +00:00
Robert Findley d419f9c612 go/types: spell out 'Type' in type parameter APIs
As discussed on the go/types proposal (#47916), we should spell out the
word 'Type', rather than using 'T'.

Change-Id: I5f51255eedc07fea61f909b7ecb3093a7fab765e
Reviewed-on: https://go-review.googlesource.com/c/go/+/348376
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-08 16:59:47 +00:00
Robert Findley 12eb7331b9 go/ast: rename TParams fields to TypeParams
As discussed in the ast proposal (#47781), there's not really a strong
reason to avoid spelling out 'Type'.

Change-Id: I0ba1bf03b112ea60509a78a89a050a302779d9d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/348375
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-08 16:59:04 +00:00
Robert Findley 38c2e08cbd go/types: move NewTypeParam off of Checker
This aligns with the API proposal.

Change-Id: I9967a317196392ffa5ddbe5391d7aba5f6e7bad2
Reviewed-on: https://go-review.googlesource.com/c/go/+/347561
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-08 16:32:00 +00:00
Robert Findley cb9ccd494b go/types: move typeHash to environment.go
This is a pure code move, with no other changes.

Change-Id: Id31f1f960d3208dc614556de89bf39b7ca77df3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/347560
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-08 16:31:42 +00:00
Robert Findley a1a6540bf1 go/types: implement deduplication of instances using the Environment
Implement deduplication of type instances via the Environment by
recording a map of unique IDs for *Named types. This avoids an issue
with the existing type hash, where qualified names alone were not
sufficient to differentiate two *Named types that have the same fully
qualified name but which are distinct pointers. It also allows us to
drop the scope accounting for local types.

A subtle bug is also fixed in subst.go, where the instance t was passed
to typeHash rather than t.orig.

Change-Id: I85639ccc1c9bfee470babd2fc85375484c8ed0b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/344390
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-08 16:31:21 +00:00
Bryan C. Mills 409434d623 cmd/go/internal/modload: scan dependencies of root paths when raising version limits in editRequirements
Fixes #47979

Change-Id: I1d9d854cda1378e20c70e6c6789b77e42e467ca7
Reviewed-on: https://go-review.googlesource.com/c/go/+/347290
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-09-08 16:19:36 +00:00
Robert Griesemer 054710ce46 cmd/compile/internal/types2: reduce number of delayed functions (optimization)
Rather than create and delay execution of a closure for each type parameter
in a type parameter list, just create one per type parameter list.

While at it, inline the small amount of code for getting the type constraint
and remove the respective function.

Change-Id: I49a00ff0a7b7e43eb53992dd7dbfac25ff23b42c
Reviewed-on: https://go-review.googlesource.com/c/go/+/348018
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-08 15:51:14 +00:00
Robert Griesemer 73a062c3e7 cmd/compile/internal/types2: handle recursive type parameter constraints
Check type constraints after the respective type parameter list
has been associated with a parameterized type so that recursive
type parameter constraints "see" a parameterized type.

Fixes #45550.
Fixes #47796.

Change-Id: Iac74610ca017a78013820624230c857395506aff
Reviewed-on: https://go-review.googlesource.com/c/go/+/348090
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-08 15:51:08 +00:00
Dmitri Shuralyov 9581d891ab cmd/pprof: update vendored github.com/google/pprof
Pull in the latest published version of github.com/google/pprof
that is available at this time in the Go 1.18 development cycle.

Done with:

	go get -d github.com/google/pprof@latest
	go mod tidy
	go mod vendor

For #36905.

Change-Id: Ib25aa38365ec70a0bed2a8a6527e5823ab9f9ded
Reviewed-on: https://go-review.googlesource.com/c/go/+/348410
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-09-08 15:36:36 +00:00
Michael Munday 8214257347 test/codegen: fix package name for test case
The codegen tests are currently skipped (see #48247). The test
added in CL 346050 did not compile because it was in the main
package but did not contain a main function. Changing the package
to 'codegen' fixes the issue.

Updates #48247.

Change-Id: I0a0eaca8e6a7d7b335606d2c76a204ac0c12e6d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/348392
Trust: Michael Munday <mike.munday@lowrisc.org>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-08 14:51:40 +00:00
Michael Munday 1da64686f8 test/codegen: fix compilation of bitfield tests
The codegen tests are currently skipped (see #48247) and the
bitfield tests do not actually compile due to a duplicate function
name (sbfiz5) added in CL 267602. Renaming the function fixes the
issue.

Updates #48247.

Change-Id: I626fd5ef13732dc358e73ace9ddcc4cbb6ae5b21
Reviewed-on: https://go-review.googlesource.com/c/go/+/348391
Trust: Michael Munday <mike.munday@lowrisc.org>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-08 14:51:31 +00:00
Michael Munday fdc2072420 test/codegen: remove broken riscv64 test
This test is not executed by default (see #48247) and does not
actually pass. It was added in CL 346689. The code generation
changes made in that CL only change how instructions are assembled,
they do not actually affect the output of the compiler. This test
is unfortunately therefore invalid and will never pass.

Updates #48247.

Change-Id: I0c807e4a111336e5a097fe4e3af2805f9932a87f
Reviewed-on: https://go-review.googlesource.com/c/go/+/348390
Trust: Michael Munday <mike.munday@lowrisc.org>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-08 14:51:22 +00:00
Dmitri Shuralyov 64bdad2011 all: update vendored golang.org/x/tools
Now that issue #48124 is resolved, ran the
following commands inside the cmd module:

	go get -d golang.org/x/tools@36045662144327e4475f9d356f49ab32ce730049  # main branch
	go mod tidy
	go mod vendor

For #36905.
Updates #48124.

Change-Id: I9dc736c2c5256f7d9e80fd9c52c6725ecf0b8001
Reviewed-on: https://go-review.googlesource.com/c/go/+/348409
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
2021-09-08 14:25:12 +00:00
Paul E. Murphy 9295723079 cmd/link: rework .TOC. handling for ppc64le
Setup .TOC. to point to the same place for all objects. Today, the linker
assumes all call relocations can use the local function entry point of
imported object files. This requires a consistent pointer across all
objects.

This intentionally computes the .TOC. pointer in all linking configurations.
In some cases the .TOC. is not used today (e.g linking position-dependent go
only code). It is harmless and simple to compute in all cases, so just
do it for easier maintenance.

Notably, .TOC. is used in some cases when static linking is requested on
ppc64le/linux:

* Position-independent C code using a PC-rel relocation against .TOC.. cgo
  generated C object files are usually compiled PIC even if the go binary
  itself is not.

* Anything which causes PLT stub generation. The stubs always generate
  a .TOC. relative relocation.

* The race detector. Today, this links in an externally compiled archive which
  contains position-independent object files.

Similarly, position-independent linking is always punted to the external
linker on ppc64 today.

Updates #21961
Fixes #15409

Change-Id: Ifd8294b9249e16ba8b92eaf876d15d162f9c61fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/304458
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-09-08 11:57:03 +00:00
Joel Sing 50c69cc3a9 cmd/link/internal/riscv64,cmd/internal/obj/riscv: make error messages consistent
Be consistent with both style/wording and formatting of error messages.

Change-Id: I23013d904333a67a8f17dd364bb5015f54f419c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/345050
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-08 06:59:06 +00:00
Joel Sing c50d811c7a cmd/interna/obj/riscv: use obj.REG_NONE rather than 0
No functional change, but makes the code consistent and more readable.

Change-Id: I33db681fe0ed501842755f27b6e7843cdc8877cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/345049
Trust: Joel Sing <joel@sing.id.au>
Trust: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
2021-09-08 06:58:13 +00:00