1
0
mirror of https://github.com/golang/go synced 2024-09-29 22:34:33 -06:00
Commit Graph

49418 Commits

Author SHA1 Message Date
Tobias Klauser
17e9d148d3 syscall: drop fallback to utimes in UtimesNano on Linux
The minimum required Linux kernel version for Go 1.18 will be changed to
2.6.32, see #45964. The current minimum required version is 2.6.23 and
utimensat was added in 2.6.22, so the fallback isn't even necessary for
the current minimum supported version. Remove the fallback to utimes.

For #45964

Change-Id: I5536f6ea7a34944dd9165f1533c10692171fb0c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/346790
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-02 09:24:59 +00:00
Tobias Klauser
d13d62c49a os, syscall: remove fallback to pipe syscall on Linux
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 the pipe syscall in os.Pipe and syscall.forkExecPipe on
Linux can be removed.

For #45964

Change-Id: I033a534f2b39e9bafc9980c9ce980e92f1e3a136
Reviewed-on: https://go-review.googlesource.com/c/go/+/346789
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-02 09:24:44 +00:00
Cuong Manh Le
840b4292c9 src: emit warning when make.bash run with invalid GOROOT_BOOTSTRAP
When setting an invalid GOROOT_BOOTSTRAP, make.bash try looking at env to
find a valid go command and use that GOROOT instead. It's better if the
script emit a warning, instead of silently change the GOROOT_BOOTSTRAP.

Change-Id: I6038093d5e8c072da27bcae44b125f6774f809a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/326030
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-02 07:31:53 +00:00
Cuong Manh Le
1ae7ddc235 test: always run test in unified IR mode regardless of explicit -G flag
Currently, if a test explicitly specify -G flag, if that flag conflict
with compiler default -G flag, the test will be skipped. That's the
reason CL 346469 haven't fixed the unified IR stuff, but still make the
unified builder passed.

This CL makes run.go always run the test in unified IR mode, regardless
of the explicit -G flag specified.

Updates #48094

Change-Id: I959ecaff6aca07844f0ffcf36caa60cf0747e8ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/347271
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Keith Randall <khr@golang.org>
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-02 06:44:04 +00:00
Cuong Manh Le
3db4888a05 cmd/compile: use types2.Unsafe to represent package unsafe in gcimports
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-02 06:43:58 +00:00
Cuong Manh Le
9afbf82667 cmd/compile: allow objStub from unsafe package
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-02 06:43:50 +00:00
Meng Zhuo
1bd35fab05 runtime: use vDSO clock_gettime on linux/riscv64
Speed up nanotime1 and walltime on riscv64 with vDSO, just like the
other vDSO-enabled targets.

name          old time/op  new time/op  delta
Now           1.53µs ± 1%  1.05µs ± 3%  -31.74%  (p=0.000 n=10+10)
NowUnixNano   1.54µs ± 0%  1.05µs ± 2%  -31.91%  (p=0.000 n=9+10)
NowUnixMilli  1.56µs ± 1%  1.06µs ± 1%  -31.73%  (p=0.000 n=10+10)
NowUnixMicro  1.56µs ± 1%  1.05µs ± 1%  -32.80%  (p=0.000 n=9+10)

Change-Id: I69b3fe3cc57685a826c53b366c0992e8048399bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/328509
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-02 01:23:38 +00:00
Robert Griesemer
df4c625d88 cmd/compile: disable type list syntax for the compiler
Add (temporary) syntax.AllowTypeLists mode to control the
acceptance of type lists; the compiler doesn't set it,
but existing syntax and types2 tests do so that the code
remains exercised while it exists.

Adjust various tests to use the type set notation.

Change-Id: I798e607912552db6bfe38a7cd4324b74c6bf4d95
Reviewed-on: https://go-review.googlesource.com/c/go/+/347249
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-02 01:06:17 +00:00
Robert Griesemer
2872496ba5 cmd/compile/internal/types2: systematic detection of missing instantiation
When type-checking expressions, detection of uninstantiated generic
functions and types was somewhat ad-hoc.

Add an extra parameter "allowGenerics" to rawExpr. If not set, the
result operand cannot be generic.

The only place where rawExpr is called with allowGenerics != false
is from exprOrType, which passes an allowGenerics parameter through.

