1
0
mirror of https://github.com/golang/go synced 2024-11-27 04:21:24 -07:00
Commit Graph

54289 Commits

Author SHA1 Message Date
hopehook
12daabb915 go/build: replace +build with go:build in documentation
Fixes #54181.

Change-Id: I47f5102ff2095a794b6fc6bcf75617ba5f85c24d
Reviewed-on: https://go-review.googlesource.com/c/go/+/437995
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-10-03 18:24:24 +00:00
cui fliter
78f7d0f001 cmd/compile/internal: fix a few function names on comments
Change-Id: If78c6d3c6183494f71f2857e496e172a789da39f
GitHub-Last-Rev: 58e0b75052
GitHub-Pull-Request: golang/go#55992
Reviewed-on: https://go-review.googlesource.com/c/go/+/437517
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
2022-10-03 17:47:02 +00:00
cuiweixie
a8d180409d cmd/trace: replace loop with append(slice, slice2...)
Change-Id: I4686f36a8f718fea1a08d816bc14e24e3528bb07
Reviewed-on: https://go-review.googlesource.com/c/go/+/436706
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: hopehook <hopehook@golangcn.org>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-10-03 15:30:36 +00:00
miller
17622b891a runtime/coverage: recognise Plan 9 error message in emitToNonexistentDir
In TestCoverageApis/emitToNonexistentDir there is a list of error
messages to match when a nonexistent directory is opened. The list
has message text only for Unix and Windows. Add the corresponding
text for Plan 9.

Fixes #55983

Change-Id: Id32130300cb02394b319e1aeb1229ee147b4afb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/437557
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2022-10-03 15:17:12 +00:00
chanxuehong
5451ba3ac4 go/token: fix File.AddLineColumnInfo logic
The offset of the line info should be smaller than the file size.
Otherwise, it should be ignored.
Before the change, such an invalid line info won't be ignored when it's
the first one to add.

Change-Id: Id17492a8de97f277a49a59fae0070efeec40b2f9
GitHub-Last-Rev: 4d61d73c3a
GitHub-Pull-Request: golang/go#48456
Reviewed-on: https://go-review.googlesource.com/c/go/+/350741
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Zeke Lu <lvzecai@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: hopehook <hopehook@golangcn.org>
2022-10-03 13:05:50 +00:00
Félix Dorn
e7e554e546 log/syslog: return nil directly
Reduce return complexity.

Change-Id: I280a0fe1a49371e231e93e0d3e177730b6f28769
GitHub-Last-Rev: 2ebc10641d
GitHub-Pull-Request: golang/go#55989
Reviewed-on: https://go-review.googlesource.com/c/go/+/437516
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-10-03 08:59:45 +00:00
cui fliter
1888875182 regexp: fix a few function names on comments
Change-Id: I192dd34c677e52e16f0ef78e1dae58a78f6d1aac
GitHub-Last-Rev: 1638a74689
GitHub-Pull-Request: golang/go#55967
Reviewed-on: https://go-review.googlesource.com/c/go/+/436885
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-10-02 02:31:23 +00:00
Ian Lance Taylor
82e357d6d5 os: use backslashes for DirFS on Windows
Otherwise DirFS of a UNC path does not work.

Fixes #54694

Change-Id: I82c1c436f7c26b3935c2cc4fd238daf094fc4d86
Reviewed-on: https://go-review.googlesource.com/c/go/+/426094
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: hopehook <hopehook@golangcn.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-10-02 02:31:18 +00:00
hopehook
4585bf96b4 all: use time.Since instead of time.Now().Sub
Change-Id: Ifaa73b64e5b6a1d37c753e2440b642478d7dfbce
Reviewed-on: https://go-review.googlesource.com/c/go/+/436957
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: hopehook <hopehook@golangcn.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-10-02 02:28:27 +00:00
cui fliter
51297dd6df syscall: remove redundant type conversion
Change-Id: Iae290216687fd1ce8be720600157fb78cc2446d0
GitHub-Last-Rev: 4fba64ecb1
GitHub-Pull-Request: golang/go#55959
Reviewed-on: https://go-review.googlesource.com/c/go/+/436881
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-10-02 02:27:38 +00:00
cui fliter
5f566d35bf crypto/rand: convert r.used to atomic type
For #53821

