1
0
mirror of https://github.com/golang/go synced 2024-11-17 06:04:47 -07:00
Commit Graph

52679 Commits

Author SHA1 Message Date
Xiaodong Liu
7607888df0 runtime: load/save TLS variable g on loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I5e09759ce9201596e89a01fc4a6f7fd7e205449f
Reviewed-on: https://go-review.googlesource.com/c/go/+/368074
Reviewed-by: David Chase <drchase@google.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>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-17 20:18:25 +00:00
John Bampton
13147f744c runtime: fix code span element
Change-Id: I99c593573b3bec560ab3af49ac2f486ee442ee1c
GitHub-Last-Rev: e399ec50f9
GitHub-Pull-Request: golang/go#52946
Reviewed-on: https://go-review.googlesource.com/c/go/+/406837
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2022-05-17 20:05:58 +00:00
Xiaodong Liu
88c5324f2e internal/syscall/unix: loong64 use generic syscall
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I5988bf3efed37b03b9193f1089dfece060ccba99
Reviewed-on: https://go-review.googlesource.com/c/go/+/363934
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-17 19:57:24 +00:00
Xiaodong Liu
d28bf6c9a2 internal/bytealg: support basic byte operation on loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I4ac6d38dc632abfa0b698325ca0ae349c0d7ecd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/342316
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-17 19:55:37 +00:00
John Bampton
a6f3f8d973 all: fix spelling
Change-Id: I68538a50c22b02cdb5aa2a889f9440fed7b94c54
GitHub-Last-Rev: aaac9e7834
GitHub-Pull-Request: golang/go#52944
Reviewed-on: https://go-review.googlesource.com/c/go/+/406835
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
2022-05-17 19:51:29 +00:00
Tobias Klauser
c25c37137d compress/flate: remove var newH
After CL 404696 hewH is no longer used outide the loop and val can be
used inside the loop instead. This leads to another slight improvement
in some benchmarks (only non-zero results reported):

name                             old time/op    new time/op     delta
Decode/Digits/Huffman/1e4-4         125µs ±40%       96µs ± 7%  -22.72%  (p=0.000 n=10+10)
Decode/Digits/Huffman/1e5-4        1.02ms ± 4%     0.97ms ± 3%   -4.29%  (p=0.000 n=10+10)
Decode/Digits/Huffman/1e6-4        10.5ms ± 3%     10.1ms ± 2%   -3.34%  (p=0.000 n=10+9)
Decode/Digits/Speed/1e4-4           130µs ± 5%      119µs ± 3%   -8.33%  (p=0.000 n=10+10)
Decode/Digits/Speed/1e5-4          1.32ms ± 3%     1.26ms ± 4%   -4.14%  (p=0.001 n=10+10)
Decode/Digits/Speed/1e6-4          13.4ms ± 3%     12.8ms ± 3%   -4.64%  (p=0.000 n=10+10)
Decode/Digits/Default/1e4-4         142µs ±19%      124µs ± 3%  -12.75%  (p=0.000 n=10+9)
Decode/Digits/Default/1e5-4        1.33ms ± 4%     1.27ms ± 2%   -4.45%  (p=0.000 n=10+10)
Decode/Digits/Compression/1e4-4     132µs ± 4%      126µs ± 3%   -4.59%  (p=0.000 n=10+10)
Decode/Digits/Compression/1e5-4    1.31ms ± 4%     1.28ms ± 3%   -2.12%  (p=0.015 n=10+10)
Decode/Digits/Compression/1e6-4    13.2ms ± 3%     12.8ms ± 4%   -3.36%  (p=0.000 n=10+10)
Decode/Newton/Huffman/1e4-4         138µs ± 5%      128µs ± 3%   -7.55%  (p=0.000 n=10+9)
Decode/Newton/Huffman/1e5-4        1.25ms ± 1%     1.23ms ± 3%   -2.21%  (p=0.027 n=8+10)
Decode/Newton/Huffman/1e6-4        13.0ms ± 5%     12.2ms ± 5%   -6.54%  (p=0.000 n=10+10)
Decode/Newton/Speed/1e4-4           128µs ± 3%      118µs ± 4%   -7.34%  (p=0.000 n=9+10)
Decode/Newton/Speed/1e5-4          1.06ms ± 3%     1.02ms ± 3%   -3.58%  (p=0.001 n=9+10)
Decode/Newton/Speed/1e6-4          10.4ms ± 4%     10.1ms ± 3%   -3.15%  (p=0.003 n=10+10)
Decode/Newton/Compression/1e4-4     105µs ± 2%      108µs ± 5%   +2.82%  (p=0.043 n=9+10)
Encode/Digits/Speed/1e5-4          1.65ms ± 2%     1.70ms ± 4%   +2.77%  (p=0.003 n=8+10)
Encode/Newton/Default/1e6-4        58.0ms ± 2%     57.0ms ± 1%   -1.59%  (p=0.001 n=9+9)