The only place where exprOrType is called with allowGenerics == true
is when handling index expressions and calls. Make sure that we only
accept generic operands where expected, and check the other branches.

As a result, a recently added varType call (CL 345970) can be removed
again.

This also fixes a bug where an error for a conversion to generic
type was reported after the conversion (i.e., with the converted
value, rather than the generic type). Added a test case for that.

For #48048.

Change-Id: I8576326f5fcfb58d78b3ce8572068aa32e66c568
Reviewed-on: https://go-review.googlesource.com/c/go/+/346471
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-01 23:41:53 +00:00
Damien Neil
0bfd6fcea6 all: update golang.org/x/net to pull in CL 346890
For #42777.

Change-Id: I963db8c666e8bcf0fc4f390b359db6408a0f792b
Reviewed-on: https://go-review.googlesource.com/c/go/+/347010
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-01 22:28:21 +00:00
Matthew Dempsky
88859f3cd8 cmd/compile: optimize unified IR handling of imported functions
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-01 21:38:48 +00:00
Matthew Dempsky
50f38d0405 cmd/compile: emit unified IR wrappers after inlining
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-01 21:38:43 +00:00
Leonard Wang
5e0f8edbdc cmd/compile: remove useless fcount
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-01 21:26:54 +00:00
Michael Munday
ea51e223c2 cmd/{asm,compile}: add fused multiply-add support on riscv64
Add support to the assembler for F[N]M{ADD,SUB}[SD] instructions.
Argument order is:

  OP RS1, RS2, RS3, RD

Also, add support for the FMA intrinsic to the compiler. Automatic
FMA matching is left to a future CL.

Change-Id: I47166c7393b2ab6bfc2e42aa8c1a8997c3a071b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/293030
Trust: Michael Munday <mike.munday@lowrisc.org>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
2021-09-01 21:17:04 +00:00
Cuong Manh Le
711e1c8224 cmd/compile: fix irgen mis-handling invalid function declaration
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-01 19:51:25 +00:00
seifchen
592ee433f5 spec: adjust example for consistency
Change-Id: I5ff9078907b78f31aec42abf749a193b15bc5109
GitHub-Last-Rev: 1f96d84f20
GitHub-Pull-Request: golang/go#47732
Reviewed-on: https://go-review.googlesource.com/c/go/+/342789
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
2021-09-01 19:23:15 +00:00
Matthew Dempsky
6c5f028242 cmd/compile/internal/pkginit: separate "init" and "inittask" logic
This CL splits the creation of the "init" function responsible for
executing package-scope variable initialization statemens from the
creation of the "inittask" record that tells the runtime how to
sequence all program-wide package initialization.

Longer term, this is desirable because sorting variable initialization
is already handled by types2 (with Info.InitOrder), so we might as
well reuse that.

As a more immediate impetus, for unified IR, I want to defer method
wrapper generation until after inlining (to know which wrappers are
needed). But the staticinit optimization used to decide whether to
emit the inittask calls into reflectdata, which in turn tries to
generate its own method wrappers. So separating the work allows to
create the "init" function early and then emit "inittask" after
inlining is done.

Change-Id: Ice1d421f92feecaaeafdf7da6b9647c0f27e3571
Reviewed-on: https://go-review.googlesource.com/c/go/+/346629
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-01 18:16:17 +00:00
Paul E. Murphy
8f397bc118 cmd/internal/obj/ppc64: improve long conditional branch fixup
Improve the code which fixes up conditional branches which exceed the
range of a single instruction by inserting one extra jump when
possible instead of two.

Change-Id: Ib0eb5b0f47f7d0e0ccd55471307a5f73fbda88a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/342930
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-01 17:25:30 +00:00
korzhao
5670ff4ae5 cmd/compile: fix conversions from TypeParam to interface
If the TypeParam has all the methods of an interface, allow conversions from TypeParam to interface

Fixes #47708

Change-Id: I40a82a31f6ea9354130dbe3bcfc83537094bf12c
Reviewed-on: https://go-review.googlesource.com/c/go/+/342509
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Trust: Keith Randall <khr@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-01 16:45:26 +00:00
Joel Sing
717f337d1d cmd/asm: adjust riscv64 test data to avoid churn
Rather than jumping and branching to a label (the offset for which changes
when instructions are added or removed), use PC-relative offsets. This
reduces unnecessary churn in the instruction encodings.