Change-Id: I1b5c62288eca20ff50f6d8d979cf82df24d4545b
GitHub-Last-Rev: 266148570a
GitHub-Pull-Request: golang/go#54884
Reviewed-on: https://go-review.googlesource.com/c/go/+/428477
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-10-01 08:32:46 +00:00
Daniel Martí
ef1c70fbde cmd/go: remove the -i build flag
The flag is now removed from `go build` and `go test`.
It has been deprecated since Go 1.16, printing a warning message.
The idea was to fully delete it in Go 1.17, but that didn't happen.

First, delete the BuildI variable and its flag declarations,
as well as all the bits of docs that mentioned the flag.

Second, delete or simplify the code paths that used BuildI.

Third, adapt the tests to the removed flag.
Some of them are removed, like test_relative_import_dash_i.txt and
TestGoTestDashIDashOWritesBinary, as they centered around the flag.
The rest are modified to not cover or use the flag.

Finally, change cmd/dist to no longer use `go install -i`.
The purpose of the flag was that, when bootstrapping the toolchain,
all of its dependencies would also be installed as object files.

When removing the use of the -i flags, the checkNotStale call right
after building toolchain3 would fail as expected,
because runtime/internal/sys is now only up to date in the build cache.

Luckily, that's not a problem: we run `go install std cmd` right after,
so all standard library packages will be installed as object files.
Move the checkNotStale call after that install command.

Fixes #41696.

Change-Id: I5d8139f18aaee07da886d483e663f3f2f00d5f3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/416094
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-10-01 08:31:45 +00:00
Mikael Urankar
738a2caf08 cmd/dist: add support for freebsd/riscv64
Updates #53466

Change-Id: I6643b4254dc707351d397018cee485bb508dde94
Reviewed-on: https://go-review.googlesource.com/c/go/+/431659
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Goutnik <dgoutnik@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-10-01 06:43:40 +00:00
David Chase
2b1c414fa8 cmd/internal/obj: hoist constant slice out of function called in loop
It's all local to a single file and responsible for 1.7% of total
space allocated summed over compilation of the bent benchmarks.

Showing nodes accounting for 27.16GB, 27.04% of 100.44GB total
Dropped 1622 nodes (cum <= 0.50GB)
Showing top 10 nodes out of 321
      flat  flat%   sum%        cum   cum%
    4.87GB  4.85%  4.85%     4.87GB  4.85%  cmd/compile/internal/objw.init
    4.79GB  4.77%  9.62%     4.81GB  4.79%  runtime.allocm
    4.72GB  4.70% 14.32%     4.72GB  4.70%  cmd/compile/internal/types.newType
    3.10GB  3.09% 17.41%     3.17GB  3.15%  cmd/compile/internal/ssagen.InitConfig
    1.86GB  1.85% 19.26%     2.61GB  2.60%  cmd/compile/internal/ssa.cse

    1.72GB  1.71% 20.97%     2.25GB  2.24%  cmd/internal/obj.(*Link).traverseFuncAux

    1.66GB  1.65% 22.62%     1.66GB  1.65%  runtime.malg
    1.61GB  1.61% 24.23%     1.64GB  1.63%  cmd/compile/internal/ssa.schedule
    1.42GB  1.41% 25.64%     1.42GB  1.41%  cmd/compile/internal/ir.NewNameAt

Change-Id: Id18ee3b83cb23a7042d59714a0c1ca074e7bc7a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/437297
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2022-10-01 02:15:39 +00:00
Cuong Manh Le
1baea0ddb3 test: skip inlining check in escape4.go
This is the last failed test in Unified IR, since it can inline f5 and
f6 but the old frontend can not. So marking them as //go:noinline, with
a TODO for re-enable once GOEXPERIMENT=nounified is gone.

Fixes #53058