name                             old speed      new speed       delta
Decode/Digits/Huffman/1e4-4      82.2MB/s ±30%  103.9MB/s ± 8%  +26.38%  (p=0.000 n=10+10)
Decode/Digits/Huffman/1e5-4      98.5MB/s ± 4%  102.9MB/s ± 3%   +4.46%  (p=0.000 n=10+10)
Decode/Digits/Huffman/1e6-4      95.6MB/s ± 3%   98.9MB/s ± 2%   +3.44%  (p=0.000 n=10+9)
Decode/Digits/Speed/1e4-4        76.9MB/s ± 5%   83.8MB/s ± 3%   +9.06%  (p=0.000 n=10+10)
Decode/Digits/Speed/1e5-4        75.8MB/s ± 3%   79.1MB/s ± 4%   +4.34%  (p=0.001 n=10+10)
Decode/Digits/Speed/1e6-4        74.4MB/s ± 3%   78.0MB/s ± 3%   +4.86%  (p=0.000 n=10+10)
Decode/Digits/Default/1e4-4      70.7MB/s ±17%   80.6MB/s ± 2%  +13.93%  (p=0.000 n=10+9)
Decode/Digits/Default/1e5-4      75.4MB/s ± 4%   78.9MB/s ± 3%   +4.60%  (p=0.000 n=10+10)
Decode/Digits/Compression/1e4-4  75.8MB/s ± 3%   79.4MB/s ± 3%   +4.79%  (p=0.000 n=10+10)
Decode/Digits/Compression/1e5-4  76.5MB/s ± 4%   78.1MB/s ± 3%   +2.15%  (p=0.015 n=10+10)
Decode/Digits/Compression/1e6-4  75.7MB/s ± 3%   78.3MB/s ± 4%   +3.49%  (p=0.000 n=10+10)
Decode/Newton/Huffman/1e4-4      72.4MB/s ± 5%   78.3MB/s ± 3%   +8.13%  (p=0.000 n=10+9)
Decode/Newton/Huffman/1e5-4      79.8MB/s ± 1%   81.6MB/s ± 3%   +2.29%  (p=0.026 n=8+10)
Decode/Newton/Huffman/1e6-4      76.9MB/s ± 5%   82.2MB/s ± 5%   +6.96%  (p=0.000 n=10+10)
Decode/Newton/Speed/1e4-4        78.4MB/s ± 3%   84.6MB/s ± 4%   +7.92%  (p=0.000 n=9+10)
Decode/Newton/Speed/1e5-4        94.2MB/s ± 3%   97.7MB/s ± 3%   +3.72%  (p=0.001 n=9+10)
Decode/Newton/Speed/1e6-4        96.0MB/s ± 4%   99.1MB/s ± 3%   +3.24%  (p=0.003 n=10+10)
Decode/Newton/Compression/1e4-4  95.2MB/s ± 2%   92.6MB/s ± 5%   -2.67%  (p=0.043 n=9+10)
Encode/Digits/Speed/1e5-4        60.6MB/s ± 2%   59.0MB/s ± 4%   -2.66%  (p=0.002 n=8+10)
Encode/Newton/Default/1e6-4      17.3MB/s ± 2%   17.5MB/s ± 1%   +1.60%  (p=0.001 n=9+9)

