]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
23 months ago[dev.unified] all: merge master (993c387) into dev.unified
Matthew Dempsky [Thu, 30 Jun 2022 20:39:49 +0000 (13:39 -0700)]
[dev.unified] all: merge master (993c387) into dev.unified

Conflicts:

- test/run.go: textual conflict in 1.18 known failures list

Merge List:

+ 2022-06-30 993c387032 os: simplify deadline fluctuation tests
+ 2022-06-30 4914e4e334 cmd/go/internal/modindex: remove spurious field from index_format documentation
+ 2022-06-30 981d5947af cmd/go: include module root in package index key
+ 2022-06-30 84db00ffd1 cmd/go: add a 'sleep' command for script tests
+ 2022-06-30 31b8c23c57 cmd/compile: fix prove pass when upper condition is <= maxint
+ 2022-06-30 17083a2fdf spec: retitle section on "Assignments" to "Assignment statements"
+ 2022-06-30 4d95fe6653 test: add regress test for #53619
+ 2022-06-29 6a7c64fde5 debug/pe: add IMAGE_FILE_MACHINE_LOONGARCH{64,32}
+ 2022-06-29 b2cc0fecc2 net/http: preserve nil values in Header.Clone
+ 2022-06-29 64ef16e777 cmd/internal/obj/arm64: save LR and SP in one instruction for small frames
+ 2022-06-29 0750107074 go/token: use atomics not Mutex for last file cache
+ 2022-06-29 e5017a93fc net/http: don't strip whitespace from Transfer-Encoding headers
+ 2022-06-29 20760cff00 runtime: add race annotations to cbs.lock
+ 2022-06-29 e6c0546c54 crypto/x509/pkix: move crl deprecation message
+ 2022-06-29 3562977b6f cmd/internal/obj/mips,s390x,riscv: save LR after decrementing SP
+ 2022-06-29 d6481d5b96 runtime: add race annotations to metricsSema
+ 2022-06-29 bd1783e812 crypto/x509: improve RevocationList documentation
+ 2022-06-28 160414ca6a cmd/internal/obj/arm64: fix BITCON constant printing error
+ 2022-06-28 a30f434667 cmd/go: pass --no-decorate when listing git tags for a commit
+ 2022-06-28 3580ef9d64 os/exec: on Windows, suppress ErrDot if the implicit path matches the explicit one
+ 2022-06-28 34f3ac5f16 cmd/compile: fix generic inter-inter comparisons from value switch statements
+ 2022-06-28 7df0a002e6 cmd/go/internal/modfetch: cache latest revinfo in Versions func
+ 2022-06-28 d5bf9604aa test: add more tests for const decls with ommitted RHS expressions
+ 2022-06-28 533082d1a0 test: add test that gofrontend failed to compile
+ 2022-06-28 47e792e22e runtime: clean up unused function gosave on loong64
+ 2022-06-28 a6e5be0d30 cmd/go: omit build metadata that may contain system paths when -trimpath is set
+ 2022-06-28 d3ffff2790 api: correct debug/pe issue number for Go 1.19 changes
+ 2022-06-28 751cae8855 cmd/go/internal/modload: fix doc comment
+ 2022-06-28 85d7bab91d go/printer: report allocs and set bytes
+ 2022-06-27 3af5280c00 net: really skip Windows PTR tests if we say we are skipping them
+ 2022-06-27 a42573c2f1 net: avoid darwin/arm64 platform bug in TestCloseWrite
+ 2022-06-27 68289f39f0 html/template: fix typo in content_test.go
+ 2022-06-27 c3bea70d9b cmd/link: link against libsynchronization.a for -race on windows
+ 2022-06-27 f093cf90bf test: add test that caused gofrontend crash
+ 2022-06-27 155612a9b9 test: add test that caused gofrontend crash
+ 2022-06-27 a861eee51a cmd/go: compile runtime/internal/syscall as a runtime package
+ 2022-06-27 8f9bfa9b7b crypto/internal/boring: factor Cache into crypto/internal/boring/bcache
+ 2022-06-26 351e0f4083 runtime: avoid fma in mkfastlog2table
+ 2022-06-26 416c953960 test: add test that gofrontend gets wrong
+ 2022-06-26 666d736ecb cmd/compile: do branch/label checks only once
+ 2022-06-26 6b309be7ab cmd/compile/internal/syntax: check fallthrough in CheckBranches mode
+ 2022-06-25 1821639b57 runtime: mark string comparison hooks as no split
+ 2022-06-25 3b594b9255 io: clarify SeekEnd offset value
+ 2022-06-25 4f45ec5963 cmd/go: prepend builtin prolog when checking for preamble errors
+ 2022-06-24 41e1d9075e strconv: avoid panic on invalid call to FormatFloat
+ 2022-06-24 bd4753905d internal/trace: add Go 1.19 test data
+ 2022-06-24 6b6c64b1cc cmd/internal/archive: don't rely on an erroneous install target in tests

Change-Id: Ib43126833bf534c311730d4283d4d25381cd3428

23 months agoos: simplify deadline fluctuation tests
Ian Lance Taylor [Wed, 29 Jun 2022 20:11:33 +0000 (13:11 -0700)]
os: simplify deadline fluctuation tests

This applies the net package CL 365334, CL 366176, CL 372215 to the os
package.

CL 365334:

    These tests were checking for fairly narrow timing windows, but were
    running in parallel and heavily dependent on timer and goroutine
    scheduling. This change eliminates unnecessary goroutines, runs the
    tests sequentially (dramatically shortening the timeouts to reduce the
    penalty of doing so), and uses timestamp comparison instead of
    background timers to hopefully gain some robustness from monotonic
    timestamps.

    Many of the other tests from this package would benefit from similar
    simplifications, which we can apply if and when we notice flaky
    failures or want to improve the latency of running the test.

CL 366176:

    It appears that at least the OpenBSD kernel gets sloppier the longer
    the timeout we give it, up to an observed overhead of around 25%.
    Let's give it a little more than that (33%) in the comparison, and
    also increase the growth curve to match the actual observed times
    instead of exponential initial growth.

CL 372215:

    Decrease the slop everywhere else, since NetBSD and OpenBSD seem to be
    the only ones that miss by that much.

For #36108
For #50189
Fixes #50725 (we hope)

Change-Id: I0854d27af67ca9fcf0f9d9e4ff67acff4c2effc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/415234
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months agocmd/go/internal/modindex: remove spurious field from index_format documentation
Bryan C. Mills [Thu, 30 Jun 2022 18:18:02 +0000 (14:18 -0400)]
cmd/go/internal/modindex: remove spurious field from index_format documentation

The 'path' field was removed in an earlier revision to the format.

While auditing the format, I also cleaned up a couple of minor
typographical issues.

For #53586.

Change-Id: I4cd1ce9e970023441c11244428ed2971be1d8138
Reviewed-on: https://go-review.googlesource.com/c/go/+/415514
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months ago[dev.unified] cmd/compile: refactor `range` desugaring
Matthew Dempsky [Thu, 30 Jun 2022 02:23:34 +0000 (19:23 -0700)]
[dev.unified] cmd/compile: refactor `range` desugaring

This CL refactors the code responsible for emitting the user-visible
assignments within a range statement. This will make it easier to
propagate RTTI from the frontend into any implicit conversions.

Updates #53328.

Change-Id: Ibed15e3b4951b0a6a726067b401a630977f4c6c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/415158
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months ago[dev.unified] cmd/compile/internal/noder: implicit conversions for multi-valued expre...
Matthew Dempsky [Tue, 28 Jun 2022 23:31:29 +0000 (16:31 -0700)]
[dev.unified] cmd/compile/internal/noder: implicit conversions for 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>

23 months ago[dev.unified] cmd/compile/internal/noder: refactor N:1 expression handling
Matthew Dempsky [Fri, 24 Jun 2022 21:19:06 +0000 (14:19 -0700)]
[dev.unified] cmd/compile/internal/noder: refactor N:1 expression handling

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>
23 months ago[dev.unified] test: tweak nilcheck test
Matthew Dempsky [Wed, 29 Jun 2022 23:48:06 +0000 (16:48 -0700)]
[dev.unified] test: tweak nilcheck test

A subsequent CL will change Unified IR to emit extra temporary
variables for multi-value expressions, because they're sometimes
necessary for handling implicit conversions.