Change-Id: Ifbbc49c87997a53e1b323048f0067f0257655fad
Reviewed-on: https://go-review.googlesource.com/c/go/+/437217
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-10-01 01:52:17 +00:00
Cuong Manh Le
0cbe30467a test: relax closure name matching in closure3.go
The mismatch between Unified IR and the old frontend is not about how
they number the closures, but how they name them. For nested closure,
the old frontend use the immediate function which contains the closure
as the outer function, while Unified IR uses the outer most function as
the outer for all closures.

That said, what important is matching the number of closures, not their
name prefix. So this CL relax the test to match both "main.func1.func2"
and "main.func1.2" to satisfy both Unified IR and the old frontend.

Updates #53058

Change-Id: I66ed816d1968aa68dd3089a4ea5850ba30afd75b
Reviewed-on: https://go-review.googlesource.com/c/go/+/437216
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-10-01 01:52:16 +00:00
eric fang
dd7ce26abf math: optimize Hypot function
This CL optimizes the Hypot function by putting the Abs function in
front of the IsInf check. This simplifies the judgment of IsInf.

Benchmarks:
On linux/arm64,
name         old time/op  new time/op  delta
Hypot-160    5.26ns ± 0%  4.53ns ± 0%  -13.84%  (p=0.000 n=4+5)
HypotGo-160  5.19ns ± 0%  4.85ns ± 0%   -6.53%  (p=0.008 n=5+5)

On linux/amd64,
name        old time/op  new time/op  delta
Hypot-44    5.99ns ± 0%  5.99ns ± 0%     ~     (p=0.667 n=5+5)
HypotGo-44  7.46ns ± 0%  6.61ns ± 0%  -11.37%  (p=0.008 n=5+5)

On darwin/arm64,
name       old time/op  new time/op  delta
Hypot-8    3.58ns ± 0%  2.79ns ± 0%  -22.01%  (p=0.008 n=5+5)
HypotGo-8  3.58ns ± 0%  2.79ns ± 0%  -22.15%  (p=0.008 n=5+5)

Change-Id: Id79236e01d9494b6e00bbda3ec08c72caf5ef3c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/414974
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Eric Fang <eric.fang@arm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-10-01 01:51:35 +00:00
Bryan C. Mills
9a029a6915 os/exec: make StdoutPipe and StderrPipe safe to Close concurrently
For #50436, I want to be able to close the pipes returned by
StdoutPipe and StderrPipe after the Context has been canceled
and the WaitDelay has subsequently expired.

However, the fact that the exec.onceCloser wrapper for StdinPipe
(added in CL 13329043) was retained in CL 65490 suggests to me that
(*os.File).Close is still not safe to call concurrently.

This may cause type assertions of these ReadClosers to *os.File that
once succeeded to no longer do so. However, the StdoutPipe and
StderrPipe methods return interfaces, not concrete *os.Files, so
callers already should not have been relying on that implementation
detail — and as far as I can tell the closeOnce wrapper does not mask
any (*os.File) methods, so assertions to any interface type that
previously succeeded will continue to do so.

This change is logically part of CL 401835, but since it may expose
fragile type-assertions in callers I want to keep it separate for
clearer bisection of any new test failures.

For #50436.

Change-Id: I58de1d48fb6fd788502f13657d8d4484516271cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/437176
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-10-01 00:21:25 +00:00
Bryan C. Mills
c9a62b7e71 os/exec: recombine goroutinePipes and userPipes
This change undoes CL 401894, because on further consideration
it turns out not to be needed.

This also makes (*Cmd).closeDescriptors a free function, since it does
not actually use the receiver in any way and is not needed to satisfy
any interfaces.

For #50436.

Change-Id: I7915265b0e6398ed5a34fae0c12873ab08a14194
Reviewed-on: https://go-review.googlesource.com/c/go/+/437175
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
2022-10-01 00:12:32 +00:00
Ian Lance Taylor
20da893e83 debug/dwarf: don't crash on negative range/rnglist offset
No test case because the problem can only happen for invalid data. Let
the fuzzer find cases like this.

Fixes #55948

Change-Id: I7ba40ba928d2a14d4ac5b39f966173f3868d4729
Reviewed-on: https://go-review.googlesource.com/c/go/+/436876
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2022-10-01 00:07:46 +00:00
Tobias Klauser
cc90e45f1d all: use "unix" build tag where appropriate
Convert a few occurrences that were submitted after CL 389935.