Change-Id: I833b008fe5b67cd17ffdfbec22a3e4b10fcddece
Reviewed-on: https://go-review.googlesource.com/c/go/+/406754
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-17 19:51:27 +00:00
Xiaodong Liu
30b17b6f60 internal/{cpu, goarch}: add constant definition for loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I39d42e5959391e47bf621b3bdd3d95de72f023cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/342318
Reviewed-by: David Chase <drchase@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>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-17 19:48:21 +00:00
Keith Randall
d23c80b8e4 doc: update jump table performance release note
Just make it clearer that the performance gains are for the switch
statement itself, not the whole program.

Change-Id: I2d1bf2888f61112af3dc37113e740b00b092e2cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/406874
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-05-17 19:40:11 +00:00
Rob Pike
668041ef66 fmt: add Append, Appendln, Appendf
These are straightforward variants of the existing Sprintf etc.,
but append the resulting bytes to a provided buffer rather than
returning a string.

Internally, there is potentially some allocation because the package
uses a pool of buffers to build its output. We make no attempt to
override that, so the result is first printed into the pool and
then copied to the output. Since it is a managed pool, asymptotically
there should be no extra allocation.

Fixes #47579

RELNOTE=yes

Change-Id: Icef797f9b6f0c84d03e7035d95c06cdb819e2649
Reviewed-on: https://go-review.googlesource.com/c/go/+/406177
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-17 18:55:46 +00:00
Xiaodong Liu
076039a5e1 cmd/nm, cmd/objdump, cmd/pprof: disassembly is not supported on loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: Ic96e4f0c46d9a6b8cd020e899f32c40681daf9c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/342323
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-05-17 18:19:34 +00:00
Cuong Manh Le
afd181cf0b test,misc: fix builders that do not support plugin
CL 406358 added test that use -buildmode=plugin. But plugin mode only
supports on some os/arch pairs, so this CL moving the test to
misc/cgo/testplugin directory instead.

Updates #52937

Change-Id: Iad049443c1f6539f6af1988bebd4dff56c6e1bf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/406774
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-17 18:13:13 +00:00
Xiaodong Liu
cc4957a5f6 cmd/link: support linker for linux/loong64
The basic arch-specific hooks are implemented, which
are used for internal and external linker.

Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I4680eb0635dd0fa3d6ea8348a2488da9c7e33d3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/349514
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-05-17 17:54:33 +00:00
Kévin Dunglas
770e0e584a net/http: allow sending 1xx responses
Currently, it's not possible to send informational responses such as
103 Early Hints or 102 Processing.

This patch allows calling WriteHeader() multiple times in order
to send informational responses before the final one.

If the status code is in the 1xx range, the current content of the header map
is also sent. Its content is not removed after the call to WriteHeader()
because the headers must also be included in the final response.

The Chrome and Fastly teams are starting a large-scale experiment to measure
the real-life impact of the 103 status code.
Using Early Hints is proposed as a (partial) alternative to Server Push,
which are going to be removed from Chrome:
https://groups.google.com/a/chromium.org/g/blink-dev/c/K3rYLvmQUBY/m/21anpFhxAQAJ

Being able to send this status code from servers implemented using Go would
help to see if implementing it in browsers is worth it.

Fixes #26089
Fixes #36734
Updates #26088

Change-Id: Ib7023c1892c35e8915d4305dd7f6373dbd00a19d
GitHub-Last-Rev: 06d749d345
GitHub-Pull-Request: golang/go#42597
Reviewed-on: https://go-review.googlesource.com/c/go/+/269997
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-17 16:09:37 +00:00
Dmitri Shuralyov
cf7ec0fa09 cmd/pprof: update vendored github.com/google/pprof
Pull in the latest published version of github.com/google/pprof
as part of go.dev/issue/36905.

Done with:

	go get github.com/google/pprof@upgrade
	go mod tidy
	go mod vendor

For #36905.

Change-Id: I3c8279fce2f20cb940a4e46b2b850703e1fc7964
Reviewed-on: https://go-review.googlesource.com/c/go/+/406359
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2022-05-17 14:39:18 +00:00
hopehook
41b9d8c75e time: add Time.ZoneBounds
The method Location.lookup returns the "start" and "end" times bracketing seconds when that zone is in effect.

