]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
13 months agonet/http: let ErrNotSupported match errors.ErrUnsupported
Ian Lance Taylor [Wed, 10 May 2023 19:47:06 +0000 (12:47 -0700)]
net/http: let ErrNotSupported match errors.ErrUnsupported

For #41198

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

13 months agogo/types, types2: move xlist next to targs in Checker.arguments signature
Robert Griesemer [Wed, 10 May 2023 16:06:33 +0000 (09:06 -0700)]
go/types, types2: move xlist next to targs in Checker.arguments signature

targs and xlist belong together (xlist contains the type expressions for
each of the type arguments).

Also, in builtins.go, rename xlist to alist2 to avoid some confusion.

Preparation for adding more parameters to the Checker.arguments signature.

Change-Id: I960501cfd2b88410ec0d581a6520a4e80fcdc56a
Reviewed-on: https://go-review.googlesource.com/c/go/+/494121
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
13 months agocmd/compile: add De Morgan's rewrite rule
Stefan [Wed, 10 May 2023 01:34:47 +0000 (01:34 +0000)]
cmd/compile: add De Morgan's rewrite rule

Adds rules that rewrites statements such as ~P&~Q as ~(P|Q) and ~P|~Q as ~(P&Q), removing an extraneous instruction.

Change-Id: Icedb97df741680ddf9799df79df78657173aa500
GitHub-Last-Rev: f22e2350c95e9052e990b2351c3c2b0af810e381
GitHub-Pull-Request: golang/go#60018
Reviewed-on: https://go-review.googlesource.com/c/go/+/493175
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Stefan M <st3f4nm4d4@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
13 months agogo/types, types2: control type inference in Checker.funcInst via infer argument
Robert Griesemer [Tue, 9 May 2023 22:40:36 +0000 (15:40 -0700)]
go/types, types2: control type inference in Checker.funcInst via infer argument

If the infer argument is true, funcInst behaves as before.
If infer is false and there are not enough type arguments,
rather then inferring the missing arguments and instantiating
the function, funcInst returns the found type arguments.

This permits the use of funcInst (and all the checks it does)
to collect the type arguments for partially instantiated
generic functions used as arguments to other functions.

For #59338.

Change-Id: I049034dfde52bd7ff4ae72964ff1708e154e5042
Reviewed-on: https://go-review.googlesource.com/c/go/+/494118
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
13 months agocmd/go/internal: update documentation of go test and go generate
Shogo Hida [Wed, 10 May 2023 14:41:06 +0000 (14:41 +0000)]
cmd/go/internal: update documentation of go test and go generate

Fixes #57050

Change-Id: I46cac667ff78ac171c878f4366f8f01f58f1d27d
GitHub-Last-Rev: 697c255ece18cd4772b76d62991474a7da2536d8
GitHub-Pull-Request: golang/go#57814
Reviewed-on: https://go-review.googlesource.com/c/go/+/461683
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
13 months agocmd/go/internal/modload: skip reading go.mod files for imports in 'go mod tidy' of...
Bryan C. Mills [Fri, 5 May 2023 20:50:56 +0000 (16:50 -0400)]
cmd/go/internal/modload: skip reading go.mod files for imports in 'go mod tidy' of modules before 'go 1.21'

This eliminate a network access in 'go mod tidy' of an already-tidy
module, which would otherwise be needed to fetch go.mod checksums for
the test dependencies whose go.mod checksums were omitted in Go
releases between Go 1.17 and 1.20 due to bug #56222.

For modules between 'go 1.17' and 'go 1.20' we intentionally preserve
the old 'go mod tidy' output (omitting go.sum entries for the go.mod
files of test dependencies of external packages). We should also avoid
performing extra sumdb lookups for checksums that would be discarded
anyway.

Updates #56222.

Change-Id: I7f0f1c8e902db0e3414c819621c4b99052f503f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/492741
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

13 months agocmd/internal/obj/riscv: regenerate instruction encoding table
Meng Zhuo [Sat, 6 May 2023 09:34:41 +0000 (17:34 +0800)]
cmd/internal/obj/riscv: regenerate instruction encoding table

This CL updates riscv instructions by
https://github.com/riscv/riscv-opcodes

which adds instruction:
APAUSE

And removes the following unused instructions:
AFENCEI
AFMVQX
AFMVXQ
AHFENCEGVMA
AHFENCEVVMA
ASLLIRV32
ASRAIRV32
ASRLIRV32
AURET

Change-Id: I314570c643af3e6bbc9d2cd471b6b39985bcbdff
Reviewed-on: https://go-review.googlesource.com/c/go/+/409415
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: M Zhuo <mzh@golangcn.org>

13 months agogo/types, types2: explicitly look for nil type arguments in infer
Robert Griesemer [Tue, 9 May 2023 21:02:07 +0000 (14:02 -0700)]
go/types, types2: explicitly look for nil type arguments in infer

Don't assume we have all type arguments if the number of type arguments
matches the number of type parameters. Instead, look explicitly for nil
type arguments in the provided targs.

Preparation for type inference with type arguments provided for type
parameters of generic function arguments passed to other functions.

For #59338.

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

13 months agoencoding/csv: update doc comment of Read method
IvoGoman [Tue, 9 May 2023 20:46:23 +0000 (20:46 +0000)]
encoding/csv: update doc comment of Read method

This updates the doc comment to reflect the behavior of the method.
On error the method returns a partial result.

Fixes #59991

Change-Id: I71e9dfa37e0488c85abd3eeede2a1a34cb74239b
GitHub-Last-Rev: 389488e5364dc939f0cbd11f99eb56001b5237a2
GitHub-Pull-Request: golang/go#60084
Reviewed-on: https://go-review.googlesource.com/c/go/+/494055
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

13 months agoall: fix a lot of comments
cui fliter [Fri, 5 May 2023 16:11:33 +0000 (00:11 +0800)]
all: fix a lot of comments

Fix comments, including duplicate is, wrong phrases and articles, misspellings, etc.

Change-Id: I8bfea53b9b275e649757cc4bee6a8a026ed9c7a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/493035
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

13 months agolog/slog: test built-in handlers with slogtest
Jonathan Amsterdam [Mon, 24 Apr 2023 18:19:20 +0000 (14:19 -0400)]
log/slog: test built-in handlers with slogtest

Test the built-in handlers using the testing/slogtest package.

Change-Id: I6464b6730293461c38b84fb2bf33cdd09173dd6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/488255
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

13 months agolog/slog: add json struct tags to Source
Jonathan Amsterdam [Tue, 9 May 2023 20:22:09 +0000 (16:22 -0400)]
log/slog: add json struct tags to Source

Add tags to the fields of Source that lower-cases their names for JSON.
The implementation still treats Source specially for performance, but
now the result would be identical if it did not.

Change-Id: I5fd2e500f1a301db62af87be8b877ecd954a26ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/494035
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

13 months agocmd: use slices.Equal to simplify code
cui fliter [Thu, 4 May 2023 11:30:53 +0000 (19:30 +0800)]
cmd: use slices.Equal to simplify code

#57433 added slices.Equal, using it can reduce the amount of code

Change-Id: I70d14b6c4c24da641a34ed36c900d9291033f526
Reviewed-on: https://go-review.googlesource.com/c/go/+/492576
Reviewed-by: Than McIntosh <thanm@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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>

13 months agoruntime: fix misaligned SP for libfuzzer entry
Keith Randall [Tue, 9 May 2023 22:55:45 +0000 (15:55 -0700)]
runtime: fix misaligned SP for libfuzzer entry