For #20322
For #51572

Change-Id: I0047361916c402f8e37f515e6b09d451bd499e6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/437235
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-30 23:58:34 +00:00
cui fliter
aeab76f0be encoding: fix a few function names on comments
Change-Id: I17a311afb94a056b3d35bfa241f5d0d206db602d
GitHub-Last-Rev: 42129464c9
GitHub-Pull-Request: golang/go#55962
Reviewed-on: https://go-review.googlesource.com/c/go/+/436882
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Rob Pike <r@golang.org>
2022-09-30 23:03:07 +00:00
Cuong Manh Le
76c1a501a5 test: enable issue47631.go for Unified IR
Updates #53058

Change-Id: Ieaa500bea11f26f9a039196592bea67405bdf0ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/437215
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-30 23:00:20 +00:00
Cuong Manh Le
aeedb5ab13 internal/singleflight: avoid race between multiple Do calls
When the first call to Do finished, it calls c.wg.Done() to signal
others that the call was done. However, that happens without holding
a lock, so if others call to Do complete and be followed by a call to
ForgotUnshared, that then returns false.

Fixing this by moving c.wg.Done() inside the section guarded by g.mu, so
the two operations won't be interrupted.

Thanks bcmills@ for finding and suggesting fix.

Change-Id: I850f5eb3f9751a0aaa65624d4109aeeb59dee42c
Reviewed-on: https://go-review.googlesource.com/c/go/+/436437
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-30 20:49:56 +00:00
cuiweixie
1e65fa58c1 encoding/json: return comparison directly
Change-Id: I4698d0fa78108d83ee91732e8d3878dbff7f9c90
Reviewed-on: https://go-review.googlesource.com/c/go/+/436711
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
2022-09-30 20:10:56 +00:00
cui fliter
4444f850b7 all: omit comparison bool constant to simplify code
Change-Id: Icd4062e570559f1d0c69d4bdb9e23412054cf2a6
GitHub-Last-Rev: fbbfbcb54d
GitHub-Pull-Request: golang/go#55958
Reviewed-on: https://go-review.googlesource.com/c/go/+/436880
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-09-30 20:09:46 +00:00
Cuong Manh Le
826efd7f25 internal/singleflight: fix duplicate deleting key when ForgetUnshared called
A key may be forgotten while the call is still in flight. So when the
call finished, it should only delete the key if that key is associated
with the call. Otherwise, we may remove the wrong newly created call.

Fixes #55343

Change-Id: I4fa72d79cad006e5884e42d885d193641ef84e0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/433315
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-30 20:05:46 +00:00
Michael Pratt
8a0cf719a6 cmd/link/internal/ld: panic if inlined functions missing FuncInfo
All inlined functions are Go functions, and thus should be capable of
having a FuncInfo. Missing FuncInfo is likely indication of a compiler
bug that dropped the symbol too early, failing to add it to the symbol
list used for writing output. I believe all existing cases have been
fixed; this check will prevent regressions.

The exception is -linkshared mode. There symbols are loaded from the
shared library, and the FuncInfo is not available. This is a bug, as it
can result in incorrect the FuncID in inlinedCall, but it is very
involved to fix.

For #54959.
For #55954.

Change-Id: Ib0dc4f1ea62525b55f68604d6013ff33223fdcdd
Reviewed-on: https://go-review.googlesource.com/c/go/+/429637
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-30 20:05:02 +00:00
Michael Pratt
33738ddd0a cmd/compile: eagerly create LSym for closures
The linker needs FuncInfo metadata for all inlined functions. This is
typically handled by gc.enqueueFunc calling ir.InitLSym for all function
declarations in typecheck.Target.Decls (ir.UseClosure adds all closures
to Decls).

However, non-trivial closures in Decls are ignored, and are insteaded
enqueued when walk of the calling function discovers them.

This presents a problem for direct calls to closures. Inlining will
replace the entire closure definition with its body, which hides the
closure from walk and thus suppresses symbol creation.