This CL does these things:

1. Exported the "start" and "end" times as time.Time form
2. Keep the "Location" of the returned times be the same as underlying time

Fixes #50062.

Change-Id: I88888a100d0fc68f4984a85c75a85a83aa3e5d80
Reviewed-on: https://go-review.googlesource.com/c/go/+/405374
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-05-17 03:26:28 +00:00
Damien Neil
aedf298daf io/fs: document requirement that ReadDir return an unwrapped io.EOF
This requirement ensures that ReadDir implementations are as compatible
as possible with "*os.File".ReadDir.

The testing/fstest package already tests for equality to io.EOF.

Updates #47062.
Fixes #47086.

Change-Id: I54f911a34e507a3db0abc4da55a19b7a50b35041
Reviewed-on: https://go-review.googlesource.com/c/go/+/333149
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-05-17 01:50:34 +00:00
Cuong Manh Le
f2b1cde544 cmd/compile: tighten the condition for inlining shape/non-shape function
CL 395854 made inline pass to not inlining function with shape params,
but pass no shape arguments. This is intended to be the reverse case of
CL 361260.

However, CL 361260 is using wider condition than necessary. Though it
only needs to check against function parameters, it checks whether the
function type has no shape. It does not cause any issue, because
!fn.Type().HasShape() implies !fn.Type().Params().HasShape().

But for the reverse case, it's not true. Function may have shape type,
but has no shape arguments. Thus, we must tighten the condition to
explicitly check against the function parameters only.

Fixes #52907

Change-Id: Ib87e87ff767c31d99d5b36aa4a6c1d8baf32746d
Reviewed-on: https://go-review.googlesource.com/c/go/+/406475
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-05-17 00:58:22 +00:00
Matthew Dempsky
b79c135f37 cmd/compile: skip exporting generic functions for -buildmode=plugin
Generic functions require instantiation, which package plugin doesn't
support, and likely never will. So instead, we can just skip writing
out any generic functions, which avoids an ICE in the plugin
generation code.

This issue doesn't affect GOEXPERIMENT=unified, because it avoids
leaking any non-instantiated types/functions to the rest of the
compiler backend.

Fixes #52937.

Change-Id: Ie35529c5c241e46b77fcb5b8cca48bb99ce7bfcb
Reviewed-on: https://go-review.googlesource.com/c/go/+/406358
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2022-05-17 00:53:54 +00:00
Matthew Dempsky
a900a176bf cmd/compile/internal/types: use Type.LinkString in TypeHash
Now that Type.LinkString always returns a fully unique string ID, we
can use it in TypeHash to avoid collisions between instantiations of
the same generic type.

Updates #51734.

Change-Id: I38cb396c88259be7afa44bd4333124ca98666c3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/393716
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2022-05-16 23:55:03 +00:00
Dmitri Shuralyov
d81dd12906 all: update vendored golang.org/x dependencies for Go 1.19 release
The Go 1.19 code freeze has recently started. This is a time to update
all golang.org/x/... module versions that contribute packages to the
std and cmd modules in the standard library to latest master versions.

This CL updates the rest of the modules with x/build/cmd/updatestd.

For #36905.

Change-Id: I4751ca477365b036a8e5ad6a9256293b44ddcd2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/406356
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2022-05-16 22:26:23 +00:00
Dmitri Shuralyov
420a1fb223 all: update vendored golang.org/x/{arch,sys,term} for Go 1.19 release
The Go 1.19 code freeze has recently started. This is a time to update
all golang.org/x/... module versions that contribute packages to the
std and cmd modules in the standard library to latest master versions.

This CL updates only the lower-level modules arch, sys, term for better
bisection. The next CL will update further ones.

For #36905.

Change-Id: I15f6f8b015f8e425571f4f072d6942c806c6ec3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/406355
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-16 22:24:28 +00:00
Rob Pike
053b63cfb5 text/template/parse: make atTerminator more efficient
The change https://go.dev/cl/398475 was too complicated and expensive.
Since the whole string is always available, all that's needed
is a call to strings.HasPrefix.