libfuzzer is written in C and so requires by the C abi that SP be
aligned correctly mod 16. Normally CALLs need to have SP aligned to 0
mod 16, but because we're simulating a CALL (which pushes a return
address) with a JMP (which doesn't), we need to align to 8 mod 16
before JMPing.

This is not causing any current problems that I know of. All the
functions called from this callsite that I checked don't rely on
correct alignment.  So this CL is just futureproofing.

Update #49075

Change-Id: I13fcbe9aaf2853056a6d44dc3aa64b7db689e144
Reviewed-on: https://go-review.googlesource.com/c/go/+/494117
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
13 months agosyscall,internal/poll: move pipe check from syscall.Seek to callers
qmuntal [Tue, 9 May 2023 14:16:42 +0000 (16:16 +0200)]
syscall,internal/poll: move pipe check from syscall.Seek to callers

On Windows, syscall.Seek is a thin wrapper over SetFilePointerEx [1],
which does not work on pipes, although it doesn't return an error on
that case. To avoid this undefined behavior, Seek defensively
calls GetFileType and errors if the type is FILE_TYPE_PIPE.

The problem with this approach is that Seek is a low level
foundational function that can be called many times for the same file,
and the additional cgo call (GetFileType) will artificially slow
down seek operations. I've seen GetFileType to account for 10% of cpu
time in seek-intensive workloads.

A better approach, implemented in this CL, would be to move the check
one level up, where many times the file type is already known so the
GetFileType is unnecessary.

The drawback is that syscall.Seek has had this behavior since pipes
where first introduced to Windows in
https://codereview.appspot.com/1715046 and someone could be relying on
it. On the other hand, this behavior is not documented, so we couldn't
be breaking any contract.

[1] https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-setfilepointerex

Change-Id: I7602182f9d08632e22a8a1635bc8ad9ad35a5056
Reviewed-on: https://go-review.googlesource.com/c/go/+/493626
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
13 months agointernal/bisect: adjust stack PCs relative to Callers[2]
David Chase [Tue, 9 May 2023 19:03:48 +0000 (15:03 -0400)]
internal/bisect: adjust stack PCs relative to Callers[2]

This is necessary to make hashes be consistent across runs,
otherwise ASLR messes up search.

Change-Id: Icf668dfe4c2008709f7767397b6700d0d5439287
Reviewed-on: https://go-review.googlesource.com/c/go/+/493857
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>

13 months agocmd/go: fix cgo prefix mapping for non-vendored modules
qmuntal [Tue, 9 May 2023 11:02:26 +0000 (13:02 +0200)]
cmd/go: fix cgo prefix mapping for non-vendored modules

Regression introduced in CL 478455.

Change-Id: I8083a0accb047188dde1a3d408df2aafaf4a5356
Reviewed-on: https://go-review.googlesource.com/c/go/+/493835
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>

13 months agoruntime: exclude extra M's from debug.SetMaxThreads
Michael Pratt [Fri, 5 May 2023 20:58:43 +0000 (16:58 -0400)]
runtime: exclude extra M's from debug.SetMaxThreads

The purpose of the debug.SetMaxThreads limit is to avoid accidental fork
bomb from something like millions of goroutines blocking on system
calls, causing the runtime to create millions of threads.

By definition we don't create threads created in C, so this isn't a
problem for those threads, and we can exclude them from the limit. If C
wants to create tens of thousands of threads, who are we to say no?

Fixes #60004.

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

13 months agomisc/wasm: add wasmer to wasip1 script
Johan Brandhorst-Satzkorn [Tue, 9 May 2023 05:21:19 +0000 (22:21 -0700)]
misc/wasm: add wasmer to wasip1 script

The wasmer runtime will be used to test our wasip1
implementation against the WASI runtime from wasmer.io.

For #59907

Change-Id: Ie7e48c39e03075815ddca46d996b6ec87009b12a
Reviewed-on: https://go-review.googlesource.com/c/go/+/493775
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
13 months agocmd/compile: remove FS debug hash form
Russ Cox [Tue, 9 May 2023 03:31:00 +0000 (23:31 -0400)]
cmd/compile: remove FS debug hash form

The FS form was only necessary for reliable hashes in tests,
and for that we can use -trimpath.

Another potential concern would be temporary work directory
names leaking into the names of files generated by cgo and the
like, but we already make sure to avoid those to ensure
reproducible builds: the compiler never sees those paths.
So the FS form is not necessary for that either.

Change-Id: Idae2c6acb22ab64dfb33bb053244d23fbe153830
Reviewed-on: https://go-review.googlesource.com/c/go/+/493737
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
13 months agocmd/compile: use more of internal/bisect in HashDebug
Russ Cox [Tue, 9 May 2023 03:18:38 +0000 (23:18 -0400)]
cmd/compile: use more of internal/bisect in HashDebug

Using more of internal/bisect gives us more that will be deleted
from base/hashdebug.go when we have updated the tools that
need the old protocol. It is also cheaper: there is no allocation to
make a decision about whether to enable, and no locking unless
printing is needed.

Change-Id: I43ec398461205a1a9e988512a134ed6b3a3b1587
Reviewed-on: https://go-review.googlesource.com/c/go/+/493736
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
13 months agocmd/compile: standardize on outer-to-inner for pos lists
Russ Cox [Tue, 9 May 2023 00:23:40 +0000 (20:23 -0400)]
cmd/compile: standardize on outer-to-inner for pos lists

The call sites that cared all reversed inner-to-outer to outer-to-inner already.
The ones that didn't care left it alone. No one explicitly wanted inner-to-outer.
Also change to a callback-based interface, so that call sites aren't required
to accumulate the results in a slice (the main reason for that before was to
reverse the slice!).

There were three places where these lists were printed:

1. -d=ssa/genssa/dump, explicitly reversing to outer-to-inner
2. node dumps like -W, leaving the default inner-to-outer
3. file positions for HashDebugs, explicitly reversing to outer-to-inner

It makes no sense that (1) and (2) would differ. The reason they do is that
the code for (2) was too lazy to bother to fix it to be the right way.

Consider this program:

package p

func f() {
g()
}

func g() {
println()
}

Both before and after this change, the ssa dump for f looks like:

# x.go:3
        00000 (3)  TEXT <unlinkable>.f(SB), ABIInternal
        00001 (3)  FUNCDATA $0, gclocals·g2BeySu+wFnoycgXfElmcg==(SB)
        00002 (3)  FUNCDATA $1, gclocals·g2BeySu+wFnoycgXfElmcg==(SB)
 v4     00003 (-4)  XCHGL AX, AX
# x.go:4
# x.go:8
 v5     00004 (+8)  PCDATA $1, $0
 v5     00005 (+8)  CALL runtime.printlock(SB)
 v7     00006 (-8)  CALL runtime.printnl(SB)
 v9     00007 (-8)  CALL runtime.printunlock(SB)
# x.go:5
 b2     00008 (5)  RET
        00009 (?)  END

Note # x.go:4 (f) then # x.go:8 (g, called from f) between v4 and v5.

The -W node dumps used the opposite order:

before walk f
.   AS2 Def tc(1) # x.go:4:3
.   INLMARK # +x.go:4:3
.   PRINTN tc(1) # x.go:8:9,x.go:4:3
.   LABEL p..i0 # x.go:4:3

Now they match the ssa dump order, and they use spaces as separators,
to avoid potential problems with commas in some editors.

before walk f
.   AS2 Def tc(1) # x.go:4:3
.   INLMARK # +x.go:4:3
.   PRINTN tc(1) # x.go:4:3 x.go:8:9
.   LABEL p..i0 # x.go:4:3

I'm unaware of any argument for the old order other than it was easier
to compute without allocation. The new code uses recursion to reverse
the order without allocation.

Now that the callers get the results outer-to-inner, most don't need
any slices at all.

This change is particularly important for HashDebug, which had been
using a locked temporary slice to walk the inline stack without allocation.
Now the temporary slice is gone.

Change-Id: I5cb6d76b2f950db67b248acc928e47a0460569f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/493735
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>

13 months agointernal/godebug: add bisect support
Russ Cox [Wed, 3 May 2023 13:54:46 +0000 (09:54 -0400)]
internal/godebug: add bisect support

CL 491875 introduces a new bisect command, which we plan to
document for use by end users to debug semantic changes in
the compiler and in GODEBUGs.

This CL adds bisect support to GODEBUGs, at least the ones
used via internal/godebug. Support for runtime-internal
GODEBUGs like panicnil will take a bit more work in followup CLs.

The new API in internal/bisect to support stack-based bisecting
should be easily reusable in non-GODEBUG settings as well,
once we finalize and export the API.

Change-Id: I6cf779c775329aceb3f3b2b2b2f221ce8a67deee
Reviewed-on: https://go-review.googlesource.com/c/go/+/491975
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

13 months agoruntime: calculate nanoseconds in usleep on linux/loong64
Guoqi Chen [Tue, 28 Mar 2023 21:08:28 +0000 (05:08 +0800)]
runtime: calculate nanoseconds in usleep on linux/loong64

Change-Id: Ia4cfdea3df8834e6260527ce8e6e894a0547070f
Reviewed-on: https://go-review.googlesource.com/c/go/+/425299
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
13 months agonet: correct Dialer.ControlContext documentation
Jabar Asadi [Tue, 2 May 2023 17:49:52 +0000 (17:49 +0000)]
net: correct Dialer.ControlContext documentation

Change-Id: I4ec5883fc8713e0f711bb6beff45f426dae8f9f4
GitHub-Last-Rev: 9ea0c1505c2f3974e5d224299db5f888a4cf7618
GitHub-Pull-Request: golang/go#59819
Reviewed-on: https://go-review.googlesource.com/c/go/+/488315
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

13 months agocmd/link/internal/ppc64: fix export of R_DWARFSECREF to ELF on ppc64
Paul E. Murphy [Thu, 4 May 2023 18:14:52 +0000 (13:14 -0500)]
cmd/link/internal/ppc64: fix export of R_DWARFSECREF to ELF on ppc64

Today, external linking is not supported on any ppc64 ELF target, but
soon openbsd will be enabled with external linking support.

This relocation does not require additional endian specific fixups
like most other PPC64 Go relocation types.

I discovered this during an experiment to support external linking
on ppc64/linux.

Change-Id: I0b12b6172c7ba08df1c8cf024b4aa5e7ee76d0c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/492618
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
13 months agonet/http: regenerate h2_bundle.go
Bryan C. Mills [Tue, 9 May 2023 13:00:02 +0000 (09:00 -0400)]
net/http: regenerate h2_bundle.go

The x/net version was updated in CL 493596; cmd/internal/moddeps
catches the skew, but only runs on the -longtest builders (because it
requires network access for the bundle tool and x/net dependency).

Change-Id: I48891d51aab23b2ca6f4484215438c60bd8c8c21
Reviewed-on: https://go-review.googlesource.com/c/go/+/493875
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
13 months agocmd/compile/loopvar: adjust logging messages
David Chase [Fri, 5 May 2023 20:29:37 +0000 (16:29 -0400)]
cmd/compile/loopvar: adjust logging messages

Michael Stapelberg thought the former messages had
upside potential, Russ and I agreed.

Also slightly tweaked the json logging, not sure if
anyone will use it but it should at least be okay.

Change-Id: Iaab75114dd5f5d8f011fab22d32b57abc0272815
Reviewed-on: https://go-review.googlesource.com/c/go/+/493135
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
13 months agocmd: vendor golang.org/x/tools/cmd/bisect
Russ Cox [Mon, 8 May 2023 17:39:27 +0000 (13:39 -0400)]
cmd: vendor golang.org/x/tools/cmd/bisect

Vendoring for use with the internal/godebug test
and eventually the cmd/compile test as well.

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

13 months agocmd: go get golang.org/x/tools@8f7fb01dd429 and revendor
Russ Cox [Mon, 8 May 2023 17:38:04 +0000 (13:38 -0400)]
cmd: go get golang.org/x/tools@8f7fb01dd429 and revendor

go get golang.org/x/tools@8f7fb01dd429 # CL 493619
go mod tidy
go mod vendor

The goal is to set up for importing the bisect command,
for use in tests, in a follow-up CL.

This also updates x/sys and x/net, including in std,
because x/tools now depends on newer versions of those.

Change-Id: I24c283cc165464d9c873ba7a9a4e75a9d02919b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/493596
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

13 months agogo/types, types2: infer minimum default type for untyped arguments
Robert Griesemer [Thu, 4 May 2023 17:38:58 +0000 (10:38 -0700)]
go/types, types2: infer minimum default type for untyped arguments

This implements the proposal #58671.
Must be explicitly enabled and requires proposal approval.

For #58671.

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

13 months agogo/types, types2: move functions for untyped constants into const.go
Robert Griesemer [Mon, 8 May 2023 21:42:19 +0000 (14:42 -0700)]
go/types, types2: move functions for untyped constants into const.go

No changes to the moved functions.
Generate const.go for go/types.

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

13 months agocmd/compile/internal/types2: pass pos argument to Checker.overflow
Robert Griesemer [Mon, 8 May 2023 21:46:17 +0000 (14:46 -0700)]
cmd/compile/internal/types2: pass pos argument to Checker.overflow

This matches the go/types version of Checker.overflow.
Preparation for generating this function (and others)
for go/types.

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

13 months agogo/types, types2: remove genericMultiExpr (inline it in genericExprList)
Robert Griesemer [Mon, 8 May 2023 20:01:21 +0000 (13:01 -0700)]
go/types, types2: remove genericMultiExpr (inline it in genericExprList)

Also, remove named return values for exprList, genericExprList.

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

13 months agoall: make safe for new vet analyzer
Russ Cox [Mon, 8 May 2023 18:03:02 +0000 (14:03 -0400)]
all: make safe for new vet analyzer

The unused analyzer handles dot imports now, so a few tests
have picked up vet errors. This CL errors like:

context/x_test.go:524:47: result of context.WithValue call not used

Change-Id: I711a62fd7b50381f8ea45ac526bf0c946a171047
Reviewed-on: https://go-review.googlesource.com/c/go/+/493598
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
13 months agocmd/go/internal/envcmd: on unix pass script contents directly to sh -c
Michael Matloob [Mon, 8 May 2023 16:53:37 +0000 (12:53 -0400)]
cmd/go/internal/envcmd: on unix pass script contents directly to sh -c

Instead of writing them to a file and executing that file.

For #59998

Change-Id: I341786926762359f67dccb475295afbbb8ed1054
Reviewed-on: https://go-review.googlesource.com/c/go/+/493555
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
13 months agoruntime: remove TestCrashExitCode
qmuntal [Mon, 8 May 2023 11:31:37 +0000 (13:31 +0200)]
runtime: remove TestCrashExitCode

TestCrashExitCode was added in CL 491935 to test that the exit code
is honored when using GOTRACEBACK=crash, which is what normally happens
on a stock Windows. The problem is that some applications (not only WER,
as I incorrectly assumed in CL 491935) can hijack a crashing process
and change its exit code.

There is no way to tell if a crashing process using GOTRACEBACK=crash/
wer will have its error code hijacked, so we better don't test this
behavior, which in fact is not documented by the Go runtime.

Change-Id: Ib8247a8a1fe6303c4c7812a1bf2ded5f4e89acb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/493495
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

13 months agotest: add memcombine testcases for ppc64
Lynn Boger [Thu, 4 May 2023 14:42:58 +0000 (09:42 -0500)]
test: add memcombine testcases for ppc64

Thanks to the recent addition of the memcombine pass, the
ppc64 ports now have the memcombine optimizations. Previously
in PPC64.rules, the memcombine rules were only added for
ppc64le targets due to the significant increase in size of
the rewritePPC64.go file when those rules were added. The
ppc64 and ppc64le rules had to be different because of the
byte order due to endianness differences.

This enables the memcombine tests to be run on ppc64 as well
as ppc64le.

Change-Id: I4081e2d94617a1b66541d536c0c2662e266c9c1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/492615
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Lynn Boger <laboger@linux.vnet.ibm.com>

13 months agoruntime: clean up extra M API
Michael Pratt [Fri, 5 May 2023 20:35:10 +0000 (16:35 -0400)]
runtime: clean up extra M API

There are quite a few locations that get/put Ms from the extra M list,
but the API is pretty clumsy to use. Add an easier to use getExtraM /
putExtraM API.

There are only two minor semantic changes:

1. dropm no longer calls setg(nil) inside the lockextra critical
   section. It is important that this thread no longer references the G
   (and in turn M) once it is published to the extra M list and another
   thread could acquire it. But there is no reason that needs to happen
   only after lockextra.

2. extraMLength (renamed from extraMCount) is no longer protected by
   lockextra and is instead simply an atomic (though writes are still in
   the critical section). The previous readers all dropped lockextra
   before using the value they read anyway.

For #60004.

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

13 months agomath: optimize math.Abs on mipsx
Junxian Zhu [Fri, 14 Apr 2023 08:06:40 +0000 (16:06 +0800)]
math: optimize math.Abs on mipsx

This commit optimized math.Abs function implementation on mipsx.
Tested on loongson 3A2000.

goos: linux
goarch: mipsle
pkg: math
                      │   oldmath    │              newmath               │
                      │    sec/op    │   sec/op     vs base               │
Acos-4                   282.6n ± 0%   282.3n ± 0%        ~ (p=0.140 n=7)
Acosh-4                  506.1n ± 0%   451.8n ± 0%  -10.73% (p=0.001 n=7)
Asin-4                   272.3n ± 0%   272.2n ± 0%        ~ (p=0.808 n=7)
Asinh-4                  529.7n ± 0%   475.3n ± 0%  -10.27% (p=0.001 n=7)
Atan-4                   208.2n ± 0%   207.9n ± 0%        ~ (p=0.134 n=7)
Atanh-4                  503.4n ± 1%   449.7n ± 0%  -10.67% (p=0.001 n=7)
Atan2-4                  310.5n ± 0%   310.5n ± 0%        ~ (p=0.928 n=7)
Cbrt-4                   359.3n ± 0%   358.8n ± 0%        ~ (p=0.121 n=7)
Ceil-4                   203.9n ± 0%   204.0n ± 0%        ~ (p=0.600 n=7)
Compare-4                23.11n ± 0%   23.11n ± 0%        ~ (p=0.702 n=7)
Compare32-4              19.09n ± 0%   19.12n ± 0%        ~ (p=0.070 n=7)
Copysign-4               33.20n ± 0%   34.02n ± 0%   +2.47% (p=0.001 n=7)
Cos-4                    422.5n ± 0%   385.4n ± 1%   -8.78% (p=0.001 n=7)
Cosh-4                   628.0n ± 0%   545.5n ± 0%  -13.14% (p=0.001 n=7)
Erf-4                    193.7n ± 2%   192.7n ± 1%        ~ (p=0.430 n=7)
Erfc-4                   192.8n ± 1%   193.0n ± 0%        ~ (p=0.245 n=7)
Erfinv-4                 220.7n ± 1%   221.5n ± 2%        ~ (p=0.272 n=7)
Erfcinv-4                221.3n ± 1%   220.4n ± 2%        ~ (p=0.738 n=7)
Exp-4                    471.4n ± 0%   435.1n ± 0%   -7.70% (p=0.001 n=7)
ExpGo-4                  470.6n ± 0%   434.0n ± 0%   -7.78% (p=0.001 n=7)
Expm1-4                  243.1n ± 0%   243.4n ± 0%        ~ (p=0.417 n=7)
Exp2-4                   463.1n ± 0%   427.0n ± 0%   -7.80% (p=0.001 n=7)
Exp2Go-4                 462.4n ± 0%   426.2n ± 5%   -7.83% (p=0.001 n=7)
Abs-4                   37.000n ± 0%   8.039n ± 9%  -78.27% (p=0.001 n=7)
Dim-4                    18.09n ± 0%   18.11n ± 0%        ~ (p=0.094 n=7)
Floor-4                  151.9n ± 0%   151.8n ± 0%        ~ (p=0.190 n=7)
Max-4                    116.7n ± 1%   116.7n ± 1%        ~ (p=0.842 n=7)
Min-4                    116.6n ± 1%   116.6n ± 0%        ~ (p=0.464 n=7)
Mod-4                   1244.0n ± 0%   980.9n ± 0%  -21.15% (p=0.001 n=7)
Frexp-4                  199.0n ± 0%   146.7n ± 0%  -26.28% (p=0.001 n=7)
Gamma-4                  516.4n ± 0%   479.3n ± 1%   -7.18% (p=0.001 n=7)
Hypot-4                  169.8n ± 0%   117.8n ± 2%  -30.62% (p=0.001 n=7)
HypotGo-4                170.8n ± 0%   117.5n ± 0%  -31.21% (p=0.001 n=7)
Ilogb-4                  160.8n ± 0%   109.5n ± 0%  -31.90% (p=0.001 n=7)
J0-4                     1.359µ ± 0%   1.305µ ± 0%   -3.97% (p=0.001 n=7)
J1-4                     1.386µ ± 0%   1.334µ ± 0%   -3.75% (p=0.001 n=7)
Jn-4                     2.864µ ± 0%   2.758µ ± 0%   -3.70% (p=0.001 n=7)
Ldexp-4                  202.9n ± 0%   151.7n ± 0%  -25.23% (p=0.001 n=7)
Lgamma-4                 234.0n ± 0%   234.3n ± 0%        ~ (p=0.199 n=7)
Log-4                    444.1n ± 0%   407.9n ± 0%   -8.15% (p=0.001 n=7)
Logb-4                   157.8n ± 0%   121.6n ± 0%  -22.94% (p=0.001 n=7)
Log1p-4                  354.8n ± 0%   315.4n ± 0%  -11.10% (p=0.001 n=7)
Log10-4                  453.9n ± 0%   417.9n ± 0%   -7.93% (p=0.001 n=7)
Log2-4                   245.3n ± 0%   209.1n ± 0%  -14.76% (p=0.001 n=7)
Modf-4                   126.6n ± 0%   126.6n ± 0%        ~ (p=0.126 n=7)
Nextafter32-4            112.5n ± 0%   112.5n ± 0%        ~ (p=0.853 n=7)
Nextafter64-4            141.7n ± 0%   141.6n ± 0%        ~ (p=0.331 n=7)
PowInt-4                 878.8n ± 1%   758.3n ± 1%  -13.71% (p=0.001 n=7)
PowFrac-4                1.809µ ± 0%   1.615µ ± 0%  -10.72% (p=0.001 n=7)
Pow10Pos-4               18.10n ± 0%   18.12n ± 0%        ~ (p=0.464 n=7)
Pow10Neg-4               17.09n ± 0%   17.09n ± 0%        ~ (p=0.263 n=7)
Round-4                  68.36n ± 0%   68.33n ± 0%        ~ (p=0.325 n=7)
RoundToEven-4            78.40n ± 0%   78.40n ± 0%        ~ (p=0.934 n=7)
Remainder-4              894.0n ± 1%   753.4n ± 1%  -15.73% (p=0.001 n=7)
Signbit-4                18.09n ± 0%   18.09n ± 0%        ~ (p=0.761 n=7)
Sin-4                    389.8n ± 1%   389.8n ± 0%        ~ (p=0.995 n=7)
Sincos-4                 416.0n ± 0%   415.9n ± 0%        ~ (p=0.361 n=7)
Sinh-4                   634.6n ± 4%   585.6n ± 1%   -7.72% (p=0.001 n=7)
SqrtIndirect-4           8.035n ± 0%   8.036n ± 0%        ~ (p=0.523 n=7)
SqrtLatency-4            8.039n ± 0%   8.037n ± 0%        ~ (p=0.218 n=7)
SqrtIndirectLatency-4    8.040n ± 0%   8.040n ± 0%        ~ (p=0.652 n=7)
SqrtGoLatency-4          895.7n ± 0%   896.6n ± 0%   +0.10% (p=0.004 n=7)
SqrtPrime-4              5.406µ ± 0%   5.407µ ± 0%        ~ (p=0.592 n=7)
Tan-4                    406.1n ± 0%   405.8n ± 1%        ~ (p=0.435 n=7)
Tanh-4                   627.6n ± 0%   545.5n ± 0%  -13.08% (p=0.001 n=7)
Trunc-4                  146.7n ± 1%   146.7n ± 0%        ~ (p=0.755 n=7)
Y0-4                     1.359µ ± 0%   1.310µ ± 0%   -3.61% (p=0.001 n=7)
Y1-4                     1.351µ ± 0%   1.301µ ± 0%   -3.70% (p=0.001 n=7)
Yn-4                     2.829µ ± 0%   2.729µ ± 0%   -3.53% (p=0.001 n=7)
Float64bits-4            14.08n ± 0%   14.07n ± 0%        ~ (p=0.069 n=7)
Float64frombits-4        19.09n ± 0%   19.10n ± 0%        ~ (p=0.755 n=7)
Float32bits-4            13.06n ± 0%   13.07n ± 1%        ~ (p=0.586 n=7)
Float32frombits-4        13.06n ± 0%   13.06n ± 0%        ~ (p=0.853 n=7)
FMA-4                    606.9n ± 0%   606.8n ± 0%        ~ (p=0.393 n=7)
geomean                  201.1n        185.4n        -7.81%

Change-Id: I6d41a97ad3789ed5731588588859ac0b8b13b664
Reviewed-on: https://go-review.googlesource.com/c/go/+/484675
Reviewed-by: Rong Zhang <rongrong@oss.cipunited.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>

13 months agocmd/go/internal/modfetch/codehost: explicitly specify GIT_DIR
Emily Shaffer [Wed, 26 Apr 2023 21:51:31 +0000 (14:51 -0700)]
cmd/go/internal/modfetch/codehost: explicitly specify GIT_DIR

When Git has safe.bareRepository=explicit set, operations on bare Git
repositories will fail unless --git-dir or GIT_DIR is set. The rest of
the time, specifying the gitdir makes repository discovery at the
beginning of a Git command ever-so-slightly faster. So, there is no
downside to ensuring that users with this stricter security config set
can still use 'go mod' commands easily.

See
https://lore.kernel.org/git/pull.1261.v8.git.git.1657834081.gitgitgadget@gmail.com/
for a more detailed description of security concerns around embedded
bare repositories without an explicitly specified GIT_DIR.

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

13 months agointernal/testenv: reduce init-time work for MustHaveExec
Bryan C. Mills [Fri, 5 May 2023 13:29:34 +0000 (09:29 -0400)]
internal/testenv: reduce init-time work for MustHaveExec

In CL 486275 I added a somewhat complex init function that sets up a
callback to probe for exec support. A lot of the complexity was simply
to avoid an unnecessary call to os.Environ during init.

In CL 491660, I made the os.Environ call unconditional on all
platforms anyway in order to make HasGoBuild more robust.

Since the init-function indirection no longer serves a useful purpose,
I would like to simplify it to a package-level function, avoiding the
complexity of changing package variables at init time.

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

13 months agogo/types, types2: factor out maximum type computation
Robert Griesemer [Thu, 4 May 2023 21:09:27 +0000 (14:09 -0700)]
go/types, types2: factor out maximum type computation

For untyped constant binary operations we need to determine the
"maximum" (untyped) type which includes both constant types.
Factor out this functionality.

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

13 months agocmd/compile: allow more inlining of functions that construct closures
Than McIntosh [Tue, 4 Apr 2023 22:31:46 +0000 (18:31 -0400)]
cmd/compile: allow more inlining of functions that construct closures

[This is a roll-forward of CL 479095, which was reverted due to a bad
interaction between inlining and escape analysis, then later fixed
first with an attempt in CL 482355, then again in CL 484859, and then
one more time with CL 492135.]

Currently, when the inliner is determining if a function is
inlineable, it descends into the bodies of closures constructed by
that function. This has several unfortunate consequences:

- If the closure contains a disallowed operation (e.g., a defer), then
  the outer function can't be inlined. It makes sense that the
  *closure* can't be inlined in this case, but it doesn't make sense
  to punish the function that constructs the closure.

- The hairiness of the closure counts against the inlining budget of
  the outer function. Since we currently copy the closure body when
  inlining the outer function, this makes sense from the perspective
  of export data size and binary size, but ultimately doesn't make
  much sense from the perspective of what should be inlineable.

- Since the inliner walks into every closure created by an outer
  function in addition to starting a walk at every closure, this adds
  an n^2 factor to inlinability analysis.

This CL simply drops this behavior.

In std, this makes 57 more functions inlinable, and disallows inlining
for 10 (due to the basic instability of our bottom-up inlining
approach), for an net increase of 47 inlinable functions (+0.6%).

This will help significantly with the performance of the functions to
be added for #56102, which have a somewhat complicated nesting of
closures with a performance-critical fast path.

The downside of this seems to be a potential increase in export data
and text size, but the practical impact of this seems to be
negligible:

       │    before    │           after            │
       │    bytes     │    bytes      vs base      │
Go/binary        15.12Mi ± 0%   15.14Mi ± 0%  +0.16% (n=1)
Go/text          5.220Mi ± 0%   5.237Mi ± 0%  +0.32% (n=1)
Compile/binary   22.92Mi ± 0%   22.94Mi ± 0%  +0.07% (n=1)
Compile/text     8.428Mi ± 0%   8.435Mi ± 0%  +0.08% (n=1)

Change-Id: I5f75fcceb177f05853996b75184a486528eafe96
Reviewed-on: https://go-review.googlesource.com/c/go/+/492017
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
13 months agocmd/compile: un-hide closure func if parent expr moved to staticinit
Than McIntosh [Wed, 3 May 2023 16:38:50 +0000 (12:38 -0400)]
cmd/compile: un-hide closure func if parent expr moved to staticinit

If the function referenced by a closure expression is incorporated
into a static init, be sure to mark it as non-hidden, since otherwise
it will be live but no longer reachable from the init func, hence it
will be skipped during escape analysis, which can lead to
miscompilations.

Fixes #59680.

Change-Id: Ib858aee296efcc0b7655d25c23ab8a6a8dbdc5f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/492135
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
13 months agocmd/compile: rework marking of dead hidden closure functions
Than McIntosh [Fri, 14 Apr 2023 18:07:37 +0000 (14:07 -0400)]
cmd/compile: rework marking of dead hidden closure functions

[This is a roll-forward of CL 484859, this time including a fix for
issue #59709. The call to do dead function marking was taking place in
the wrong spot, causing it to run more than once if generics were
instantiated.]

This patch generalizes the code in the inliner that marks unreferenced
hidden closure functions as dead. Rather than doing the marking on the
fly (previous approach), this new approach does a single pass at the
end of inlining, which catches more dead functions.

Change-Id: I0e079ad755c21295477201acbd7e1a732a98fffd
Reviewed-on: https://go-review.googlesource.com/c/go/+/492016
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
13 months agoruntime, runtime/pprof: record instantiated symbol name in CPU profile
Cherry Mui [Tue, 2 May 2023 21:15:10 +0000 (17:15 -0400)]
runtime, runtime/pprof: record instantiated symbol name in CPU profile

For generic functions, the previous CL makes it record the full
instantiated symbol name in the runtime func table. This CL
changes the pprof package to use that name in CPU profile. This
way, it matches the symbol name the compiler sees, so it can apply
PGO.

TODO: add a test.

Fixes #58712.

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

13 months agocmd/link, runtime: include full symbol name for generic functions in runtime table
Cherry Mui [Tue, 2 May 2023 20:46:20 +0000 (16:46 -0400)]
cmd/link, runtime: include full symbol name for generic functions in runtime table

For generic functions and methods, we replace the instantiated
shape type parameter name to "...", to make the function name
printed in stack traces looks more user friendly. Currently, this
is done in the binary's runtime func table at link time, and the
runtime has no way to access the full symbol name. This causes
the profile to also contain the replaced name. For PGO, this also
cause the compiler to not be able to find out the original fully
instantiated function name from the profile.

With this CL, we change the linker to record the full name, and
do the name substitution at run time when a printing a function's
name in traceback.

For #58712.

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

13 months agocmd/link: remove zdebug from ELF section header table
Cherry Mui [Thu, 4 May 2023 21:11:46 +0000 (17:11 -0400)]
cmd/link: remove zdebug from ELF section header table

We now use SHF_COMPRESSED sections for DWARF compression, and no
longer generate zdebug sections on ELF platforms. No need to
generate them in the section header string table.

Updates #50796.

Change-Id: I5c79ccd43f803c75dbd86e28195d0db1c0beb087
Reviewed-on: https://go-review.googlesource.com/c/go/+/492719
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

13 months agocmd/link: remove elfsetstring out of the loader
Cherry Mui [Thu, 4 May 2023 21:09:49 +0000 (17:09 -0400)]
cmd/link: remove elfsetstring out of the loader

Currently, we pass elfsetstring to the loader as a callback, for
a special case of Addstring. This is only used for ELF when adding
strings to the section header string table. Move the logic to the
caller instead, so the loader would not have this special case.

Change-Id: Icfb91f380fe4ba435985c3019681597932f58242
Reviewed-on: https://go-review.googlesource.com/c/go/+/492718
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
13 months agogo/types, types2: better error message for bad assignment
Robert Griesemer [Fri, 5 May 2023 00:01:53 +0000 (17:01 -0700)]
go/types, types2: better error message for bad assignment

If the LHS of an assignment is neither addressable nor a map expression
(and not the blank identifier), explicitly say so for a better error
message.

For #3117.

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

13 months agogo/types, types2: exclude untyped nil arguments early in type inference
Robert Griesemer [Thu, 4 May 2023 17:54:12 +0000 (10:54 -0700)]
go/types, types2: exclude untyped nil arguments early in type inference

An untyped nil argument cannot be used to infer any type information.
We don't need to include it in the untyped arguments.

Change-Id: Ied44738ff1b135e65a3acfa19223cd3889b7fa7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/492695
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
13 months agointernal/coverage/encodecounter: followup changes from code review
Than McIntosh [Fri, 5 May 2023 15:11:10 +0000 (11:11 -0400)]
internal/coverage/encodecounter: followup changes from code review

This patch contains a small set of changes with fixes for some
issues that surfaced during the code review for CL 484535. Due
to an error on my part, these never got included in the final version
that was checked in (I rebased, mailed the rebase, but then never
mailed the final patch set with the changes). This patch sends
the remaining bits and pieces.

Updates #59563.

Change-Id: I87dc05a83f8e44c8bfe7203bc2b035defc817af9
Reviewed-on: https://go-review.googlesource.com/c/go/+/492981
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
13 months agocmd/dist: add explicit module version to generated go.mod
David Chase [Fri, 5 May 2023 15:23:29 +0000 (11:23 -0400)]
cmd/dist: add explicit module version to generated go.mod

This avoids bootstrapping problems with 1.20.
Tested w/ 1.19 and 1.20.

Change-Id: I0ca9e111719e8c1bcd1a0b53b9f16d9a2d77e836
Reviewed-on: https://go-review.googlesource.com/c/go/+/492982
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

13 months agocmd/go: save checksums for go.mod files needed for go version lines
Bryan C. Mills [Wed, 26 Apr 2023 05:43:20 +0000 (01:43 -0400)]
cmd/go: save checksums for go.mod files needed for go version lines

When we load a package from a module, we need the go version line from
that module's go.mod file to know what language semantics to use for
the package. We need to save a checksum for the go.mod file even if
the module's requirements are pruned out of the module graph.
Previously, we were missing checksums for test dependencies of
packages in 'all' and packages passed to 'go get -t'.

This change preserves the existing bug for 'go mod tidy' in older
module versions, but fixes it for 'go mod tidy' in modules at go 1.21
or higher and for 'go get -t' at all versions.

Fixes #56222.

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

13 months agocmd/compile: work with new bisect command
Russ Cox [Wed, 3 May 2023 05:08:10 +0000 (01:08 -0400)]
cmd/compile: work with new bisect command

CL 491875 introduces a new bisect command, which we plan to
document for use by end users to debug semantic changes in
the compiler and in GODEBUGs.

This CL adapts the existing GOSSAHASH support, which bisect
is a revision of, to support the specific syntax and output used
by bisect as well.

A followup CL will remove the old GOSSAHASH syntax and output
once existing consumers of that interface have been updated.

Change-Id: I99c4af54bb82c91c74bd8b8282ded968e6316f56
Reviewed-on: https://go-review.googlesource.com/c/go/+/491895
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
13 months agointernal/bisect: copy from golang.org/x/tools/bisect
Russ Cox [Thu, 4 May 2023 12:33:09 +0000 (08:33 -0400)]
internal/bisect: copy from golang.org/x/tools/bisect

We don't want std to depend on x/tools, so just as we
did with txtar, copy the bisect package into internal
rather than using a require + vendor.

Change-Id: Id775254f7c765a9244ba6eaf041c13e6e5c5e9f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/492595
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

13 months agointernal/abi: refactor (basic) type struct into one definition
David Chase [Fri, 20 Jan 2023 21:41:57 +0000 (16:41 -0500)]
internal/abi: refactor (basic) type struct into one definition

This touches a lot of files, which is bad, but it is also good,
since there's N copies of this information commoned into 1.

The new files in internal/abi are copied from the end of the stack;
ultimately this will all end up being used.

Change-Id: Ia252c0055aaa72ca569411ef9f9e96e3d610889e
Reviewed-on: https://go-review.googlesource.com/c/go/+/462995
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
13 months agocmd/compile: add "loop-transformed" (for whole loop) to logopt
David Chase [Thu, 4 May 2023 20:08:13 +0000 (16:08 -0400)]
cmd/compile: add "loop-transformed" (for whole loop) to logopt

This is intended to support automated pairing of performance
regressions with transformed loops; there is already a POC
for doing this in the general missed-optimization case; the
difference here is the ability to describe an entire range,
which required some extra plumbing to acquire and publish
the ending line+column.

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

13 months agomath: optimize math.Abs on mips64x
Junxian Zhu [Mon, 3 Apr 2023 07:26:54 +0000 (15:26 +0800)]
math: optimize math.Abs on mips64x

This commit optimized math.Abs function implementation on mips64x.
Tested on loongson 3A2000.

goos: linux
goarch: mips64le
pkg: math
                      │    oldmath    │               newmath               │
                      │    sec/op     │    sec/op     vs base               │
Acos-4                   258.0n ± ∞ ¹   257.1n ± ∞ ¹   -0.35% (p=0.008 n=5)
Acosh-4                  417.0n ± ∞ ¹   377.9n ± ∞ ¹   -9.38% (p=0.008 n=5)
Asin-4                   248.0n ± ∞ ¹   259.9n ± ∞ ¹   +4.80% (p=0.008 n=5)
Asinh-4                  439.6n ± ∞ ¹   408.3n ± ∞ ¹   -7.12% (p=0.008 n=5)
Atan-4                   189.6n ± ∞ ¹   188.8n ± ∞ ¹        ~ (p=0.056 n=5)
Atanh-4                  390.0n ± ∞ ¹   356.4n ± ∞ ¹   -8.62% (p=0.008 n=5)
Atan2-4                  279.0n ± ∞ ¹   263.9n ± ∞ ¹   -5.41% (p=0.008 n=5)
Cbrt-4                   314.2n ± ∞ ¹   322.3n ± ∞ ¹   +2.58% (p=0.008 n=5)
Ceil-4                   139.7n ± ∞ ¹   136.6n ± ∞ ¹   -2.22% (p=0.008 n=5)
Compare-4                21.11n ± ∞ ¹   21.09n ± ∞ ¹        ~ (p=0.405 n=5)
Compare32-4              20.10n ± ∞ ¹   20.12n ± ∞ ¹        ~ (p=0.206 n=5)
Copysign-4               32.17n ± ∞ ¹   35.71n ± ∞ ¹  +11.00% (p=0.008 n=5)
Cos-4                    222.8n ± ∞ ¹   169.8n ± ∞ ¹  -23.79% (p=0.008 n=5)
Cosh-4                   550.2n ± ∞ ¹   477.4n ± ∞ ¹  -13.23% (p=0.008 n=5)
Erf-4                    171.6n ± ∞ ¹   174.5n ± ∞ ¹        ~ (p=0.635 n=5)
Erfc-4                   182.6n ± ∞ ¹   170.2n ± ∞ ¹   -6.79% (p=0.008 n=5)
Erfinv-4                 177.6n ± ∞ ¹   196.6n ± ∞ ¹  +10.70% (p=0.008 n=5)
Erfcinv-4                177.8n ± ∞ ¹   197.8n ± ∞ ¹  +11.25% (p=0.008 n=5)
Exp-4                    422.8n ± ∞ ¹   382.1n ± ∞ ¹   -9.63% (p=0.008 n=5)
ExpGo-4                  416.1n ± ∞ ¹   383.2n ± ∞ ¹   -7.91% (p=0.008 n=5)
Expm1-4                  232.9n ± ∞ ¹   252.2n ± ∞ ¹   +8.29% (p=0.008 n=5)
Exp2-4                   404.8n ± ∞ ¹   389.1n ± ∞ ¹   -3.88% (p=0.008 n=5)
Exp2Go-4                 407.0n ± ∞ ¹   372.3n ± ∞ ¹   -8.53% (p=0.008 n=5)
Abs-4                   30.120n ± ∞ ¹   3.014n ± ∞ ¹  -89.99% (p=0.008 n=5)
Dim-4                    5.021n ± ∞ ¹   5.023n ± ∞ ¹        ~ (p=0.071 n=5)
Floor-4                  127.8n ± ∞ ¹   127.1n ± ∞ ¹   -0.55% (p=0.008 n=5)
Max-4                    77.69n ± ∞ ¹   76.33n ± ∞ ¹   -1.75% (p=0.008 n=5)
Min-4                    83.27n ± ∞ ¹   77.87n ± ∞ ¹   -6.48% (p=0.008 n=5)
Mod-4                    906.2n ± ∞ ¹   692.9n ± ∞ ¹  -23.54% (p=0.008 n=5)
Frexp-4                  150.6n ± ∞ ¹   108.6n ± ∞ ¹  -27.89% (p=0.008 n=5)
Gamma-4                  418.4n ± ∞ ¹   386.1n ± ∞ ¹   -7.72% (p=0.008 n=5)
Hypot-4                 148.20n ± ∞ ¹   93.78n ± ∞ ¹  -36.72% (p=0.008 n=5)
HypotGo-4               148.20n ± ∞ ¹   94.47n ± ∞ ¹  -36.26% (p=0.008 n=5)
Ilogb-4                 135.50n ± ∞ ¹   92.38n ± ∞ ¹  -31.82% (p=0.008 n=5)
J0-4                     937.7n ± ∞ ¹   861.7n ± ∞ ¹   -8.10% (p=0.008 n=5)
J1-4                     915.4n ± ∞ ¹   875.9n ± ∞ ¹   -4.32% (p=0.008 n=5)
Jn-4                     1.974µ ± ∞ ¹   1.863µ ± ∞ ¹   -5.62% (p=0.008 n=5)
Ldexp-4                  158.5n ± ∞ ¹   129.3n ± ∞ ¹  -18.42% (p=0.008 n=5)
Lgamma-4                 209.0n ± ∞ ¹   211.8n ± ∞ ¹        ~ (p=0.095 n=5)
Log-4                    326.4n ± ∞ ¹   295.2n ± ∞ ¹   -9.56% (p=0.008 n=5)
Logb-4                   147.7n ± ∞ ¹   105.0n ± ∞ ¹  -28.91% (p=0.008 n=5)
Log1p-4                  303.4n ± ∞ ¹   266.3n ± ∞ ¹  -12.23% (p=0.008 n=5)
Log10-4                  329.2n ± ∞ ¹   298.3n ± ∞ ¹   -9.39% (p=0.008 n=5)
Log2-4                   187.4n ± ∞ ¹   153.0n ± ∞ ¹  -18.36% (p=0.008 n=5)
Modf-4                   110.5n ± ∞ ¹   103.5n ± ∞ ¹   -6.33% (p=0.008 n=5)
Nextafter32-4            128.4n ± ∞ ¹   121.5n ± ∞ ¹   -5.37% (p=0.016 n=5)
Nextafter64-4            109.5n ± ∞ ¹   110.5n ± ∞ ¹   +0.91% (p=0.008 n=5)
PowInt-4                 603.3n ± ∞ ¹   516.4n ± ∞ ¹  -14.40% (p=0.008 n=5)
PowFrac-4                1.365µ ± ∞ ¹   1.183µ ± ∞ ¹  -13.33% (p=0.008 n=5)
Pow10Pos-4               15.07n ± ∞ ¹   15.07n ± ∞ ¹        ~ (p=0.738 n=5)
Pow10Neg-4               21.11n ± ∞ ¹   21.10n ± ∞ ¹        ~ (p=0.190 n=5)
Round-4                  44.23n ± ∞ ¹   44.22n ± ∞ ¹        ~ (p=0.635 n=5)
RoundToEven-4            50.25n ± ∞ ¹   46.27n ± ∞ ¹   -7.92% (p=0.008 n=5)
Remainder-4              675.6n ± ∞ ¹   530.4n ± ∞ ¹  -21.49% (p=0.008 n=5)
Signbit-4                17.07n ± ∞ ¹   17.95n ± ∞ ¹   +5.16% (p=0.008 n=5)
Sin-4                    171.6n ± ∞ ¹   189.1n ± ∞ ¹  +10.20% (p=0.008 n=5)
Sincos-4                 201.5n ± ∞ ¹   200.5n ± ∞ ¹        ~ (p=0.421 n=5)
Sinh-4                   529.6n ± ∞ ¹   484.6n ± ∞ ¹   -8.50% (p=0.008 n=5)
SqrtIndirect-4           5.021n ± ∞ ¹   5.023n ± ∞ ¹   +0.04% (p=0.048 n=5)
SqrtLatency-4            8.032n ± ∞ ¹   8.039n ± ∞ ¹   +0.09% (p=0.024 n=5)
SqrtIndirectLatency-4    8.036n ± ∞ ¹   8.038n ± ∞ ¹        ~ (p=0.056 n=5)
SqrtGoLatency-4          338.8n ± ∞ ¹   338.7n ± ∞ ¹        ~ (p=0.841 n=5)
SqrtPrime-4              5.379µ ± ∞ ¹   5.382µ ± ∞ ¹   +0.06% (p=0.048 n=5)
Tan-4                    182.7n ± ∞ ¹   191.8n ± ∞ ¹   +4.98% (p=0.008 n=5)
Tanh-4                   558.7n ± ∞ ¹   497.6n ± ∞ ¹  -10.94% (p=0.008 n=5)
Trunc-4                  122.5n ± ∞ ¹   122.6n ± ∞ ¹        ~ (p=0.405 n=5)
Y0-4                     892.8n ± ∞ ¹   851.7n ± ∞ ¹   -4.60% (p=0.008 n=5)
Y1-4                     887.2n ± ∞ ¹   863.2n ± ∞ ¹   -2.71% (p=0.008 n=5)
Yn-4                     1.889µ ± ∞ ¹   1.832µ ± ∞ ¹   -3.02% (p=0.008 n=5)
Float64bits-4            13.05n ± ∞ ¹   13.06n ± ∞ ¹   +0.08% (p=0.040 n=5)
Float64frombits-4        13.05n ± ∞ ¹   13.06n ± ∞ ¹        ~ (p=0.143 n=5)
Float32bits-4            13.05n ± ∞ ¹   13.06n ± ∞ ¹   +0.08% (p=0.008 n=5)
Float32frombits-4        13.05n ± ∞ ¹   13.08n ± ∞ ¹   +0.23% (p=0.016 n=5)
FMA-4                    445.7n ± ∞ ¹   448.1n ± ∞ ¹   +0.54% (p=0.008 n=5)
geomean                  157.2n         142.8n         -9.17%

Change-Id: I9bf104848b588c9ecf79401a81d483d7fcdb0a79
Reviewed-on: https://go-review.googlesource.com/c/go/+/481575
Reviewed-by: M Zhuo <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Rong Zhang <rongrong@oss.cipunited.com>
13 months agoRevert "runtime/cgo: store M for C-created thread in pthread key"
Chressie Himpel [Fri, 5 May 2023 14:17:38 +0000 (14:17 +0000)]
Revert "runtime/cgo: store M for C-created thread in pthread key"

This reverts CL 485500.

Reason for revert: This breaks internal tests at Google, see b/280861579 and b/280820455.

Change-Id: I426278d400f7611170918fc07c524cb059b9cc55
Reviewed-on: https://go-review.googlesource.com/c/go/+/492995
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Chressie Himpel <chressie@google.com>

13 months agocmd/go: sanitize go env outputs
Michael Matloob [Mon, 24 Apr 2023 20:57:28 +0000 (16:57 -0400)]
cmd/go: sanitize go env outputs

go env, without any arguments, outputs the environment variables in
the form of a script that can be run on the host OS. On Unix, single
quote the strings and place single quotes themselves outside the
single quoted strings. On windows use the set "var=val" syntax with
the quote starting before the variable.

Fixes #58508

Change-Id: Iecd379a4af7285ea9b2024f0202250c74fd9a2bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/488375
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
13 months agocmd/go/internal/modfetch/codehost: skip tests that fail due to tag mismatches
Bryan C. Mills [Fri, 5 May 2023 13:09:00 +0000 (09:09 -0400)]
cmd/go/internal/modfetch/codehost: skip tests that fail due to tag mismatches

For #56881.

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

13 months agoruntime: don't check the exit code in TestWERDialogue
qmuntal [Wed, 3 May 2023 10:19:58 +0000 (12:19 +0200)]
runtime: don't check the exit code in TestWERDialogue

TestWERDialogue intent is to check that the WER dialog doesn't pop-up
when `GOTRACEBACK=wer` is set. CL 474915 extended the test to also
check the error code of the crashed process. This change is causing
failures in Microsoft internal test pipelines because some WER setups
can modify the exit code of the crashed application, for example to
signal that the crash dump has been collected.

Fix this issue by not checking the error code in TestWERDialogue. Also,
add a new test, TestCrashExitCode, which does the same but using
`GOTRACEBACK=crash` instead, so that we have one test that checks the
error code.

Change-Id: Iedde09e1df7223009ebef38a32a460f1ab07e31a
Reviewed-on: https://go-review.googlesource.com/c/go/+/491935
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
13 months agotestenv: allow HasGoBuild to be false on -noopt builders
Bryan C. Mills [Thu, 4 May 2023 21:14:53 +0000 (17:14 -0400)]
testenv: allow HasGoBuild to be false on -noopt builders

-noopt uses GO_GCFLAGS to disable optimization, and
GO_GCFLAGS has caused HasGoBuild to be false since CL 74470.

Change-Id: Iadcd15d412c05aec11e9a23b86d7b24af79d73bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/492795
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

13 months agolog/slog: remove special float handling from JSONHandler
Jonathan Amsterdam [Wed, 19 Apr 2023 20:51:05 +0000 (16:51 -0400)]
log/slog: remove special float handling from JSONHandler

Remove the special-case handling of NaN and infinities from
appendJSONValue, making JSONHandler behave almost exactly like
a json.Encoder without HTML escaping.

The only differences are:

- Encoding errors are turned into strings, instead of causing the Handle method to fail.

- Values of type `error` are displayed as strings by calling their `Error` method.

Fixes #59345.

Change-Id: Id06bd952bbfef596e864bd5fd3f9f4f178f738c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/486855
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
13 months agoruntime: don't run TestStackGrowth in parallel with other tests
Cherry Mui [Thu, 4 May 2023 19:11:28 +0000 (15:11 -0400)]
runtime: don't run TestStackGrowth in parallel with other tests

This test calls runtime.GC quite a number of times. GC is a global
operation. To reduce interference with other tests, don't run this
test in parallel with other tests.

May fix #57601.

Change-Id: I6efadb62c4dada37a927455f5c6cd98cafb88aaf
Reviewed-on: https://go-review.googlesource.com/c/go/+/492715
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
13 months agolog/slog: rearrange package doc
Jonathan Amsterdam [Sun, 23 Apr 2023 15:06:34 +0000 (11:06 -0400)]
log/slog: rearrange package doc

Move the "Attrs and Values" section lower. It describes an optimization;
the API it covers is not essential.

Also, move the brief section on Logger.With up to the first section.
It was in the "Groups" section but didn't belong there.

Change-Id: I0e36ef654e95f918d5b480566ec58d9990d26b40
Reviewed-on: https://go-review.googlesource.com/c/go/+/487856
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>

13 months agolog/slog: Group takes ...any
Jonathan Amsterdam [Wed, 19 Apr 2023 18:56:58 +0000 (14:56 -0400)]
log/slog: Group takes ...any

The Group function takes a key and a ...any, which is converted
into attrs.

Fixes #59204.

Change-Id: Ib714365dcda2eda37863ce433f3dd8cf5eeda610
Reviewed-on: https://go-review.googlesource.com/c/go/+/487855
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

13 months agointernal/testenv: remove HasExec and simplify other support checks again
Bryan C. Mills [Tue, 2 May 2023 17:07:26 +0000 (13:07 -0400)]
internal/testenv: remove HasExec and simplify other support checks again

HasExec is an attractive nuisance: it is tempting to check in a
TestMain function, but TestMain really shouldn't be running
subprocesses eagerly anyway (they add needless overhead for operations
like 'go test -list=.'), and the trick of re-executing the test binary
to determine whether 'exec' works ends up in infinite recursion if
TestMain itself calls HasExec.

Instead, tests that need to execute a subprocess should call
MustHaveExec or MustHaveExecPath from within a specific test,
or just try to exec the program and check its error status
(perhaps using testenv.SyscallIsNotSupported).

While I'm in here and testing on the SlowBots anyway, a few other
cleanups relating to subprocesses:

- Add more t.Helper calls to support checks where appropriate.

- Remove findGoTool, which can be simplified to exec.LookPath as of
  CL 404134.

- Add tests confirming the expected behavior of the support functions
  on the Go project's builders.

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

13 months agolog/slog: built-in handler constructors take options as a second arg
Jonathan Amsterdam [Wed, 19 Apr 2023 18:24:33 +0000 (14:24 -0400)]
log/slog: built-in handler constructors take options as a second arg

There is now one constructor function for each built-in handler, with
signature

    NewXXXHandler(io.Writer, *HandlerOptions) *XXXHandler

Fixes #59339.

Change-Id: Ia02183c5ce0dc15c64e33ad05fd69bca09df2d2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/486415
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>

13 months agoruntime/cgo: preserve VRs across crosscall_ppc64 on linux
Paul E. Murphy [Fri, 31 Mar 2023 18:33:25 +0000 (13:33 -0500)]
runtime/cgo: preserve VRs across crosscall_ppc64 on linux

Rework this function to closely match the PPC64 crosscall2, but
written in gnu asm. Likewise, fix this to store TOC in the new
frame, not the caller's, as is required by the ELF ABIs.

Change-Id: I8902c74f2607e3436260882a7bea52e72a67b8f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/486335
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Carlos Amedee <carlos@golang.org>

13 months agoruntime/cgo: preserve nonvolatile VRs when crosscalling into Go on PPC64
Paul E. Murphy [Thu, 30 Mar 2023 16:11:39 +0000 (11:11 -0500)]
runtime/cgo: preserve nonvolatile VRs when crosscalling into Go on PPC64

ELFv1 and ELFv2 declare V20-V31 as nonvolatile (callee save) registers.
Go does not. Preserve them before calling into Go.

Change-Id: If60a6d8f71b51b1136a86eab2b90d964900becd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/480657
Auto-Submit: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

13 months agocmd/fix: move cgo and 'go build' support checks into TestRewrite
Bryan C. Mills [Tue, 2 May 2023 15:59:19 +0000 (11:59 -0400)]
cmd/fix: move cgo and 'go build' support checks into TestRewrite

This avoids unnecessary work to determine 'go build' and cgo support
if we're not actually running the test (as in 'go test -list').

Change-Id: Id175a759605b2130d4de8bff8eba4c23fe65ccba
Reviewed-on: https://go-review.googlesource.com/c/go/+/491657
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Austin Clements <austin@google.com>
13 months agocmd/compile: fix bswap/load rewrite rules
Keith Randall [Thu, 4 May 2023 16:30:24 +0000 (09:30 -0700)]
cmd/compile: fix bswap/load rewrite rules

When combining a byteswap and a load, the resulting combined op
must go in the load's block, not the byteswap's block, as the load
has a memory argument that might only be valid in its original block.

Fixes #59973

Change-Id: Icd84863ef3a9ca1fc22f2bb794a003f2808c746f
Reviewed-on: https://go-review.googlesource.com/c/go/+/492616
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Keith Randall <khr@google.com>
13 months agogo/types, types2: remove Config.EnableReverseTypeInference flag
Robert Griesemer [Thu, 4 May 2023 05:05:27 +0000 (22:05 -0700)]
go/types, types2: remove Config.EnableReverseTypeInference flag

Proposal #59338 has been accepted and we expect this feature to
be available starting with Go 1.21. Remove the flag to explicitly
enable it through the API and enable by default.

For now keep an internal constant enableReverseTypeInference to
guard and mark the respective code, so we can disable it for
debugging purposes.

For #59338.

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

13 months agogo/types, types2: consider generic functions in inference simplify step
Robert Griesemer [Thu, 4 May 2023 04:34:25 +0000 (21:34 -0700)]
go/types, types2: consider generic functions in inference simplify step

After type arguments for all type parameters have been determined,
the type arguments are "simplified" by substituting any type parameters
that might occur in them with their corresponding type arguments until
all type parameters have been removed.

If in this process a (formerly) generic function signature becomes
non-generic, make sure to nil out its (declared) type parameters.

Fixes #59953.
For #59338.

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

13 months agosyscall: reduce memory allocated by UTF16FromString
Frediano Ziglio [Thu, 4 May 2023 10:25:29 +0000 (11:25 +0100)]
syscall: reduce memory allocated by UTF16FromString

The function allocated a buffer larger than needed.
Fixes #59967.

Signed-off-by: Frediano Ziglio <frediano.ziglio@nextdlp.com>
Change-Id: I5f30a135acf5f27d6c2ef4bc4abef5144da4dc94
Reviewed-on: https://go-review.googlesource.com/c/go/+/492575
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
13 months agocmd/go: fix short tests on ios
Bryan C. Mills [Thu, 4 May 2023 15:16:04 +0000 (11:16 -0400)]
cmd/go: fix short tests on ios

As of CL 488076, many cmd/go tests can run on the ios-arm64-corellium
builder. Some of them had made erroneous assumptions about cmd/go's
use of the C toolchain.

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

13 months agogo/types, types2: rename generic function arguments
Robert Griesemer [Thu, 4 May 2023 00:47:29 +0000 (17:47 -0700)]
go/types, types2: rename generic function arguments

For correct inference, if the same generic function is provided
more than once as an argument to another function, the argument
function's type parameters must be unique for each argument so
that the type parameters can be correctly inferred.

Example:

func f(func(int), func(string)) {}

func g[P any](P) {}

func _() {
f(g, g)
}

Here the type parameter P for the first g argument resolves to int
and the type parameter P for the second g argument resolves to string.

Fixes #59956.
For #59338.

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

13 months agogo/types, types2: make Checker.renameTParams work on any type
Robert Griesemer [Thu, 4 May 2023 00:42:01 +0000 (17:42 -0700)]
go/types, types2: make Checker.renameTParams work on any type

This permits the rewrite of type parameters in arbitrary types,
not just tuples.

Preparation for fixing #59956.
For #59338.

Change-Id: I9ccaac1f163051cb837cae2208763cafb1d239cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/492515
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
13 months agonet: net remove completed return from cgo lookup functions
Mateusz Poliwczak [Tue, 2 May 2023 14:17:54 +0000 (14:17 +0000)]
net: net remove completed return from cgo lookup functions

After CL 487196 there is no need anymore to return
completed == false from the cgo lookup functions and
then fallback to to go resolver.  (Before CL 487196 this
change would cause the (only?) tests to fail)
Now the cgoAvailable constant guards that correctly.

This change will cause a panic when the cgo resolver is being
used without the cgo support, so it will be easier to
detect bug while changing the code in the net package.

I am leaving the completed return from cgoLookupCNAME,
because it is super broken now.

Change-Id: I2661b9a3725de2b1a229847c12adf64b3f62b136
GitHub-Last-Rev: 2a6501a53e1b2c5195c3869d528a40e7f93d6225
GitHub-Pull-Request: golang/go#59925
Reviewed-on: https://go-review.googlesource.com/c/go/+/491275
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
13 months agoall: add String for fs.{FileInfo,DirEntry} implementations
Ian Lance Taylor [Tue, 2 May 2023 00:38:08 +0000 (17:38 -0700)]
all: add String for fs.{FileInfo,DirEntry} implementations

The new String methods use the new FormatFileInfo and
FormatDirEntry functions.

Fixes #54451

Change-Id: I414cdfc212ec3c316fb2734756d2117842a23631
Reviewed-on: https://go-review.googlesource.com/c/go/+/491175
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
13 months agocmd/go/internal/modfetch/codehost: initialize localGitURL lazily and clean up skips
Bryan C. Mills [Tue, 2 May 2023 16:44:40 +0000 (12:44 -0400)]
cmd/go/internal/modfetch/codehost: initialize localGitURL lazily and clean up skips

Previously localGitURL was initialized in TestMain, which creates
needless work if the test flags do not result in running a test that
requires localGitURL.

We had also been skipping a bunch of tests that used
vcs-test.golang.org in order to avoid network traffic, but now that
that content is served through an in-process vcweb server that is no
longer necessary. (All of the 'git' tests together take less than a
second to run.)

The 'hg' tests are much slower, so we do still skip those in short
mode.

Updates #59940.

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

13 months agoruntime: skip TestSegv/SegvInCgo earlier on ios
Bryan C. Mills [Wed, 3 May 2023 15:22:53 +0000 (11:22 -0400)]
runtime: skip TestSegv/SegvInCgo earlier on ios

It appears to sometimes hang instead of crashing,
which can cause subsequent tests to time out.

For #59947.

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

13 months agocmd/go: remove a redundant HasExec check in TestScript/README
Bryan C. Mills [Tue, 2 May 2023 16:43:04 +0000 (12:43 -0400)]
cmd/go: remove a redundant HasExec check in TestScript/README

The test checks testenv.HasExec right before calling testenv.Command,
but testenv.Command already skips the test if HasExec is false.

Change-Id: I04716bf823a1b76640394a964973ff34c65afb1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/491658
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
13 months agoslog: fix grammatical mistakes in docs
nilsocket [Sun, 16 Apr 2023 09:21:22 +0000 (14:51 +0530)]
slog: fix grammatical mistakes in docs

Change-Id: I183dda71fcec04fc1e622c66f719bd745d8b4eea
Reviewed-on: https://go-review.googlesource.com/c/go/+/484975
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Carlos Amedee <carlos@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
13 months agocmd/link/internal/ppc64: support non-PIC PLT call stubs
Paul E. Murphy [Mon, 24 Apr 2023 20:59:17 +0000 (15:59 -0500)]
cmd/link/internal/ppc64: support non-PIC PLT call stubs

Simplify the PLT stub generation code to minimize stub generation
knowing there is only ever a single TOC pointer when linking
internally.

The OpenBSD port requires Go make dynamic calls into its C library,
so the linker must create stubs which work without R2 being set up.
This new case is exactly case 3 described in the PPC64 ELFv2 1.5
section 4.2.5.3.

Updates #56001

Change-Id: I07ebd08442302e55b94b57db474dfd7e7a0c2ac9
Reviewed-on: https://go-review.googlesource.com/c/go/+/488316
Auto-Submit: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
13 months agocmd/compile: fix compilation of inferred type arguments
Matthew Dempsky [Wed, 3 May 2023 21:53:03 +0000 (14:53 -0700)]
cmd/compile: fix compilation of inferred type arguments

Previously, type arguments could only be inferred for generic
functions in call expressions, whereas with the reverse type inference
proposal they can now be inferred in assignment contexts too. As a
consequence, we now need to check Info.Instances to find the inferred
type for more cases now.

Updates #59338.
Fixes #59955.

Change-Id: I9b6465395869459c2387d0424febe7337b28b90e
Reviewed-on: https://go-review.googlesource.com/c/go/+/492455
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

13 months agoRevert "cmd/compile: enhance tighten pass for memory values"
Daniel Martí [Wed, 3 May 2023 20:56:41 +0000 (20:56 +0000)]
Revert "cmd/compile: enhance tighten pass for memory values"

This reverts CL 458755.

Reason for revert: broke make.bash on GOAMD64=v3:

/workdir/go/src/crypto/sha1/sha1.go:54:35: internal compiler error: '(*digest).MarshalBinary': func (*digest).MarshalBinary, startMem[b13] has different values, old v206, new v338

goroutine 34 [running]:
runtime/debug.Stack()
/workdir/go/src/runtime/debug/stack.go:24 +0x9f
bootstrap/cmd/compile/internal/base.FatalfAt({0x13, 0xaa0f1}, {0xc000db4440, 0x40}, {0xc0013b0000, 0x5, 0x5})
/workdir/go/src/cmd/compile/internal/base/print.go:234 +0x2d1
bootstrap/cmd/compile/internal/base.Fatalf(...)
/workdir/go/src/cmd/compile/internal/base/print.go:203
bootstrap/cmd/compile/internal/ssagen.(*ssafn).Fatalf(0xc000d90000, {0x13, 0xaa0f1}, {0xcb7b91, 0x3a}, {0xc000d99bc0, 0x4, 0x4})
/workdir/go/src/cmd/compile/internal/ssagen/ssa.go:7896 +0x1f8
bootstrap/cmd/compile/internal/ssa.(*Func).Fatalf(0xc000d82340, {0xcb7b91, 0x3a}, {0xc000d99bc0, 0x4, 0x4})
/workdir/go/src/cmd/compile/internal/ssa/func.go:716 +0x342
bootstrap/cmd/compile/internal/ssa.memState(0xc000d82340, {0xc000ec6200, 0x22, 0x40}, {0xc001046000, 0x22, 0x40})
/workdir/go/src/cmd/compile/internal/ssa/tighten.go:240 +0x6c5
bootstrap/cmd/compile/internal/ssa.tighten(0xc000d82340)
[...]

Change-Id: Ic445fb48fe0f2c60ac67abe259b66594f1419152
Reviewed-on: https://go-review.googlesource.com/c/go/+/492335
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
13 months agoRevert "crypto/sha1: add WriteString and WriteByte method"
Ian Lance Taylor [Wed, 3 May 2023 21:00:13 +0000 (21:00 +0000)]
Revert "crypto/sha1: add WriteString and WriteByte method"

This reverts CL 483815

Reason for revert: can cause cgo errors when using boringcrypto.
See #59954.

For #38776
For #59954

Change-Id: I1f7e0fb06b627971811623927e3d98c0fdbc730b
Reviewed-on: https://go-review.googlesource.com/c/go/+/492375
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>

13 months agoRevert "crypto/sha256: add WriteString and WriteByte method"
Ian Lance Taylor [Wed, 3 May 2023 21:00:58 +0000 (21:00 +0000)]
Revert "crypto/sha256: add WriteString and WriteByte method"

This reverts CL 481478

Reason for revert: can cause cgo errors when using boringcrypto.
See #59954.

For #38776
For #59954

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

13 months agoRevert "crypto/sha512: add WriteString and WriteByte method"
Ian Lance Taylor [Wed, 3 May 2023 20:59:12 +0000 (20:59 +0000)]
Revert "crypto/sha512: add WriteString and WriteByte method"

This reverts CL 483816

Reason for revert: can cause cgo errors when using boringcrypto.  See #59954.

For #38776
For #59954

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

13 months agogo/types, types2: rename allowVersionf to verifyVersionf
Robert Griesemer [Wed, 3 May 2023 19:16:40 +0000 (12:16 -0700)]
go/types, types2: rename allowVersionf to verifyVersionf

Follow-up on comment in CL 491715.

Change-Id: Ie6a71859e791434b7ab53c5524f35718a3567ecb
Reviewed-on: https://go-review.googlesource.com/c/go/+/492236
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
13 months agoruntime/coverage: fix problematic test from issue 59563
Than McIntosh [Wed, 3 May 2023 17:40:02 +0000 (13:40 -0400)]
runtime/coverage: fix problematic test from issue 59563

Fix up the coverage testpoint TestIssue59563TruncatedCoverPkgAll
to avoid spurious failures due to racy behavior. Specifically,
we are only interested in verifying coverage for the larger
function of the two in the test package (the smaller one is only
there to trigger additional function registrations while the
test is finalizing the cov data).

Updates #59867.
Updates #59563.

Change-Id: Ibfbbcbf68e0ad7a4d9606cbcfc69d140375c7b87
Reviewed-on: https://go-review.googlesource.com/c/go/+/492175
Run-TryBot: Than McIntosh <thanm@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
13 months agolib/time: update to 2023c/2023c
Carlos Amedee [Wed, 3 May 2023 16:32:44 +0000 (12:32 -0400)]
lib/time: update to 2023c/2023c

Commit generated by update.bash.

For #22487.

Change-Id: I3d5c42f5c2ed06d562aea881f75b645729e6087d
Reviewed-on: https://go-review.googlesource.com/c/go/+/492095
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
13 months agocmd/compile: enhance tighten pass for memory values
erifan01 [Thu, 15 Dec 2022 08:39:07 +0000 (16:39 +0800)]
cmd/compile: enhance tighten pass for memory values

This CL enhances the tighten pass. Previously if a value has memory arg,
then the tighten pass won't move it, actually if the memory state is
consistent among definition and use block, we can move the value. This
CL optimizes this case. This is useful for the following situation:
b1:
  x = load(...mem)
  if(...) goto b2 else b3
b2:
  use(x)
b3:
  some_op_not_use_x

For the micro-benchmark mentioned in #56620, the performance improvement
is about 15%.
There's no noticeable performance change in the go1 benchmark.

Fixes #56620

Change-Id: I9b152754f27231f583a6995fc7cd8472aa7d390c
Reviewed-on: https://go-review.googlesource.com/c/go/+/458755
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>

13 months agogo/types, types2: use version data type instead of major,minor ints
Robert Griesemer [Tue, 2 May 2023 22:55:03 +0000 (15:55 -0700)]
go/types, types2: use version data type instead of major,minor ints

Also, move version type declaration and associated operations to
the top of version.go.

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

13 months agogo/types, types2: combine version check with version error reporting
Robert Griesemer [Tue, 2 May 2023 21:09:45 +0000 (14:09 -0700)]
go/types, types2: combine version check with version error reporting

This removes the duplicate (and possible error-prone) versions
(once for test and once for error message) and simplifies code.

Adjusted multiple go/types call sites to match types2.

Renamed posFor to atPos in types2, for closer match with go/types
and to keep automatic generation of instantiate.go working.

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

13 months agocmd/compile: enable reverse type inference
Robert Griesemer [Tue, 2 May 2023 17:06:44 +0000 (10:06 -0700)]
cmd/compile: enable reverse type inference

For #59338.

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