Change-Id: I6816ce939eeabdf828039f59f4f29260eb1ac8da
Reviewed-on: https://go-review.googlesource.com/c/go/+/344449
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@lowrisc.org>
2021-09-01 07:10:24 +00:00
Joel Sing
5a687eeaf1 cmd/asm,cmd/internal/obj/riscv: add more error tests for riscv64 assembly
Add more error tests for riscv64 assembly. Also avoid a panic when one of
these error conditions is hit.

Change-Id: If5d913894facbd67f7d014eab745da77c8c66ab0
Reviewed-on: https://go-review.googlesource.com/c/go/+/344228
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
2021-09-01 06:18:05 +00:00
Keith Randall
faf9c7d8fe cmd/compile: assign results of transformAssign back to source location
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-01 03:50:19 +00:00
Dan Scales
2dd7b770de cmd/compile: fix missing case for shape double-check function
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-09-01 02:51:18 +00:00
Cuong Manh Le
62ba72b353 cmd/compile: fix method expression lookup during import
CL 309831 fixed importing of method expressions, by re-using the same
code already have for ODOTMETH. But that code does not work with
embedded field.

To fix this, we need to calculate all methods of the receiver base type
of method expression, before looking up the selection.

Fixes #48088

Change-Id: Ia244d36a3ed0f989735eb57becdfa70a81912f57
Reviewed-on: https://go-review.googlesource.com/c/go/+/346489
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-01 02:16:30 +00:00
Robert Findley
f4e24599dd go/types: disallow aliases for generic types
This is a port of CL 346294 to go/types.

Change-Id: Ib70541a92e352c8df8123c8b82bb4eeedce3b89f
Reviewed-on: https://go-review.googlesource.com/c/go/+/346560
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-01 00:37:28 +00:00
Robert Findley
36ac2214fa go/types: remove superfluous ordinaryType calls
This is a port of CL 346291 to go/types.

Change-Id: I8f864aca5cdb4037bc27a81cde1597430b9a48db
Reviewed-on: https://go-review.googlesource.com/c/go/+/346559
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-01 00:37:23 +00:00
Robert Findley
1a9807906d go/types: more systematic error handling in typeWriter
This is a port of CL 346009 to go/types. An unnecessary break statement
was removed from both the port and types2.

Change-Id: I2cc1328a61100d4b01a2d26ac7bac9044440d579
Reviewed-on: https://go-review.googlesource.com/c/go/+/346558
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-01 00:37:16 +00:00
Robert Findley
5cd1b847dc go/types: eliminate typeHashing global variable
This is a port of CL 345929 to go/types. It is also a step toward making
instantiation concurrency-safe.

Also fix some whitespace in instantiate.go.

Updates #47910

Change-Id: Icdeb227cb83eee15da6db90daab294c8c55db601
Reviewed-on: https://go-review.googlesource.com/c/go/+/346557
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-01 00:36:05 +00:00
Robert Findley
0df6df17e1 go/types: generalize instanceHash to accept any type, rename to typeHash
This is a port of CL 345791 to go/types.

Change-Id: I673c22ad8b668f07aae4117555b1c0efb273fb78
Reviewed-on: https://go-review.googlesource.com/c/go/+/346556
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-01 00:35:54 +00:00
Robert Findley
3c8c9e1e44 go/types: don't print instance markers for type hashes
This is a port of CL 345891 to go/types.

Change-Id: I5abcb9c9c5110923a743f0c47d9b34b2baabab68
Reviewed-on: https://go-review.googlesource.com/c/go/+/346555
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-08-31 23:46:12 +00:00
Robert Findley
2d98a4b4bc go/types: use a typeWriter to write types (cleanup)
This is a port of CL 345890 to go/types.

Change-Id: I98162deaf044b2194b05dc51e6948e227216fc4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/346554
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-08-31 23:45:48 +00:00
Robert Findley
b2f09cd717 go/types: do not declare new methods on instantiated types
This is a port of CL 345472 to go/types.