While we're here, change the way lexer.backup works
so it can be called repeatedly to back up more than one
rune, in case that becomes necessary. This change also
requires less state to maintain, as lexer.width was only
there for backup, and prevented multiple steps.

Fixes #52191

Change-Id: I43b64fc66edeb8ba73ba5aa72f3b727c377dc067
Reviewed-on: https://go-review.googlesource.com/c/go/+/406476
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-16 21:02:09 +00:00
Matthew Dempsky
a8facc456f cmd/compile/internal/typecheck: remove "name" handling in iimport.go
This hack is no longer needed since CL 393715, because LocalPkg.Prefix
is set correctly, so when we write out instantiated objects/types into
the export data, they'll already have a proper name.

Updates #51734.

Change-Id: I26cfa522f1bfdfd162685509757f51093b8b92e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/406318
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-05-16 20:54:16 +00:00
Matthew Dempsky
2540f4e49d cmd/compile: remove base.Ctxt.Pkgpath fallback paths
Historically, the compiler set types.LocalPkg.Path to "", so a lot of
compiler code checks for this, and then falls back to using
base.Ctxt.Pkgpath instead.

Since CL 393715, we now initialize types.LocalPkg.Path to
base.Ctxt.Pkgpath, so these code paths can now simply rely on Pkg.Path
always being meaningful.

Updates #51734.

Change-Id: I0aedbd7cf8e14edbfef781106a9510344d468f2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/406317
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
2022-05-16 20:19:45 +00:00
Matthew Dempsky
99d63007a0 test: fix issue20014 for noopt builder
This test is currently overly sensitive to compiler optimizations,
because inlining can affect the order in which cmd/link emits field
references. The order doesn't actually matter though, so this CL just
tweaks the test to sort the tracked fields before printing them.

Updates #51734.

Change-Id: I3b65ca265856b2e1102f40406d5ce34610c70d40
Reviewed-on: https://go-review.googlesource.com/c/go/+/406674
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-16 19:48:35 +00:00
Rhys Hiltner
6ec46f4707 runtime/pprof: slow new goroutine launches in test
The goroutine profiler tests include one that launches a steady stream
of goroutines. That creates a scheduler busy loop that can prevent
forward progress in the rest of the program. Slow down the launches a
bit so other goroutines have a chance to run.

Fixes #52916
For #52934

Change-Id: I748557201b94918b1fa4960544a51a48d9cacc6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/406654
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-05-16 18:30:07 +00:00
Matthew Dempsky
ab8d7dd75e cmd/compile: set LocalPkg.Path to -p flag
Since CL 391014, cmd/compile now requires the -p flag to be set the
build system. This CL changes it to initialize LocalPkg.Path to the
provided path, rather than relying on writing out `"".` into object
files and expecting cmd/link to substitute them.

However, this actually involved a rather long tail of fixes. Many have
already been submitted, but a few notable ones that have to land
simultaneously with changing LocalPkg:

1. When compiling package runtime, there are really two "runtime"
packages: types.LocalPkg (the source package itself) and
ir.Pkgs.Runtime (the compiler's internal representation, for synthetic
references). Previously, these ended up creating separate link
symbols (`"".xxx` and `runtime.xxx`, respectively), but now they both
end up as `runtime.xxx`, which causes lsym collisions (notably
inittask and funcsyms).

2. test/codegen tests need to be updated to expect symbols to be named
`command-line-arguments.xxx` rather than `"".foo`.

3. The issue20014 test case is sensitive to the sort order of field
tracking symbols. In particular, the local package now sorts to its
natural place in the list, rather than to the front.

Thanks to David Chase for helping track down all of the fixes needed
for this CL.

Updates #51734.

Change-Id: Iba3041cf7ad967d18c6e17922fa06ba11798b565
Reviewed-on: https://go-review.googlesource.com/c/go/+/393715
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-05-16 18:19:47 +00:00
Bryan C. Mills
db875f4d1b runtime/pprof: eliminate arbitrary deadline in testCPUProfile
The testCPUProfile helper function iterates until the profile contains
enough samples. However, in general very slow builders may need longer
to complete tests, and may have less-responsive schedulers (leading to
longer durations required to collect profiles with enough samples).
To compensate, slower builders generally run tests with longer timeouts.