Explicitly create a symbol early in this edge case to ensure we keep
this metadata.

InitLSym needs to move out of ssagen to avoid a circular dependency (it
doesn't have anything to do with ssa anyway). There isn't a great place
for it, so I placed it in ir, which seemed least objectionable.

The added test triggers one of these inlined direct non-trivial closure
calls, though the test needs CL 429637 to fail, which adds a FuncInfo
assertion to the linker. Note that the test must use "run" instead of
"compile" since the assertion is in the linker, and "compiler" doesn't
run the linker.

Fixes #54959.

Change-Id: I0bd1db4f3539a78da260934cd968372b7aa92546
Reviewed-on: https://go-review.googlesource.com/c/go/+/436240
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-30 20:04:54 +00:00
Michael Pratt
4a49af5755 Revert "runtime: move epoll syscalls to runtime/internal/syscall"
This reverts CL 421994.

Reason for revert: breaks runtime.TestCheckPtr2

For #53824
For #51087

Change-Id: I044ea4d6efdffe0a4b7fb0d2bb3717d9f391fc59
Reviewed-on: https://go-review.googlesource.com/c/go/+/437295
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-09-30 19:07:13 +00:00
Andrew Pogrebnoy
4e6f963469 runtime: move epoll syscalls to runtime/internal/syscall
This change moves Linux epoll's syscalls implementation to the
"runtime/internal/syscall" package. The intention in this CL was to
minimise behavioural changes but make the code more generalised. This
also will allow adding new syscalls (like epoll_pwait2) without the
need to implement assembly stubs for each arch.

It also drops epoll_create as not all architectures provide this call.
epoll_create1 was added to the kernel in version 2.6.27 and Go requires
Linux kernel version 2.6.32 or later since Go 1.18. So it is safe to
always use epoll_create1.

For #53824
For #51087

Change-Id: I9a6a26b7f2075a38e041de1bab4691da0ecb94fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/421994
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2022-09-30 17:35:24 +00:00
David Chase
9e0149da3c cmd/compile: fuse largest possible runs of plain blocks
This is predicted to reduce allocation, hence GC time.
(And it does.)

Change-Id: I30a46805b81e5ecd3fd7a6737f60ec26ef0498b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/434796
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2022-09-30 17:13:39 +00:00
cui fliter
73e14a3026 internal: fix a few function names on comments
Change-Id: I53169e386b8c789b092de348fa891fe50e11c2ef
GitHub-Last-Rev: 75232393b4
GitHub-Pull-Request: golang/go#55965
Reviewed-on: https://go-review.googlesource.com/c/go/+/436883
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-30 16:39:12 +00:00
Than McIntosh
902da52f7b Revert "cmd/cgo, cmd/compile, cmd/link: remove old style build tags"
This reverts commit 6616573982, corresponding to CL 436915.

Reason for revert: this is causing some bootstrap build problems with older versions of Go 1.17, as I understand it. Still under investigation.

Change-Id: Idb6e17ff7b47004cbf87f967af6d84f214d8abb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/435471
Reviewed-by: David Chase <drchase@google.com>
2022-09-30 14:43:55 +00:00
cuiweixie
13159fef04 go: replace bytes.Compare with bytes.Equal
Change-Id: I268033bfcda34b76ef1d3a3446d6d1d875fc33ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/436716
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-09-30 14:14:36 +00:00
cuiweixie
7aa4905bb4 go/doc: use strings.TrimPrefix
Change-Id: Ie1e76d2e99bf2af7f064c9073c1fb866086962f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/436715
Run-TryBot: Robert Griesemer <gri@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-30 14:12:38 +00:00
Than McIntosh
9910f8a403 internal/buildcfg: enabled CoverageRedesign GOEXPERIMENT by default
Turn on the CoverageRedesign GOEXPERIMENT by default.

Updates #51430.

Change-Id: Id15c67ef0b6ac421b188d163fd2ce4a302abb3c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/436236
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
2022-09-30 13:50:45 +00:00
Tobias Klauser
6616573982 cmd/cgo, cmd/compile, cmd/link: remove old style build tags
The minimum bootstrap version for Go ≥ 1.20 is Go 1.17. That version
supports the new style //go:build lines. Thus the old style //+build
lines can be dropped in this part of the tree as well. Leave the
//+build lines in cmd/dist which will ensure the minimum Go version
during bootstrap.

As suggested by Cherry during review of CL 430496

For #44505

Change-Id: If53c0b02cacbfb055a33e73cfd38578dfd3aa340
Reviewed-on: https://go-review.googlesource.com/c/go/+/436915
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2022-09-30 11:22:39 +00:00
doujiang24
d7dbe0111e runtime/trace: skip tests if parsing fails with timestamp error
already skips tests in case of the timestamp error, eg. #97757

Change-Id: Ia696e83cba2e3ed50181a8100b964847092a7365
GitHub-Last-Rev: 8e5f607e14
GitHub-Pull-Request: golang/go#55918
Reviewed-on: https://go-review.googlesource.com/c/go/+/435855
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
2022-09-30 05:48:38 +00:00
Mikael Urankar
9faf6b7929 cmd/link/internal/riscv64: add support for freebsd/riscv64
Updates #53466

Change-Id: Ifa1b8fe79f952a08dbdf91ae5ab23e4431e66134
Reviewed-on: https://go-review.googlesource.com/c/go/+/431660
Reviewed-by: Dmitri Goutnik <dgoutnik@gmail.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-30 03:08:40 +00:00
cuiweixie
2cbcf36ede cmd/internal: use fmt.Fprintf
Change-Id: Ifa78c98bf919ea62136f19b2bad0a8ee33afc646
Reviewed-on: https://go-review.googlesource.com/c/go/+/435695
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-09-30 01:56:14 +00:00
cuiweixie
f1f85f4ab5 strconv: delete unused field
Change-Id: I1257270c55d69962988b6034e7341a9142a0c449
Reviewed-on: https://go-review.googlesource.com/c/go/+/436720
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-30 01:40:34 +00:00
cuiweixie
157e018fc3 cmd/compile/internal/noder: remove unnecessary assignment to the blank identifier
Change-Id: I51dd087e630bf433c30d0aaaf3715b62524eb432
Reviewed-on: https://go-review.googlesource.com/c/go/+/436647
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-30 01:35:55 +00:00
cuiweixie
dc53738f58 internal/profile: omit comparison tool bool constant
Change-Id: I59b3e72382433a6dd82306f026171f3af4a6cba7
Reviewed-on: https://go-review.googlesource.com/c/go/+/436717
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2022-09-30 01:34:14 +00:00
cuiweixie
574b5decf2 cmd/internal/obj/x86: return comparison directly
Change-Id: I4b596b252c1785b13c4a166e9ef5f4ae812cd1bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/436704
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-09-29 23:49:16 +00:00
cuiweixie
1a6af5f7a0 cmd/internal/obj: call delete directly without check exist
Change-Id: I5350c6374cd39ce4512d29cd8a341c4996f3b601
Reviewed-on: https://go-review.googlesource.com/c/go/+/436703
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-09-29 23:49:15 +00:00
cuiweixie
1f15838392 cmd/internal/dwarf: remove redundant break statement
Change-Id: I20956187e925ef6ab35d23b23c40bbb0ee55ef4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/436702
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-09-29 23:49:14 +00:00
cuiweixie
d547ae2a8e cmd/internal/cov: use io.SeekStart, io.SeekCurrent, and io.SeekEnd
Change-Id: Ibf7e33e42c649783eaa0e638babff22d96ab51c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/436701
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-29 23:49:12 +00:00
cuiweixie
fdcaae5734 cmd/go/internal/mvs: remove useless type assertion
Change-Id: Ifdb351193cab1c0b905a1cde17993231f849644c
Reviewed-on: https://go-review.googlesource.com/c/go/+/436700
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-29 23:49:11 +00:00
cuiweixie
2fedd335f0 cmd/go/internal/modindex: should omit comparison to bool constant
Change-Id: Iea75d0475e1cc8f794a7bae864c6ce0e6e33cb6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/436698
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-29 23:48:48 +00:00