Change-Id: I0e2a88909ecebe9dea3325244153f5c74e4c3ce7
Reviewed-on: https://go-review.googlesource.com/c/go/+/346553
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-08-31 22:47:49 +00:00
Robert Findley
5e9ba0b1bd go/types: implement TypeList.String (debugging support)
This is a port of CL 345471 to go/types.

Change-Id: Icad5fb8b3b4375182f420a51c80607b88696561e
Reviewed-on: https://go-review.googlesource.com/c/go/+/346552
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-08-31 22:45:42 +00:00
Robert Findley
580987cd58 go/types: remove need for the instance struct
This is a port of CL 345177 to go/types.

Change-Id: I79fcfbf5b28e9a7a2e66c81bc831e164a8da8bbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/346551
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-08-31 22:45:26 +00:00
Robert Findley
d15a75e070 go/types: address some TODOs (cleanup)
This is a port of CL 345176 to go/types, though not all TODOs were
present in go/types.

A TODO that still needs to be resolved was added back to types2.

Change-Id: Icf79483c92d0bc1248de772c7044620f0f0a5c58
Reviewed-on: https://go-review.googlesource.com/c/go/+/346550
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-08-31 22:39:00 +00:00
Keith Randall
1f83a8c16c cmd/compile: use the zero value for results of impossible indexing
type A [0]int
var a A
x := a[i]

Use the zero value for x instead of the "impossible" value. That lets
us at least compile code like this with -B, even though it can't
possibly run correctly.

Fixes #48092

Change-Id: Idad5cfab49e05f375c069b05addceed68a15299f
Reviewed-on: https://go-review.googlesource.com/c/go/+/346589
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-31 21:49:48 +00:00
Keith Randall
bb0b511738 cmd/compile: use right line number for conversion expression
Use the position of the actual conversion operation instead of base.Pos.

Fixes #47880

Change-Id: I56adc134e09cb7fd625adc0a847c1a6b3e254b1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/345095
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2021-08-31 21:26:33 +00:00
Robert Findley
7637345b6e go/internal/typeparams: remove typeparams.{Get,Set} (cleanup)
These helper functions are no longer necessary, now that type parameters
are enabled; we can access type parameters directly.

When considering the existence or non-existence of type parameters, we
can either check whether node.TParams != nil, or whether
node.TParams.NumFields() > 0. The heuristic I'm using for deciding
between these checks is as follows:
 - For data access, just check node.TParams != nil.
 - For producing errors if type parameters exist, check NumFields() > 0.

Change-Id: I6597536898e975564e9e8bf6a3a91bc798e0f110
Reviewed-on: https://go-review.googlesource.com/c/go/+/346549
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-08-31 21:25:03 +00:00
Robert Findley
78d0f8c870 go/types: fix type set printing and add a test
This is a port of CL 344873 to go/types.

Change-Id: Iad41d6de166214178adf2123ac05023895f5208b
Reviewed-on: https://go-review.googlesource.com/c/go/+/346435
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-08-31 21:24:09 +00:00
Robert Findley
ae2b2dc01a go/types: rename IsMethodSet to IsConstraint (cleanup)
This is a port of CL 344872 to go/types.

Change-Id: Id794f1fc3b86779ee32dbe5e656ffc747d44c3e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/346434
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-08-31 21:23:49 +00:00
Robert Findley
b93581e47d go/types: add error reporting for 1.18 syntax if GoVersion is below 1.18
This is a port of CL 344871 to go/types. Unlike the compiler, go/parser
is already always producing 1.18 syntax, so the effect of this CL is to
add some additional errors when Config.GoVersion is below 1.18.

This is a non-trivial port, both due to different error reporting APIs
and due to interacting with declaration syntax nodes, which differ
between go/ast and cmd/compile/internal/syntax.

Change-Id: I8003a014e6eec5e554c24e9a6cfc0548ec534834
Reviewed-on: https://go-review.googlesource.com/c/go/+/346433
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-08-31 21:22:54 +00:00
Robert Findley
aed59d172a go/types: allow composite literals of type parameter type
This is a port of CL 342690 to go/types.