Since this test helper already dynamically scales the profile duration
based on the collected samples, allow it to continue to retry and
rescale until it would exceed the test's deadline.

Fixes #52656 (hopefully).

Change-Id: I4561e721927503f33a6d23336efa979bb9d3221f
Reviewed-on: https://go-review.googlesource.com/c/go/+/406614
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
2022-05-16 16:15:58 +00:00
Matthew Dempsky
2a6e13843d cmd/compile/internal/ir: more idiomatic DynamicType{,AssertExpr}
Rename DynamicType's "X" field to "RType".

Split DynamicTypeAssertExpr's "T" field into "RType" and "ITab", the
same as DynamicType, updating all uses accordingly.

Change-Id: I8cec8171349c93234a10ac50708f800dee6fb1d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/405334
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2022-05-16 09:35:17 +00:00
Matthew Dempsky
3caf67d247 go/importer: disable TestForCompiler/LookupCustom for GOEXPERIMENT=unified
The TestForCompiler/LookupCustom test tries to read in the export data
for "math/big", but with a package path of "math/bigger" instead. This
has historically worked because the export data formats were designed
to not assume the package's own path, but I expect we can safely
remove support for this now.

However, since that would be a user-visible change, for now just
disable the test for GOEXPERIMENT=unified so we can land CL 393715. We
can revisit whether it's actually safe to break that go/importer use
case later.

Updates #51734.

Change-Id: I5e89314511bd1352a9f5e14a2e218a5ab00cab3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/406319
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-16 09:31:42 +00:00
Matthew Dempsky
568590b085 runtime: mark panicshift and panicdivide as //go:yeswritebarrierrec
When compiling package runtime, cmd/compile logically has two copies
of package runtime: the actual source files being compiled, and the
internal description used for emitting compiler-generated calls.

Notably, CL 393715 will cause the compiler's write barrier validation
to start recognizing that compiler-generated calls are actually calls
to the corresponding functions from the source package. And today,
there are some code paths in nowritebarrierrec code paths that
actually end up generating code to call panicshift or panicdivide.

In preparation, this CL marks those functions as
//go:yeswritebarrierrec. We probably want to actually cleanup those
code paths to avoid these calls actually (e.g., explicitly convert
shift count expressions to an unsigned integer type). But for now,
this at least unblocks CL 393715 while preserving the status quo.

Updates #51734.

Change-Id: I01f89adb72466c0260a9cd363e3e09246e39cff9
Reviewed-on: https://go-review.googlesource.com/c/go/+/406316
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-16 09:31:07 +00:00
Matthew Dempsky
35d83535f7 cmd/compile/internal/test: don't initialize LocalPkg.Path to ""
Updates #51734.

Change-Id: I80c4e9ae7e17172f26cd32509ce0cb5b4d311819
Reviewed-on: https://go-review.googlesource.com/c/go/+/406315
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-05-16 09:30:57 +00:00
Meng Zhuo
9956996f6e runtime: add address sanitizer support for riscv64
Updates #44853

Change-Id: I3ba6ec0cfc6c7f311b586deedb1cda0f87a637aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/375256
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: Zhuo Meng <mzh@golangcn.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: David Chase <drchase@google.com>
2022-05-16 06:55:54 +00:00
Xiaodong Liu
335569b598 cmd/asm/internal: assembler end-to-end test for loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I93d8be36e44e516df70b25e20d9c0695a05510d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/349510
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-05-14 23:57:43 +00:00
Cuong Manh Le
19156a5474 cmd/compile: fix inlining function has shape in type
CL 395854 made inline pass to not inlining function with shape params,
but pass no shape arguments. But it does not consider the case where
function has shape params, but passing zero arguments. In this case, the
un-safe interface conversion that may be applied to a shape argument can
not happen, so it's safe to inline the function.

Fixes #52907