A consequence of this is that:

_, ok := m[""]

will be rewritten into:

autotmp_1, autotmp_2 := m[""]
_, ok := autotmp_1, autotmp_2

As the comment in nilcheck.go says, we don't want this code sequence
to emit any nil checks, and it doesn't either way. But only the second
form results in the compiler reporting "removed nil check", and I
can't make sense of why.

Rather than splitting this test case into separate unified and
nounified variants, it seems easier to just tweak the test case to the
more complex form and verify that we correctly remove the nil check
still.

Change-Id: I6a9266db933b201352d52da4d403a330fdeac48b
Reviewed-on: https://go-review.googlesource.com/c/go/+/415242
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
23 months ago[dev.unified] test: break escape_iface.go into unified/nounified variants
Matthew Dempsky [Thu, 30 Jun 2022 00:16:46 +0000 (17:16 -0700)]
[dev.unified] test: break escape_iface.go into unified/nounified variants

The assignment `sink, *(&ok) = y.(int)` should (and does) escape a
value to the heap, but this detail is missed because the implicit
conversion of the multi-value expression `y.(int)` isn't visible to
escape analysis (because it's not inserted until desugaring during
walk).

For Unified IR, I plan to apply this desugaring earlier (because it's
necessary for correct dictionary handling), which means we'll
now (correctly) report the heap escape.

Due to limitations of the $GOROOT/test harness, the easiest way to
handle that GOEXPERIMENT=unified gets this right while
GOEXPERIMENT=nounified does not is to split the test case into
separate files. Hence this CL.

Change-Id: I91f3a6c015cbc646ab018747e152cac2874cf24c
Reviewed-on: https://go-review.googlesource.com/c/go/+/415241
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>
23 months ago[dev.unified] test: relax live_regabi.go
Matthew Dempsky [Thu, 30 Jun 2022 00:15:08 +0000 (17:15 -0700)]
[dev.unified] test: relax live_regabi.go

Unified IR will soon introduce additional temporary variables for
multi-valued expressions, which cause this test to start failing.
However, according to the comment on lines 594--596, we don't care
what temporaries are printed on the noisy lines, just that they're not
mentioned on the printnl lines.

This CL relaxes the test expectations so that temporaries are allowed
to be live at the call to fb38() too, not just the calls to fi38() and
fc38().

Change-Id: Ia6c5f28ccf760fd8890a4313fb0d9f0eb9850bba
Reviewed-on: https://go-review.googlesource.com/c/go/+/415240
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>
23 months agocmd/go: include module root in package index key
Bryan C. Mills [Thu, 30 Jun 2022 17:39:57 +0000 (13:39 -0400)]
cmd/go: include module root in package index key

The package index format includes the directory relative to the module
root. The module root for a given directory can change even if the
contents of the directory itself do not (by adding or removing a
go.mod file in some parent directory).

Thus, we need to invalidate the index for a package when its module
root location changes.

Fixes #53586 (I think).

Change-Id: I2d9f4de80e16bce75b3106a2bad4a11d8378d037
Reviewed-on: https://go-review.googlesource.com/c/go/+/415475
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocmd/go: add a 'sleep' command for script tests
Bryan C. Mills [Thu, 30 Jun 2022 17:30:48 +0000 (13:30 -0400)]
cmd/go: add a 'sleep' command for script tests

Due to mtime skew we don't index mutable packages with an mtime
younger than 2 seconds. In order to test indexed packages reliably, we
want to be able to sleep long enough for the files in the package to be cached.

(As an alternative we could instead use os.Chtimes to fake old enough
timestamps, but sleeping keeps the tests more realistic.)

For #53586.

Change-Id: I1873f47c55a72d928451593b8c989f0092a557db
Reviewed-on: https://go-review.googlesource.com/c/go/+/415474
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months ago[dev.unified] cmd/compile/internal/walk: fix typo in debug print
Matthew Dempsky [Thu, 30 Jun 2022 00:22:15 +0000 (17:22 -0700)]
[dev.unified] cmd/compile/internal/walk: fix typo in debug print

We want to print `init` here. We called `ir.TakeInit(r)` earlier, so
`r.Init()` always evaluates to nil at this point.

Change-Id: I196fdcfbf5e63c80b7bff0cce1881c9e58302501
Reviewed-on: https://go-review.googlesource.com/c/go/+/415239
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
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>
23 months agocmd/compile: fix prove pass when upper condition is <= maxint
Keith Randall [Wed, 29 Jun 2022 20:22:59 +0000 (13:22 -0700)]
cmd/compile: fix prove pass when upper condition is <= maxint

When the terminating condition is <= X, we need to make sure that
X+step doesn't overflow.

Fixes #53600

Change-Id: I36e5384d05b4d7168e48db6094200fcae409bfe5
Reviewed-on: https://go-review.googlesource.com/c/go/+/415219
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>

23 months agospec: retitle section on "Assignments" to "Assignment statements"
Robert Griesemer [Wed, 22 Jun 2022 18:58:06 +0000 (11:58 -0700)]
spec: retitle section on "Assignments" to "Assignment statements"

This permits a clear distinction between an individual assignment
and an assignment statement which may assign more than one value.
It also makes this section title consistent with all other section
titles about statements. Adjust internal links and prose where
appropriate. (Note that the spec already referred to assignment
statements in a couple of places, even before this change.)

Add an introductory paragraph to the section on assignment statements.