Change-Id: I27dcde237e400a84c3394a3579805014777830bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/346432
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-08-31 20:39:39 +00:00
Dan Scales
891470fbf7 cmd/compile: fix handling of Defn field during stenciling
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-31 19:07:50 +00:00
Martin Möhrmann
46121306d3 cmd/compile: remove folding of 32 bit pointer offsets on amd64
These rules were likely only used in the removed amd64p32 port.

Passes toolstash -cmp.

Change-Id: Ie626d1021bade7f7571d1bd5271fbe8676bb295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/346509
Trust: Martin Möhrmann <martin@golang.org>
Run-TryBot: Martin Möhrmann <martin@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-31 18:41:52 +00:00
Martin Möhrmann
144e0b1f6e cmd/compile: add MOVOstoreconst with offset folding on amd64
Replace MOVOstorezero with new MOVOstoreconst.
MOVOstoreconst has similar address folding rules then
other MOVstoreconst operations but only supports zero
as store value. Currently only MOVO stores with zero
values are generated. Using MOVOstoreconst with
SymValAndOff aux has the advantage that we can just
add one more MOVstoreconst variant to the existing rules.

The main effect of this CL is converting 16 byte zeroing
of a value on the stack from LEAQ+MOVUPS to just MOVUPS
which reduces binary size.

old:
LEAQ 0x20(SP), DX
MOVUPS X15, 0(DX)

new:
MOVUPS X15, 0x20(SP)

file      before    after     Δ       %
addr2line 3661568   3657472   -4096   -0.112%
asm       4566432   4562336   -4096   -0.090%
cgo       4305456   4301360   -4096   -0.095%
compile   22878528  22874512  -4016   -0.018%
cover     4517952   4513856   -4096   -0.091%
link      6287248   6283152   -4096   -0.065%
nm        3640768   3636672   -4096   -0.113%
objdump   4010592   4006496   -4096   -0.102%
pack      2188224   2184128   -4096   -0.187%
pprof     13429504  13421312  -8192   -0.061%
trace     10143968  10135776  -8192   -0.081%
vet       6868864   6864768   -4096   -0.060%

Change-Id: I08f5dd5ab9251448a4572d3ddd1e0c8cd417f5e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/346249
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Martin Möhrmann <martin@golang.org>
2021-08-31 17:35:15 +00:00
Keith Randall
f27d6a23b0 cmd/compile: builtins may be in the unsafe package
Now that unsafe.Sizeof and friends can operate on generic parameters,
and evaluate to non-constants, we need to export/import them correctly.

Fixes #48094

Change-Id: If3ebf77255385cd5462e13fb7ced8b157ba3cf5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/346469
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-08-31 17:21:38 +00:00
Robert Griesemer
68152359fd cmd/compile/internal/types2: disallow aliases for generic types
The existing approach (alias name stands for generic type name)
is an exception: it's the only place where a generic type could
be used without explicit instantiation. The correct solution is
currently under discussion (see proposal issue #46477).

This CL requires that the RHS of an alias type declaration be
an instantiated non-generic type. If #46477 is accepted, the
implementation will require proper representation of alias
types.

Change-Id: Ie85b923213a64f39837e56e38e14757458272b93
Reviewed-on: https://go-review.googlesource.com/c/go/+/346294
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-08-31 16:43:46 +00:00
Robert Griesemer
605d1aaea2 go/types, types2: union terms must be instantiated
Fixes #48083.

Change-Id: I77899d3e6edc806dee770403b3c3c4e2974d0e50
Reviewed-on: https://go-review.googlesource.com/c/go/+/346293
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-08-31 16:20:54 +00:00
Robert Griesemer
ded10d75a9 cmd/compile/internal/types2: remove superfluous ordinaryType calls
The value types in type assertions and type switches cannot be
constraint types (if there are, an error was reported earlier),
so there is no need to check again that they are not constraint
types.

This permits merging the ordinaryType call with varType, which
is the only place where it's needed.

Change-Id: I44a852377b3dddf53692f764e588801fb3d3c0a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/346291
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-08-31 16:14:01 +00:00
Andy Pan
3920d6f208 runtime: eliminate the redundant for loop in runqget()
Change-Id: If9b283bbef3ff12a64d34b07491aee3396852f05
Reviewed-on: https://go-review.googlesource.com/c/go/+/317509
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Keith Randall <khr@golang.org>
2021-08-31 13:54:19 +00:00