Change-Id: Ifa7b23709bb47b97e27dc1bf32343d92683ef783
Reviewed-on: https://go-review.googlesource.com/c/go/+/406176
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-05-14 15:26:27 +00:00
hopehook
3474cd4eee encoding/csv: add Reader.InputOffset method
Fixes #43401.

Change-Id: I2498e77e41d845130d95012bc8623bfb29c0dda1
Reviewed-on: https://go-review.googlesource.com/c/go/+/405675
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-05-14 04:25:13 +00:00
Cuong Manh Le
cb458c05a8 cmd/compile: don't inline fn with shape params, but passed no shape arg
This is the same fix as CL 36126, but for the reverse case, function
with shape params but passed no shape arg. The same conversion problem
may occur in this case, see details explanation there.

Fixes #51909
Fixes #51925

Change-Id: Ib0c1973c7511d85b4918a252c80060f1864180cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/395854
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-14 00:29:30 +00:00
Jinzhu
21680959f8 database/sql: follow convention for field naming
Change-Id: I161072698dad8f184b46c6e627bbfbcb18a1b5c6
GitHub-Last-Rev: 7c8d241280
GitHub-Pull-Request: golang/go#52770
Reviewed-on: https://go-review.googlesource.com/c/go/+/404934
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: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-14 00:17:10 +00:00
Michael Anthony Knyszek
08d6c4c2b9 runtime: account for idle mark time in the GC CPU limiter
Currently the GC CPU limiter doesn't account for idle application time
at all. This means that the GC could start thrashing, for example if the
live heap exceeds the max heap set by the memory limit, but the limiter
will fail to kick in when there's a lot of available idle time. User
goroutines will still be assisting at a really high rate because of
assist pacing rules, but the GC CPU limiter will fail to kick in because
the actual fraction of GC CPU time will be low if there's a lot of
otherwise idle time (for example, on an overprovisioned system).

Luckily, that idle time is usually eaten up entirely by idle mark
workers, at least during the GC cycle. And in these cases where we're
GCing continuously, that's all of our idle time. So we can take idle
mark work time and subtract it from the mutator time accumulated in the
GC CPU limiter, and that will give us a more accurate picture of how
much CPU is being spent by user goroutines on GC. This will allow the GC
CPU limiter to kick in, and reduce the impact of the thrashing.

There is a corner case here if the idle mark workers are disabled, for
example for the periodic GC, but in the case of the periodic GC, I don't
think it's possible for us to be thrashing at all, so it doesn't really
matter.

Fixes #52890.

Change-Id: Ie133a7d1f89b603434b415d51eb8733c2708a858
Reviewed-on: https://go-review.googlesource.com/c/go/+/405898
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-13 22:25:51 +00:00
Xiaodong Liu
845a95b1ae cmd/compile/internal: fix test error on loong64
For TestLogOpt test case, add loong64 support to test the host
architecture and os.

The Ctz64 is not intrinsified on loong64 for TestIntendedInlining.

Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I42280e89a337dbfde55a01a134820f8ae94f6b47
Reviewed-on: https://go-review.googlesource.com/c/go/+/400237
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-05-13 22:18:38 +00:00
Daniel Martí
9e9e2a82d8 cmd/compile: tidy up noder's unified IR docs
Hopefully made the wording clearer as I was reading it.

Change-Id: I241ce3f2ac7ae77de00dbc969540c09ef0b77496
Reviewed-on: https://go-review.googlesource.com/c/go/+/395394
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
2022-05-13 21:50:20 +00:00
Matthew Dempsky
4170084ad1 cmd/compile/internal/ir: remove PkgFuncName assumption that LocalPkg.Path == ""
Prep refactoring for CL 393715, after which LocalPkg.Path will no
longer be the empty string. Instead of testing `pkg.Path == ""`, we
can just test `pkg == LocalPkg`.

Updates #51734.

Change-Id: I74fff7fb383e275c9f294389d30b2220aced19e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/406059
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-13 21:33:25 +00:00
Matthew Dempsky
aa6b75dd7d cmd/compile/internal/types: remove Type.sym and rename Type.nod to Type.obj
Now that Ntype is gone, we no longer require separate sym and nod
fields for Type. It's now always the case that t.sym == t.nod.Sym(),
or that t.sym and t.nod are both nil.