Preparation for adding a section on value vs reference types
(issue #5083).

Change-Id: Ie140ac296e653c67da2a5a203b63352b3dc4f9f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/413615
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months agotest: add regress test for #53619
Matthew Dempsky [Wed, 29 Jun 2022 22:39:01 +0000 (15:39 -0700)]
test: add regress test for #53619

Works with cmd/compile, but fails with gccgo currently.

Updates #53619.

Change-Id: I787faa9584cc33bd851c9cc8f146c91f4eb36fc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/415238
Reviewed-by: Ian Lance Taylor <iant@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>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

23 months agodebug/pe: add IMAGE_FILE_MACHINE_LOONGARCH{64,32}
Guoqi Chen [Fri, 10 Jun 2022 11:53:27 +0000 (19:53 +0800)]
debug/pe: add IMAGE_FILE_MACHINE_LOONGARCH{64,32}

Related: https://github.com/MicrosoftDocs/win32/pull/1067

Change-Id: I946253f217a5c616ae4a19be44634000cba5020e
Reviewed-on: https://go-review.googlesource.com/c/go/+/411616
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
23 months agonet/http: preserve nil values in Header.Clone
Damien Neil [Fri, 17 Jun 2022 17:09:45 +0000 (10:09 -0700)]
net/http: preserve nil values in Header.Clone

ReverseProxy makes a distinction between nil and zero-length header values.
Avoid losing nil-ness when cloning a request.

Thanks to Christian Mehlmauer for discovering this.

Fixes #53423
Fixes CVE-2022-32148

Change-Id: Ice369cdb4712e2d62e25bb881b080847aa4801f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/412857
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
23 months agocmd/internal/obj/arm64: save LR and SP in one instruction for small frames
Cherry Mui [Wed, 15 Jun 2022 19:09:24 +0000 (15:09 -0400)]
cmd/internal/obj/arm64: save LR and SP in one instruction for small frames

When we create a thread with signals blocked. But glibc's
pthread_sigmask doesn't really allow us to block SIGSETXID. So we
may get a signal early on before the signal stack is set. If we
get a signal on the current stack, it will clobber anything below
the SP. This CL makes it to save LR and decrement SP in a single
MOVD.W instruction for small frames, so we don't write below the
SP.

We used to use a single MOVD.W instruction before CL 379075.
CL 379075 changed to use an STP instruction to save the LR and FP,
then decrementing the SP. This CL changes it back, just this part
(epilogues and large frame prologues are unchanged). For small
frames, it is the same number of instructions either way.

This decreases the size of a "small" frame from 0x1f0 to 0xf0.
For frame sizes in between, it could benefit from using an
STP instruction instead of using the prologue for the "large"
frame case. We don't bother it for now as this is a stop-gap
solution anyway.

This only addresses the issue with small frames. Luckily, all
functions from thread entry to setting up the signal stack have
samll frames.

Other possible ideas:
- Expand the unwind info metadata, separate SP delta and the
  location of the return address, so we can express "SP is
  decremented but the return address is in the LR register". Then
  we can always create the frame first then write the LR, without
  writing anything below the SP (except the frame pointer at SP-8,
  which is minor because it doesn't really affect program
  execution).
- Set up the signal stack immediately in mstart in assembly.

For Go 1.19 we do this simple fix. We plan to do the metadata fix
in Go 1.20 ( #53609 ).

Other LR architectures are addressed in CL 413428.

Fix #53374.

Change-Id: I9d6582ab14ccb06ac61ad43852943d9555e22ae5
Reviewed-on: https://go-review.googlesource.com/c/go/+/412474
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Eric Fang <eric.fang@arm.com>
23 months agogo/token: use atomics not Mutex for last file cache
Alan Donovan [Wed, 29 Jun 2022 17:08:11 +0000 (13:08 -0400)]
go/token: use atomics not Mutex for last file cache

Previously, FileSet would cache the last *File found by a lookup,
using a full (exclusive) mutex within FileSet.File, turning a logical
read operation into an update. This was one of the largest sources
of contention in gopls.  This change uses atomic load/store on the
'last' field without a mutex.

Also, in FileSet.AddFile, allocate the File outside the critical
section; all the other operations are typically cheap.

Fixes #53507

Change-Id: Ice8641650d8495b25b0428e9b9320837ff2ca7e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/411909
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agonet/http: don't strip whitespace from Transfer-Encoding headers
Damien Neil [Wed, 1 Jun 2022 18:17:07 +0000 (11:17 -0700)]
net/http: don't strip whitespace from Transfer-Encoding headers

Do not accept "Transfer-Encoding: \rchunked" as a valid TE header
setting chunked encoding.

Thanks to Zeyu Zhang (https://www.zeyu2001.com/) for identifying
the issue.

Fixes #53188
Fixes CVE-2022-1705

Change-Id: I1a16631425159267f2eca68056b057192a7edf6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/409874
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
23 months agoruntime: add race annotations to cbs.lock
Michael Pratt [Tue, 28 Jun 2022 20:32:50 +0000 (16:32 -0400)]
runtime: add race annotations to cbs.lock

cbs.lock protects a map. The map implementation is race instrumented
regardless of which package is it called from.

lock/unlock are not automatically race instrumented, so we can trigger
race false positives without manually annotating our lock acquire and
release.

compileCallback is used during initialization before the P is available,
at which point raceacquire will crash during a racecallback to get the
race proc. Thus we skip instrumentation until scheduler initialization
is complete.

Fixes #50249.

Change-Id: Ie49227c9e9210ffbf0aee65f86f2b7b6a2f64638
Reviewed-on: https://go-review.googlesource.com/c/go/+/414518
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>

23 months ago[dev.unified] test: add regress test for generic select statements
Matthew Dempsky [Tue, 28 Jun 2022 23:30:29 +0000 (16:30 -0700)]
[dev.unified] test: add regress test for generic select statements

The Go 1.18 frontend ICEs on select case clauses that involve an
implicit conversion.

Change-Id: I1c0865bf97d8b0a8fbddb0da43333e909df0d38a
Reviewed-on: https://go-review.googlesource.com/c/go/+/414878
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>
23 months agocrypto/x509/pkix: move crl deprecation message
Roland Shoemaker [Tue, 28 Jun 2022 01:04:56 +0000 (18:04 -0700)]
crypto/x509/pkix: move crl deprecation message

There was a deprecation message on RevokedCertificate which was
intended to be on CertificateList.

Change-Id: Ia378935afc75c36702e64cf33ea5c8a24c1488ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/414754
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Tatiana Bradley <tatiana@golang.org>
23 months agocmd/internal/obj/mips,s390x,riscv: save LR after decrementing SP
Cherry Mui [Wed, 22 Jun 2022 20:28:41 +0000 (16:28 -0400)]
cmd/internal/obj/mips,s390x,riscv: save LR after decrementing SP

Following CL 412474, for the rest of the LR architectures. On
MIPS(32/64), S390X, and RISCV, there is no single instruction that
saves the LR and decrements the SP, so we need to insert an
instruction to save the LR after decrementing the SP.

On ARM(32) and PPC64 we already use a single instruction to save
the LR and decrement the SP.

Updates #53374.

Change-Id: I5a2e211026d95edb0e0f7d084ddb784f8077b86d
Reviewed-on: https://go-review.googlesource.com/c/go/+/413428
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

23 months agoruntime: add race annotations to metricsSema
Michael Pratt [Tue, 28 Jun 2022 19:17:12 +0000 (15:17 -0400)]
runtime: add race annotations to metricsSema

metricsSema protects the metrics map. The map implementation is race
instrumented regardless of which package is it called from.

semacquire/semrelease are not automatically race instrumented, so we can
trigger race false positives without manually annotating our lock
acquire and release.

See similar instrumentation on trace.shutdownSema and reflectOffs.lock.

Fixes #53542.

Change-Id: Ia3fd239ac860e037d09c7cb9c4ad267391e70705
Reviewed-on: https://go-review.googlesource.com/c/go/+/414517
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
23 months agocrypto/x509: improve RevocationList documentation
Roland Shoemaker [Mon, 27 Jun 2022 23:23:37 +0000 (16:23 -0700)]
crypto/x509: improve RevocationList documentation

Adds documentation for a handful of RevocationList fields.

Updates #50674

Change-Id: I26b838553d870b631deaf8b9a5b4d0b251fdef20
Reviewed-on: https://go-review.googlesource.com/c/go/+/414635
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
23 months agocmd/internal/obj/arm64: fix BITCON constant printing error
eric fang [Sun, 26 Jun 2022 09:39:09 +0000 (09:39 +0000)]
cmd/internal/obj/arm64: fix BITCON constant printing error

For some 32-bit instructions whose first operand is a constant, we
copy the lower 32 bits of the constant into the upper 32 bits in progedit,
which leads to the wrong value being printed in -S output.

The purpose of this is that we don't need to distinguish between 32-bit
and 64-bit constants when checking C_BITCON, this CL puts the modified
value in a temporary variable, so that the constant operand of the
instruction will not be modified.

Fixes #53551

Change-Id: I40ee9223b4187bff1c0a1bab7eb508fcb30325f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/414374
Run-TryBot: Eric Fang <eric.fang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
23 months agocmd/go: pass --no-decorate when listing git tags for a commit
hidu [Thu, 3 Mar 2022 05:33:38 +0000 (13:33 +0800)]
cmd/go: pass --no-decorate when listing git tags for a commit

This avoids a parse error when the user's global .gitconfig sets
log.decorate to true.

Fixes #51312.

Change-Id: Ic47b0f604c0c3a404ec50d6e09f4e138045ac2f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/387835
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
23 months agoos/exec: on Windows, suppress ErrDot if the implicit path matches the explicit one
Bryan C. Mills [Fri, 24 Jun 2022 19:36:25 +0000 (15:36 -0400)]
os/exec: on Windows, suppress ErrDot if the implicit path matches the explicit one

If the current directory is also listed explicitly in %PATH%,
this changes the behavior of LookPath to prefer the explicit name for it
(and thereby avoid ErrDot).

However, in order to avoid running a different executable from what
would have been run by previous Go versions, we still return the
implicit path (and ErrDot) if it refers to a different file entirely.

Fixes #53536.
Updates #43724.

Change-Id: I7ab01074e21a0e8b07a176e3bc6d3b8cf0c873cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/414054
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocmd/compile: fix generic inter-inter comparisons from value switch statements
Cuong Manh Le [Tue, 28 Jun 2022 17:07:37 +0000 (00:07 +0700)]
cmd/compile: fix generic inter-inter comparisons from value switch statements

If value is a non-empty interface and has shape, we still need to
convert it to an interface{} first.

Fixes #53477

Change-Id: I516063ba4429a6cc24c483758387ec13815fc63e
Reviewed-on: https://go-review.googlesource.com/c/go/+/414834
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

23 months agocmd/go/internal/modfetch: cache latest revinfo in Versions func
Baokun Lee [Sun, 1 May 2022 06:32:02 +0000 (14:32 +0800)]
cmd/go/internal/modfetch: cache latest revinfo in Versions func

The responses have been cached by the web2 package before removed
it in CL 170879. This change add latest revinfo cache in Versions
func.

Fixes #51391

Change-Id: I73597e0a6b4938238e69d85e1cbbaa9007776db3
Reviewed-on: https://go-review.googlesource.com/c/go/+/403335
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Lee Baokun <bk@golangcn.org>
Reviewed-by: David Chase <drchase@google.com>
23 months agotest: add more tests for const decls with ommitted RHS expressions
Robert Griesemer [Tue, 28 Jun 2022 17:51:53 +0000 (10:51 -0700)]
test: add more tests for const decls with ommitted RHS expressions

Add analogous tests to go/types and types2 test suites.
Make sure "assert" built-in is available in type-checker
tests.

For #49157.
For #53585.

Change-Id: I092901ecb43eb4833c09bd8f5e38efbe0285babe
Reviewed-on: https://go-review.googlesource.com/c/go/+/414795
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agotest: add test that gofrontend failed to compile
Ian Lance Taylor [Tue, 28 Jun 2022 05:11:38 +0000 (22:11 -0700)]
test: add test that gofrontend failed to compile

For #51475

Change-Id: Ie1b27304687225194a323dc8305e5d62578fff4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/414755
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
23 months agoruntime: clean up unused function gosave on loong64
Guoqi Chen [Mon, 30 May 2022 10:44:57 +0000 (18:44 +0800)]
runtime: clean up unused function gosave on loong64

Change-Id: I28960a33d251a36e5e364fa6e27c5b2e13349f6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/409354
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: David Chase <drchase@google.com>

23 months agocmd/go: omit build metadata that may contain system paths when -trimpath is set
Bryan C. Mills [Fri, 27 May 2022 19:54:44 +0000 (15:54 -0400)]
cmd/go: omit build metadata that may contain system paths when -trimpath is set

CGO flag variables often include system paths for header files and
compiled libraries. The point of -trimpath is to avoid dependending on
system paths, so stamping these variables is counterproductive.

Moreover, the point of stamping build information is to improve
reproducibility. Since we don't also stamp the versions of C
compilers, headers, and libraries used in a cgo build, only the most
trivial cgo programs can be faithfully reproduced from the stamped
information.

Likewise, the -ldflags flag may include system-specific paths,
particularly if external linking is in use. For now, we omit -ldflags
entirely; however, in the future we may instead want to parse and
redact the individual flags.

Fixes #52372.

Change-Id: I73318a01cce4371d66955b3261fc7ee58d4b33dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/409174
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>

23 months agoapi: correct debug/pe issue number for Go 1.19 changes
Russ Cox [Mon, 27 Jun 2022 21:48:57 +0000 (17:48 -0400)]
api: correct debug/pe issue number for Go 1.19 changes

It was #51868 not #51686.

For #53310.

Change-Id: I2cf28ca4de65e7030fdbd05e7f32fe42c8f3ca0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/414515
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
23 months agocmd/go/internal/modload: fix doc comment
Russ Cox [Thu, 9 Jun 2022 12:51:11 +0000 (08:51 -0400)]
cmd/go/internal/modload: fix doc comment

Change-Id: Ib7f47c7fc2fa5db3adbe51612b1e7a9bb49647b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/411105
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agogo/printer: report allocs and set bytes
Daniel Martí [Wed, 15 Jun 2022 20:19:04 +0000 (21:19 +0100)]
go/printer: report allocs and set bytes

We now get more than just time/op.

name      time/op
Print-16    6.29ms Â± 3%

name      speed
Print-16  8.25MB/s Â± 3%

name      alloc/op
Print-16     483kB Â± 0%

name      allocs/op
Print-16     17.8k Â± 0%

Change-Id: I6b5e9a30a826ff8603724bd5983e6b7f5ec12708
Reviewed-on: https://go-review.googlesource.com/c/go/+/412554
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months ago[dev.unified] cmd/compile: drop package height from Unified IR importer
Cuong Manh Le [Wed, 8 Jun 2022 04:05:28 +0000 (11:05 +0700)]
[dev.unified] cmd/compile: drop package height from Unified IR importer

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>

23 months ago[dev.unified] cmd/compile/internal/types2: remove package height
Cuong Manh Le [Mon, 6 Jun 2022 03:52:12 +0000 (10:52 +0700)]
[dev.unified] cmd/compile/internal/types2: remove package height

Same as CL 410342, but for types2.

Updates #51734

Change-Id: I6d6cb8fbb7567d3acf0b8cec0fa74f1344b56a1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/410347
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: Robert Griesemer <gri@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

23 months agonet: really skip Windows PTR tests if we say we are skipping them
Ian Lance Taylor [Mon, 27 Jun 2022 21:10:08 +0000 (14:10 -0700)]
net: really skip Windows PTR tests if we say we are skipping them

For #38111

Change-Id: I2651687367af68ee070ea91106f4bc18adab2762
Reviewed-on: https://go-review.googlesource.com/c/go/+/414634
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agonet: avoid darwin/arm64 platform bug in TestCloseWrite
Bryan C. Mills [Mon, 27 Jun 2022 17:58:55 +0000 (13:58 -0400)]
net: avoid darwin/arm64 platform bug in TestCloseWrite

On darwin_arm64, reading from a socket at the same time as the other
end is closing it will occasionally hang for 60 seconds before
returning ECONNRESET. (This is a macOS issue, not a Go issue.)

Work around this condition by adding a brief sleep before the read.

Fixes #49352 (we hope).
Updates #37795.

Change-Id: I4052aec21d311d7370550aea9dd7941f39141133
Reviewed-on: https://go-review.googlesource.com/c/go/+/414534
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agohtml/template: fix typo in content_test.go
SemihBKGR [Sun, 26 Jun 2022 03:27:08 +0000 (03:27 +0000)]
html/template: fix typo in content_test.go

esacped -> escaped

Change-Id: I253c46b30bb1cf7cdfb4668628907d16428fefb9
GitHub-Last-Rev: accd0e089f35b93c7e26725fcac5c048799db022
GitHub-Pull-Request: golang/go#53553
Reviewed-on: https://go-review.googlesource.com/c/go/+/414274
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Ian Lance Taylor <iant@google.com>

23 months agocmd/link: link against libsynchronization.a for -race on windows
Than McIntosh [Fri, 24 Jun 2022 19:31:35 +0000 (15:31 -0400)]
cmd/link: link against libsynchronization.a for -race on windows

As of LLVM rev 41cb504b7c4b18ac15830107431a0c1eec73a6b2, the
race detector runtime now refers to things in the windows
synchronization library, hence when doing windows internal
linking, at that library to the list of host archives that
we visit. The tsan code that makes the reference is here:

https://github.com/llvm/llvm-project/blob/41cb504b7c4b18ac15830107431a0c1eec73a6b2/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp#L48
https://github.com/llvm/llvm-project/blob/41cb504b7c4b18ac15830107431a0c1eec73a6b2/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp#L834

Note that libsynchronization.a is not guaranteed to be available on
all windows systems, so in the external linking case, check for its
existence before adding "-lsynchronization" to the external linker
args.

Updates #53539.

Change-Id: I433c95c869915693d59e9c1082d5b8a11da1fc8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/413817
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>

23 months agotest: add test that caused gofrontend crash
Ian Lance Taylor [Sun, 26 Jun 2022 22:17:23 +0000 (15:17 -0700)]
test: add test that caused gofrontend crash

For #52871

Change-Id: Id6102222a8b1ec8a84b716425bed0e349c65dbc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/414336
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
23 months agotest: add test that caused gofrontend crash
Ian Lance Taylor [Sat, 25 Jun 2022 00:13:30 +0000 (17:13 -0700)]
test: add test that caused gofrontend crash

The gofrontend crashed importing a complex 0 constant.

For #52862

Change-Id: Ia87d8eadb9c5ddf51e1cd65c1a626f05f0d068d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/413980
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
23 months agocmd/go: compile runtime/internal/syscall as a runtime package
Michael Pratt [Fri, 24 Jun 2022 20:50:59 +0000 (16:50 -0400)]
cmd/go: compile runtime/internal/syscall as a runtime package

runtime/internal/syscall is a runtime package, so it should be built
with -+.

Specifically, we don't want libfuzzer instrumentation in Go functions
defined in runtime/internal/syscall, which is disabled with -+.

For #53190.

Change-Id: I9f16f5c7c7ce10b98371e9de82fcea6da854e163
Reviewed-on: https://go-review.googlesource.com/c/go/+/413818
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocrypto/internal/boring: factor Cache into crypto/internal/boring/bcache
Russ Cox [Wed, 11 May 2022 19:11:29 +0000 (15:11 -0400)]
crypto/internal/boring: factor Cache into crypto/internal/boring/bcache

Requested by the maintainers of the OpenSSL-based fork of Go+BoringCrypto,
to make maintaining that fork easier.

Change-Id: I770e70ecc12b589034da31edecf59c73b2c6e1dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/407135
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>

23 months agoruntime: avoid fma in mkfastlog2table
Ian Lance Taylor [Fri, 24 Jun 2022 20:22:02 +0000 (13:22 -0700)]
runtime: avoid fma in mkfastlog2table

This lets us generate identical copies of fastlog2table.go on all hosts.

Tested by regenerating fastlog2table.go on linux-amd64 and darwin-arm64.

Fixes #49891

Change-Id: I279d6b5abb5a5290c049d9658050fd9c8d0c0190
Reviewed-on: https://go-review.googlesource.com/c/go/+/413976
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

23 months agotest: add test that gofrontend gets wrong
Ian Lance Taylor [Sat, 25 Jun 2022 22:40:11 +0000 (15:40 -0700)]
test: add test that gofrontend gets wrong

For #52856

Change-Id: Iab3e8352f64d774058391f0422cd01c53c3e711d
Reviewed-on: https://go-review.googlesource.com/c/go/+/414235
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

23 months agocmd/compile: do branch/label checks only once
Robert Griesemer [Sat, 25 Jun 2022 02:11:52 +0000 (19:11 -0700)]
cmd/compile: do branch/label checks only once

The previous change implemented the missing fallthrough checking
in the parser. Therefore we can now disable the duplicate check
in the type checker:

- rename (types2.Config.)IngoreLabels to IgnoreBranches to more
  accurately reflect its functionality

- now also ignore break/continue/fallthroughs, not just labels

The IgnoreBranches flag only exists for types2, for use with
the compiler. There's no need to port this code to go/types.

Note: An alternative (and perhaps better) approach would be
to not use the the parser's CheckBranches mode and instead
enable (i.e. not disable) the branch/label checking in the
type checker. However, this requires a bit more work because
the type checker's error messages about goto's jumping over
variables don't have access to the variable names, which are
desired in the error messages.

Fixes #51456.

Change-Id: Ib2e71e811d4e84e4895b729646e879fd43b12dcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/414135
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
23 months agocmd/compile/internal/syntax: check fallthrough in CheckBranches mode
Robert Griesemer [Fri, 24 Jun 2022 22:55:30 +0000 (15:55 -0700)]
cmd/compile/internal/syntax: check fallthrough in CheckBranches mode

The parser CheckBranches mode checked correct use of break, continue,
and labels, but not of fallthrough statements.

This CL adds checking of fallthrough statements as well.

For #51456.

Change-Id: I5000388011973724f80c59a6aaf015e3bb70faea
Reviewed-on: https://go-review.googlesource.com/c/go/+/414134
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months agoruntime: mark string comparison hooks as no split
Khaled Yakdan [Sat, 25 Jun 2022 05:17:45 +0000 (05:17 +0000)]
runtime: mark string comparison hooks as no split

These functions can be inserted by the compiler into the code to be
instrumented. This may result in these functions having callers that
are nosplit. That is why they must be nosplit.

This is a followup for CL 410034 in order to fix #53190.

Change-Id: I03746208a2a302a581a1eaad6c9d0672bb1e949a
GitHub-Last-Rev: 6506d86f221d745de083fad862bba7ba04a80455
GitHub-Pull-Request: golang/go#53544
Reviewed-on: https://go-review.googlesource.com/c/go/+/413978
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

23 months agoio: clarify SeekEnd offset value
HowJMay [Fri, 24 Jun 2022 04:02:10 +0000 (04:02 +0000)]
io: clarify SeekEnd offset value

fixes #53474

Change-Id: I14c3dc800dc27233630a54592328bb0df1bbaa5d
GitHub-Last-Rev: 46f93cfbd41c1b3274b570744f18d08e7759eb1e
GitHub-Pull-Request: golang/go#53505
Reviewed-on: https://go-review.googlesource.com/c/go/+/413614
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

23 months agocmd/go: prepend builtin prolog when checking for preamble errors
qmuntal [Thu, 20 Jan 2022 11:46:38 +0000 (12:46 +0100)]
cmd/go: prepend builtin prolog when checking for preamble errors

Fixes #50710

Change-Id: I62feddbe3eaae9605d196bec60d378614436603a
Reviewed-on: https://go-review.googlesource.com/c/go/+/379754
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
23 months agostrconv: avoid panic on invalid call to FormatFloat
Rémy Oudompheng [Fri, 29 Apr 2022 09:54:13 +0000 (11:54 +0200)]
strconv: avoid panic on invalid call to FormatFloat

Calling FormatFloat with an invalid value of fmt is expected
to return a string containing '%' and the input fmt character.
Since even before Go 1.0, the code has been panicking in the
case where prec=0.

Fixes #52187

Change-Id: I74fec601eedb7fe28efc5132c4253674661452aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/402817
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

23 months agointernal/trace: add Go 1.19 test data
Rhys Hiltner [Thu, 23 Jun 2022 16:43:47 +0000 (09:43 -0700)]
internal/trace: add Go 1.19 test data

Update instructions to match what seems to be the historical practice:
to generate canned traces when a version is finalized, rather than
waiting until it is superseded.

Follow rename of trace-internal tests from "Span" to "Region". Update
the net/http test invocation to match the apparent intent and the actual
http_1_5_good behavior (about 7ms of total run time and trace file size
under 50kB).

Change-Id: Ifd4c85882159478852e0b8f0d771b6f16b8f3c1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/413776
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
23 months agocmd/internal/archive: don't rely on an erroneous install target in tests
Bryan C. Mills [Fri, 24 Jun 2022 21:02:24 +0000 (17:02 -0400)]
cmd/internal/archive: don't rely on an erroneous install target in tests

Non-main packages in module mode should not be installed to
GOPATH/pkg, but due to #37015 they were installed there anyway.
This change switches the 'go install' command to instead use
'go build -buildmode=archive' with an explicit archive path.

For #37015.

Change-Id: Ib0c8f213100b6473a7657af96f31395703e28493
Reviewed-on: https://go-review.googlesource.com/c/go/+/414055
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>

23 months ago[dev.unified] all: merge master (5a1c5b8) into dev.unified
Matthew Dempsky [Fri, 24 Jun 2022 20:48:30 +0000 (13:48 -0700)]
[dev.unified] all: merge master (5a1c5b8) into dev.unified

Conflicts:

- test/run.go

  Textual conflict adding to the known failures list for the nounified
  frontend.

Merge List:

+ 2022-06-24 5a1c5b8ae7 cmd/go: add per-package indexing for modules outside mod cache
+ 2022-06-24 b9c4d94fdb cmd/go/internal/list: update help info with Deprecated field
+ 2022-06-24 73475ef035 go/types, types2: print qualified object names in cycle errors
+ 2022-06-24 3e58ef6cc7 go/types, types2: better errors for == when type sets are empty
+ 2022-06-24 d38f1d13fa doc/go1.19: Linux race detector now requires glibc 2.17
+ 2022-06-23 de5329f1de debug/dwarf: handle malformed line table with bad program offset
+ 2022-06-23 15605ca827 embed: document additional file name restrictions
+ 2022-06-22 2e773a3894 test: add test that causes gofrontend crash
+ 2022-06-22 ff17b7d0d4 cmd/compile: don't use dictionary convert to shaped empty interface
+ 2022-06-22 2a3b467d5f cmd/go: make module .zip files group/world readable
+ 2022-06-22 bdab4cf47a cmd/go, cmd/link: support failure to create _cgo_import.go
+ 2022-06-22 aca37d16a5 cmd/go: avoid indexing modules in GOROOT
+ 2022-06-22 111cdb5848 all: update to current golang.org/x/sys revision
+ 2022-06-22 4045b1bc3f cmd/compile: fix assert condition in generic method call
+ 2022-06-22 6bad7e8243 compress/gzip: always close bodyReader in Example_compressingReader
+ 2022-06-22 606c6c371a encoding/xml: check nil pointer in DecodeElement
+ 2022-06-22 f571518139 cmd/cgo: dont override declared struct type
+ 2022-06-22 92c9b81447 net: don't set netGo = true on Windows with no cgo
+ 2022-06-22 be0b2a393a cmd/trace: add basic documentation to main page
+ 2022-06-22 b004c739b5 go/types, types2: fix parameter order dependence in type inference
+ 2022-06-21 f2c7e78592 spec: document operations which accept []byte|string constrained types
+ 2022-06-21 ab422f2749 runtime/trace: ignore fallback stacks in test
+ 2022-06-21 66685fb7dd doc/go1.19: use correct link to sync/atomic docs
+ 2022-06-21 4b236b45d0 runtime: convert flaky semaphore linearity test into benchmark
+ 2022-06-21 530511bacc cmd/go/internal/modindex: avoid walking modules when not needed
+ 2022-06-21 c2d373d5d1 cmd/compile: allow 128-bit values to be spilled
+ 2022-06-21 19ed442807 test: add regress test for #53477
+ 2022-06-20 3fcbfb07a8 doc/go1.19: fix HTML validation issues
+ 2022-06-18 527ace0ffa cmd/compile: skip substituting closures in unsafe builtins arguments
+ 2022-06-17 ec58e3f327 test: add regress test for #53419
+ 2022-06-17 103cc661f1 cmd/go/internal/modfetch: prevent duplicate hashes in go.sum
+ 2022-06-17 d42a48828f sync: add more notes about Cond behavior
+ 2022-06-17 9e2f289754 cmd/go/internal/work: log clearer detail for subprocess errors in (*Builder).toolID
+ 2022-06-17 dd2d00f9d5 net: fix flaky *TimeoutMustNotReturn tests
+ 2022-06-17 6c25ba624f go/token: delete unused File.set field
+ 2022-06-16 9068c6844d cmd/dist: add package . to 'go test' commands
+ 2022-06-16 7bad61554e runtime: write much more direct test for semaphore waiter scalability
+ 2022-06-16 f38a580a51 cmd/go: add more tracing

Change-Id: I912c5879165e03f4d7f8ac3ee9241d50fc92a419

23 months agocmd/go: add per-package indexing for modules outside mod cache
Michael Matloob [Thu, 23 Jun 2022 19:46:29 +0000 (15:46 -0400)]
cmd/go: add per-package indexing for modules outside mod cache

Packages outside the module cache including the standard library will be
indexed individually rather than as a whole module.

For #52876

Change-Id: I142dad6a790e9e8eb4dc6430a588fbfa86552e49
Reviewed-on: https://go-review.googlesource.com/c/go/+/413815
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocmd/go/internal/list: update help info with Deprecated field
Sean Liao [Tue, 22 Mar 2022 22:00:22 +0000 (22:00 +0000)]
cmd/go/internal/list: update help info with Deprecated field

Also align Retracted documentation with actual type of []string

Fixes #51876

Change-Id: I3b34e53424aa7ee5330eb71adac23510fff91798
Reviewed-on: https://go-review.googlesource.com/c/go/+/394677
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
23 months agogo/types, types2: print qualified object names in cycle errors
Robert Griesemer [Fri, 24 Jun 2022 00:53:01 +0000 (17:53 -0700)]
go/types, types2: print qualified object names in cycle errors

Fixes #50788.

Change-Id: Id1ed7d9c0687e3005e28598373fd5634178c78ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/413895
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
23 months agogo/types, types2: better errors for == when type sets are empty
Robert Griesemer [Fri, 24 Jun 2022 03:54:52 +0000 (20:54 -0700)]
go/types, types2: better errors for == when type sets are empty

For #51525.

Change-Id: I3762bc4a48a1aaab3b006b1ad1400f866892243c
Reviewed-on: https://go-review.googlesource.com/c/go/+/413934
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
23 months agodoc/go1.19: Linux race detector now requires glibc 2.17
Ian Lance Taylor [Fri, 24 Jun 2022 00:23:39 +0000 (17:23 -0700)]
doc/go1.19: Linux race detector now requires glibc 2.17

Fixes #53522

Change-Id: Ibed838d358a733d26a6c3d89446d7fadb1012961
Reviewed-on: https://go-review.googlesource.com/c/go/+/413876
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months ago[dev.unified] cmd/compile: rename haveRType and implicitExpr
Matthew Dempsky [Thu, 23 Jun 2022 20:07:32 +0000 (13:07 -0700)]
[dev.unified] cmd/compile: rename haveRType and implicitExpr

This CL renames:

1. "haveRType" to "hasRType", suggested by drchase@ during review of
CL 413358; and

2. "implicitExpr" to "implicitConvExpr", suggested by khr@ during
review of CL 413396.

Change-Id: Ibb4deae20908d960706640991ea44d1b9c0b9e3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/413854
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
23 months ago[dev.unified] cmd/compile: implicit conversions for return statements
Matthew Dempsky [Tue, 21 Jun 2022 19:02:03 +0000 (12:02 -0700)]
[dev.unified] cmd/compile: implicit conversions for return statements

This CL inserts implicit conversions for simple N:N return
statements. A subsequent CL will handle N:1 return statements.

Change-Id: Ia672db3e214025510485e17d3d50d42ff01bc74e
Reviewed-on: https://go-review.googlesource.com/c/go/+/413517
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months ago[dev.unified] cmd/compile/internal/noder: implicit conversions for writer.assignStmt
Matthew Dempsky [Tue, 21 Jun 2022 19:51:01 +0000 (12:51 -0700)]
[dev.unified] cmd/compile/internal/noder: implicit conversions for writer.assignStmt

This CL inserts implicit conversions for simple N:N assignment
statements within Unified IR. A subsequent CL will handle N:1
assignments.

Change-Id: I7e204c6ee9ffdb9fa2bc9146315fd79735c04628
Reviewed-on: https://go-review.googlesource.com/c/go/+/413516
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>

23 months ago[dev.unified] cmd/compile/internal/noder: refactor stmtAssign generation
Matthew Dempsky [Tue, 21 Jun 2022 18:49:27 +0000 (11:49 -0700)]
[dev.unified] cmd/compile/internal/noder: refactor stmtAssign generation

Eliminate some code duplication between assignment statements and
variable declarations, so they're easier to extend with implicit
conversions.

Change-Id: I605cf7817e3cb230f2c4612b777d8023c926e8b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/413515
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months ago[dev.unified] cmd/compile/internal/noder: implicit conversion of call arguments
Matthew Dempsky [Tue, 21 Jun 2022 18:31:11 +0000 (11:31 -0700)]
[dev.unified] cmd/compile/internal/noder: implicit conversion of call arguments

Function call arguments need to be implicitly converted to their
respective parameter types. This CL updates the Unified IR writer to
handle this case, at least for typical function calls. I'll handle
f(g()) calls is a subsequent CL.

Change-Id: I7c031d21f57885c9516eaf89eca517977bf9e39a
Reviewed-on: https://go-review.googlesource.com/c/go/+/413514
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>

23 months ago[dev.unified] cmd/compile/internal/noder: remove needType logic
Matthew Dempsky [Tue, 21 Jun 2022 14:56:25 +0000 (07:56 -0700)]
[dev.unified] cmd/compile/internal/noder: remove needType logic

This logic is a holdover from very early on when it wasn't as clear
how we would handle dictionary entries for derived types, particularly
ones that are emitted during desugaring.

However, the current plan is to explicitly wire runtime type info
through IR nodes, so we can drop this logic.

Notably, the "needed" bit is exposed to the go/types importers, so
removing it would break the x/tools importer. To minimize churn for
now, we can just leave the bools in place.

Change-Id: I374927887d4f3d6d711d3355607849a407d717c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/413367
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

23 months ago[dev.unified] cmd/compile/internal/noder: implicit conversions for complits
Matthew Dempsky [Tue, 21 Jun 2022 14:39:23 +0000 (07:39 -0700)]
[dev.unified] cmd/compile/internal/noder: implicit conversions for complits

Operands within a composite literal must be implicitly converted to
their respective key/element type.

Change-Id: Idc12eba1559e9c9ffebd03395cd91473dd5fc2db
Reviewed-on: https://go-review.googlesource.com/c/go/+/413364
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
23 months ago[dev.unified] cmd/compile/internal/noder: start writing implicit conversions
Matthew Dempsky [Tue, 21 Jun 2022 14:07:41 +0000 (07:07 -0700)]
[dev.unified] cmd/compile/internal/noder: start writing implicit conversions

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>

23 months ago[dev.unified] cmd/compile/internal/noder: add pkgWriter.typeOf helper
Matthew Dempsky [Tue, 21 Jun 2022 13:36:28 +0000 (06:36 -0700)]
[dev.unified] cmd/compile/internal/noder: add pkgWriter.typeOf helper

Getting the type of a value expression is already a very common
operation during writing, and it's going to become more common to
handle implicit conversions.

Change-Id: I5401c6b01546bbf8e85b1ed3fe4acf2835925e2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/413395
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months ago[dev.unified] cmd/compile/internal/typecheck: replace unreachable code with assert
Matthew Dempsky [Tue, 21 Jun 2022 12:22:00 +0000 (05:22 -0700)]
[dev.unified] cmd/compile/internal/typecheck: replace unreachable code with assert

Since the removal of -G=0 mode, IR is always well-typed. And in
well-typed IR, convlit will always returns expressions having real
types (i.e., not untyped).

Change-Id: I1ac99a88c94777829852519347a716d19af7948c
Reviewed-on: https://go-review.googlesource.com/c/go/+/413363
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
23 months ago[dev.unified] cmd/compile: special case f(g()) calls in Unified IR
Matthew Dempsky [Tue, 21 Jun 2022 11:41:38 +0000 (04:41 -0700)]
[dev.unified] cmd/compile: special case f(g()) calls in Unified IR

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>

23 months ago[dev.unified] cmd/compile: plumb rtype through OSWITCH/OCASE clauses
Matthew Dempsky [Tue, 21 Jun 2022 09:30:21 +0000 (02:30 -0700)]
[dev.unified] cmd/compile: plumb rtype through OSWITCH/OCASE clauses

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>

23 months ago[dev.unified] cmd/compile: plumb rtype through for OMAPLIT
Matthew Dempsky [Tue, 21 Jun 2022 09:29:49 +0000 (02:29 -0700)]
[dev.unified] cmd/compile: plumb rtype through for OMAPLIT

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>

23 months ago[dev.unified] cmd/compile: start setting RType fields for Unified IR
Matthew Dempsky [Tue, 21 Jun 2022 07:57:18 +0000 (00:57 -0700)]
[dev.unified] cmd/compile: start setting RType fields for Unified IR

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>
23 months ago[dev.unified] cmd/compile: add RType fields
Matthew Dempsky [Tue, 21 Jun 2022 06:21:16 +0000 (23:21 -0700)]
[dev.unified] cmd/compile: add RType fields

This CL adds RType/ITab fields to IR nodes that (may) ultimately
become runtime calls that require a *runtime._type or *runtime.itab
argument. It also updates the corresponding reflectdata IR helpers to
use these fields in preference of calling TypePtr/ITabAddr.

Subsequent CLs will start updating the GOEXPERIMENT=unified frontend
to set the RType fields, and incrementally switch the reflectdata
helpers to require them.

Passes toolstash -cmp.

Change-Id: I30e31d91f0a53961e3d6d872d7b5f9df2ec5074c
Reviewed-on: https://go-review.googlesource.com/c/go/+/413358
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

23 months agodebug/dwarf: handle malformed line table with bad program offset
Than McIntosh [Thu, 23 Jun 2022 18:11:59 +0000 (14:11 -0400)]
debug/dwarf: handle malformed line table with bad program offset

Touch up the line table reader to ensure that it can detect and reject
an invalid program offset field in the table header.

Fixes #53329.

Change-Id: Ia8d684e909af3aca3014b4a3d0dfd431e3f5a9f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/413814
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months agoembed: document additional file name restrictions
tulip [Tue, 21 Jun 2022 16:42:29 +0000 (00:42 +0800)]
embed: document additional file name restrictions

For #44486

Change-Id: I66af9f7a9f95489a41fd6710e50bdd7878f78b85
Reviewed-on: https://go-review.googlesource.com/c/go/+/413494
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

23 months agotest: add test that causes gofrontend crash
Ian Lance Taylor [Wed, 22 Jun 2022 23:02:45 +0000 (16:02 -0700)]
test: add test that causes gofrontend crash

For #52846

Change-Id: I763f81def97b53277396c123c524f7b8193ea35e
Reviewed-on: https://go-review.googlesource.com/c/go/+/413694
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
23 months agocmd/compile: don't use dictionary convert to shaped empty interface
Wayne Zuo [Tue, 7 Jun 2022 01:12:21 +0000 (09:12 +0800)]
cmd/compile: don't use dictionary convert to shaped empty interface

Fixes: #53254
Change-Id: I3153d6ebb9f25957b09363f45c5cd4651ee84c2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/410655
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
23 months agocmd/go: make module .zip files group/world readable
Dmitri Goutnik [Sat, 7 May 2022 21:10:16 +0000 (16:10 -0500)]
cmd/go: make module .zip files group/world readable

os.CreateTemp in downloadZip leaves downloaded .zip files readable only
by the owner. Make them group/world readable.

Fixes #52765

Change-Id: Iace13e4ad813201a533a1a5fc0c6d9b2e5349a42
Reviewed-on: https://go-review.googlesource.com/c/go/+/404854
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>

23 months agocmd/go, cmd/link: support failure to create _cgo_import.go
Ian Lance Taylor [Wed, 22 Jun 2022 01:11:32 +0000 (18:11 -0700)]
cmd/go, cmd/link: support failure to create _cgo_import.go

For a package that uses cgo, the file _cgo_import.go is created to
record information required for internal linking: the non-Go dynamic
symbols and libraries that the package depends on. Generating this
information sometimes fails, because it can require recreating all the
dependencies of all transitively imported packages. And the
information is rarely needed, since by default we use external linking
when there are packages outside of the standard library that use cgo.

With this CL, if generating _cgo_import.go fails, we don't report an
error. Instead, we mark the package as requiring external linking, by
adding an empty file named "dynimportfail" into the generated archive.
If the linker sees a file with that name, it rejects an attempt to use
internal linking.

Fixes #52863

Change-Id: Ie586e6753a5b67e49bb14533cd7603d9defcf0ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/413460
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocmd/go: avoid indexing modules in GOROOT
Bryan C. Mills [Wed, 22 Jun 2022 19:19:54 +0000 (15:19 -0400)]
cmd/go: avoid indexing modules in GOROOT

Scanning GOROOT modules for changes appears to be causing Windows
builders to time out in x/tools tests. We may try a per-package index
instead, but for now just skip GOROOT modules (as we do for main
modules).

Fixes #53493.

Change-Id: Ic5bb90b4ce173a24fc6564e85fcde96e1f9b975f
Reviewed-on: https://go-review.googlesource.com/c/go/+/413634
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
23 months agoall: update to current golang.org/x/sys revision
Guoqi Chen [Wed, 15 Jun 2022 11:07:24 +0000 (19:07 +0800)]
all: update to current golang.org/x/sys revision

go get -d golang.org/x/sys@6c1b26c55098eae66ce95ab7c3712ab6cbfff2b7
go mod tidy
go mod vendor

This fixes the problem of the second return value in syscall on linux/loong64.

Change-Id: I8018ae96f4e5ca9779b2c053cdccc6b2866bf0de
Reviewed-on: https://go-review.googlesource.com/c/go/+/412274
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agocmd/compile: fix assert condition in generic method call
Wayne Zuo [Thu, 16 Jun 2022 03:05:39 +0000 (11:05 +0800)]
cmd/compile: fix assert condition in generic method call

Fixes #53406.

Change-Id: If7ae39ec1042a792d82a0a2de96d168c22d8ab71
Reviewed-on: https://go-review.googlesource.com/c/go/+/412614
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Rakoczy <alex@golang.org>
Auto-Submit: Alex Rakoczy <alex@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>

23 months agocompress/gzip: always close bodyReader in Example_compressingReader
Ian Lance Taylor [Fri, 17 Jun 2022 20:38:07 +0000 (13:38 -0700)]
compress/gzip: always close bodyReader in Example_compressingReader

For #53362
Fixes #53414

Change-Id: I352164e70c136eed210c7ee4ceba5dc631f81f94
Reviewed-on: https://go-review.googlesource.com/c/go/+/412955
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Alex Rakoczy <alex@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agoencoding/xml: check nil pointer in DecodeElement
shaoliming [Fri, 17 Jun 2022 05:01:26 +0000 (05:01 +0000)]
encoding/xml: check nil pointer in DecodeElement

Fixes #53350

Change-Id: Id5e1f4016db5f1d4349ee1a76a9dfe3aeae83cee
GitHub-Last-Rev: 45add121612a8144c2525828bd7386c4adb05174
GitHub-Pull-Request: golang/go#53407
Reviewed-on: https://go-review.googlesource.com/c/go/+/412634
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Rakoczy <alex@golang.org>
23 months agocmd/cgo: dont override declared struct type
kkHAIKE [Wed, 11 May 2022 02:27:21 +0000 (02:27 +0000)]
cmd/cgo: dont override declared struct type

Fixes #52611

Change-Id: I835df8d6a98a37482446ec00af768c96fd8ee4fe
GitHub-Last-Rev: ea54dd69eef90eaf1641889039344fff70158ece
GitHub-Pull-Request: golang/go#52733
Reviewed-on: https://go-review.googlesource.com/c/go/+/404497
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dexter Ouyang <kkhaike@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Alex Rakoczy <alex@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agonet: don't set netGo = true on Windows with no cgo
Ian Lance Taylor [Tue, 21 Jun 2022 22:17:22 +0000 (15:17 -0700)]
net: don't set netGo = true on Windows with no cgo

Windows can call the C DNS lookup routines even without cgo,
so don't force it to use the Go routines in that scenario.

No test because the test requires building the tools with CGO_ENABLED=0.

For #33097
Fixes #53490

Change-Id: I3595a68e788be0d3bbd1bbd431836aca20a7d757
Reviewed-on: https://go-review.googlesource.com/c/go/+/413458
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

23 months agocmd/trace: add basic documentation to main page
Alan Donovan [Fri, 17 Jun 2022 14:32:52 +0000 (10:32 -0400)]
cmd/trace: add basic documentation to main page

This change adds rudimentary explanation of the various
visualizations to main page of the trace server.
There is clearly a vast amount one could write here,
especially in the form of tutorials, but I've tried to
restrict it to just basic conceptual overview.

Change-Id: Id4dfe9d47f9b31ed5f8fe39f8b3a7c60c0ae8d5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/412876
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months agogo/types, types2: fix parameter order dependence in type inference
Robert Griesemer [Tue, 21 Jun 2022 22:56:16 +0000 (15:56 -0700)]
go/types, types2: fix parameter order dependence in type inference

If we have more than two function arguments to a generic function,
we may have arguments with named and unnamed types. If that is the
case, permutate params and args such that the arguments with named
types are first in the list. This way, independent of parameter
ordering, the type inference will produce the same result.

This extra step is not explicitly outlined in the spec yet but we
all agree that (parameter) order independence is an invariant that
we should uphold for type inference. As we move towards less
operational and more descriptive rules for type inference, we will
incorporate this property as well.

The actual fix for this bug existed before 1.18 but was not enabled.
This CL merely enables the fix (switches a flag) and adjusts some
tests.

Fixes #43056.

Change-Id: Ie4e40cf8438dfd82fa94b78068e4f6f6f53f83e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/413459
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
23 months ago[dev.unified] cmd/compile: avoid reflectType in ssagen
Matthew Dempsky [Tue, 21 Jun 2022 05:28:15 +0000 (22:28 -0700)]
[dev.unified] cmd/compile: avoid reflectType in ssagen

This CL adds alternate code paths for the frontend to plumb through
rtypes to package ssagen, so the latter doesn't have to use
reflectType (which in general will only have access to shape types).

Note: This CL doesn't yet plumb through the rtypes for variables that
escape to the heap. However, those rtypes are only used for calling
runtime.newobject, and the status quo as of Go 1.18 is already to use
shape rtypes for most runtime.newobject calls. (Longer term though, I
would like to get rid of shape rtypes altogether.)

Passes toolstash -cmp.

Updates #53276.

Change-Id: I76a281eca8300de2e701fbac89ead32f8568a5f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/413357
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
23 months ago[dev.unified] cmd/compile: extract rtype code from walk
Matthew Dempsky [Tue, 14 Jun 2022 23:07:46 +0000 (16:07 -0700)]
[dev.unified] cmd/compile: extract rtype code from walk

This CL removes (almost*) all reflectdata.{TypePtr,ITabAddr} calls
from package walk. This will allow us to next start adding RType/ITab
fields to IR nodes directly, and have the helpers start returning them
when available instead.

The one survining ITabAddr call is due to ODOTTYPE{,2}, but we already
have ODYNAMICDOTTYPE{,2}, which I plan to have Unified IR always
use. (Longer term, once the Go 1.18 frontend is gone, we can get rid
of ODOTTYPE*, and rename ODYNAMICDOTTYPE*.)

Passes toolstash -cmp.

Change-Id: I5e00da06a93d069abf383d7628e692dd7fd2a1c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/413356
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

23 months ago[dev.unified] cmd/compile: refactor reflectdata.{TypePtr,ITabAddr}
Matthew Dempsky [Tue, 14 Jun 2022 23:11:17 +0000 (16:11 -0700)]
[dev.unified] cmd/compile: refactor reflectdata.{TypePtr,ITabAddr}

Minor refactoring to decouple from base.Pos and deduplicate some
common code paths.

Passes toolstash -cmp.

Change-Id: I8c0724cf821d28b0ede3b0e8e4b2d02302d9af3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/413355
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
23 months agospec: document operations which accept []byte|string constrained types
Robert Griesemer [Wed, 15 Jun 2022 01:30:44 +0000 (18:30 -0700)]
spec: document operations which accept []byte|string constrained types

Pre-1.18, as special cases, the built-in operations append and copy
accepted strings as second arguments if the first argument was a byte
slice. With Go 1.18, these two built-ins as well as slice expressions
rely on the notion of core types in their specification.

Because we want to permit slice expressions, append, and copy to
operate on (1st or 2nd operands) that are type parameters restricted
by []byte | string (and variations thereof), the simple notion of
core type is not sufficient for these three operations. (The compiler
already permits such more relaxed operations).

In the section on core types, add a paragraph and examples introducing
the (artificial) core type "bypestring", which describes the core type
of type sets whose underlying types are []byte or string. Adjust the
rules for slice expressions, append, and copy accordingly.

Also (unrelated): Adjust prose in the only paragraph where we used
personal speech ("we") to impersonal speech, to match the rest of
the spec.

Fixes #52859.

Change-Id: I1cbda3095a1136fb99334cc3a62a9a349a27ce1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/412234
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
23 months agoruntime/trace: ignore fallback stacks in test
Rhys Hiltner [Tue, 21 Jun 2022 19:28:48 +0000 (12:28 -0700)]
runtime/trace: ignore fallback stacks in test

When runtime.sigprof encounters a stack that gentraceback is unable to
process, it synthesizes a call stack with a sentinel function (such as
runtime._System) at the leaf.

The test to confirm that runtime/trace and runtime/pprof have similar
views of CPU profile samples has trouble with those stacks. The test
confirms that the samples match by confirming that their symbolized
forms match, and the symbolization procedure is very different for the
two packages.

Skip the samples that the CPU profiler's view symbolizes to include one
of runtime.sigprof's sentinel functions at the leaf. (The test design
expects the CPU profiler to under-report samples relative to the
execution tracer.)

Fixes #53378

Change-Id: I60c27de4c69b454057d28a3b6e12d70369de4c4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/413457
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
23 months agodoc/go1.19: use correct link to sync/atomic docs
Ian Lance Taylor [Mon, 20 Jun 2022 05:57:10 +0000 (22:57 -0700)]
doc/go1.19: use correct link to sync/atomic docs

For #51400
Fixes #53453

Change-Id: Ie11182a16299cf26d03970d6aa9bfe03caa56ea4
Reviewed-on: https://go-review.googlesource.com/c/go/+/413235
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>