While here, rename nod to obj, to better reflect that in fact it's
always an object (i.e., *ir.Name), not merely a type literal (which no
longer exists in package ir).

Change-Id: Iba4c1590ca585b816ff6b70947ad2a1109918955
Reviewed-on: https://go-review.googlesource.com/c/go/+/405656
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-13 21:29:20 +00:00
Matthew Dempsky
53db708a1d cmd/compile/internal/types: change structuraltype_test.go to external test
This test can run against package types's exported API just fine.

Change-Id: I74184eedc9ca9159b05d893c5f7c615c3dd1884d
Reviewed-on: https://go-review.googlesource.com/c/go/+/405655
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-05-13 21:28:48 +00:00
Matthew Dempsky
e99275241c cmd/compile/internal/types: change NewTypeParam to match New{Basic,Named}
NewBasic and NewNamed take an Object (i.e., *ir.Name), so that callers
don't need to call SetNod. This CL changes NewTypeParam to follow the
same convention. Following up on recent Ntype removal, this allows
getting rid of Type.SetNod entirely.

While here, Type.SetSym is unused too.

Change-Id: Ibe0f5747e2ab4a9512b65142b6d3006704b60bd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/405654
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-13 21:28:41 +00:00
Cuong Manh Le
80f3e3deba cmd/compile/internal/ir: remove NilExpr.Sym_
Historically, the compiler used to use a name node to represent "nil".
Now, "nil" is represented by NilExpr, so it's not necessary to associate
a Sym with it anymore.

Passes toolstash-check.

Change-Id: Ied1ddefa06ea55ada18ca52c8fcf71defa4c23b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/406174
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-05-13 21:28:16 +00:00
Matthew Dempsky
499e334a28 cmd/compile/internal/staticdata: remove use of "" in embed linker symbols
Not strictly necessary for CL 393715, but this is necessary if we want
to remove the logic from cmd/internal/obj for substituting `""` in
linker symbol names.

Updates #51734.

Change-Id: Ib13cb12fa3973389ca0c1c9a9209e00c30dc9431
Reviewed-on: https://go-review.googlesource.com/c/go/+/406058
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-05-13 21:12:30 +00:00
Matthew Dempsky
e3661d5f08 cmd/compile/internal/typecheck: remove iexport assumption of LocalPkg.Path == ""
The indexed export data format encodes the local package's path as "",
because that's historically how we've represented it within
cmd/compile. The format also requires the local package to be first in
the exported list of packages, and was implicitly relying on ""
sorting before other, non-empty package paths.

We can't change the format without breaking existing importers (e.g.,
go/internal/gcimporter), but we can at least remove the dependency on
LocalPkg.Path being "".

Prep refactoring for CL 393715.

Updates #51734.

Change-Id: I6dd4eafd2d538f4e81376948ef9e92fc44a5462a
Reviewed-on: https://go-review.googlesource.com/c/go/+/406057
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
2022-05-13 21:12:24 +00:00
Matthew Dempsky
1973be519a cmd/compile/internal/noder: remove unified IR assumptions on LocalPkg.Path == ""
Replace `pkg.Path == ""` check with `pkg == types.LocalPkg`. This is a
prep refactoring for CL 393715, which will properly initialize
types.LocalPkg.

Updates #51734.

Change-Id: I7a5428ef1f422de396762b6bc6d323992834b27c
Reviewed-on: https://go-review.googlesource.com/c/go/+/406056
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-13 21:12:13 +00:00
Matthew Dempsky
b6c5a5baa7 cmd/compile/internal/gc: parse command-line flags earlier
This CL moves the call to base.ParseFlags() earlier in compiler
startup. This is necessary so CL 393715 can use base.Ctxt.Pkgpath to
construct types.LocalPkg.

Updates #51734.

Change-Id: I9f5f75dc9d5fd1b1d22e98523efc95e6cec64385
Reviewed-on: https://go-review.googlesource.com/c/go/+/406055
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-13 21:12:06 +00:00