]> Cypherpunks repositories - gostls13.git/log
gostls13.git
5 years ago[dev.link] cmd/link: fix trampoline generation on AIX
Cherry Zhang [Thu, 16 Apr 2020 03:11:52 +0000 (23:11 -0400)]
[dev.link] cmd/link: fix trampoline generation on AIX

The addend should be applied to the target symbol, not the TOC
symbol.

Change-Id: I0a14873cdcafc4ede401878882646dade9cd8e3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/228479
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years ago[dev.link] cmd/link: fix buglet in dodata
Cherry Zhang [Thu, 16 Apr 2020 01:55:35 +0000 (21:55 -0400)]
[dev.link] cmd/link: fix buglet in dodata

Fix AIX build.

Change-Id: I5c0f1390a62c684bb0b162c3309902566cc6b025
Reviewed-on: https://go-review.googlesource.com/c/go/+/228477
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years ago[dev.link] cmd/link/internal/loader: remove some unused types
Than McIntosh [Wed, 15 Apr 2020 17:46:25 +0000 (13:46 -0400)]
[dev.link] cmd/link/internal/loader: remove some unused types

The types funcAllocInfo and funcInfoSym are no longer referenced.

Fixes #38456.

Change-Id: Icd32445f6027429f4a2781554d2086790ebe5daf
Reviewed-on: https://go-review.googlesource.com/c/go/+/228318
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years ago[dev.link] cmd/link: begin splitting up dodata()
Than McIntosh [Tue, 14 Apr 2020 19:14:54 +0000 (15:14 -0400)]
[dev.link] cmd/link: begin splitting up dodata()

Begin refactoring dodata to try to convert it from a single giant blob
to something more hierarchical, with descriptive function names for
sub-parts.

Add a state object to hold things like "data" and "dataMaxAlign"
arrays that are used throughout dodata. Extract out the code that
allocates data symbols to sections into a separate method (this
method is still too big, probably needs to be refactored again).

No change in functionality.

Change-Id: I7b52dc2aff0356e7d4b5d6f629d907fd37d3082c
Reviewed-on: https://go-review.googlesource.com/c/go/+/228259
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years ago[dev.link] cmd/link: hoist dwarfGenerateDebugSyms out of dodata()
Than McIntosh [Mon, 13 Apr 2020 19:38:03 +0000 (15:38 -0400)]
[dev.link] cmd/link: hoist dwarfGenerateDebugSyms out of dodata()

Hoist dwarfGenerateDebugSyms call up out of dodata to before
loadlibfull. This required a couple of small tweaks to the
loader and to loadlibfull.

Change-Id: I48ffb450d2e48b9e55775b73a6debcd27dbb7b9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/228221
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years ago[dev.link] cmd/oldlink: update with recent change
Cherry Zhang [Tue, 14 Apr 2020 16:35:54 +0000 (12:35 -0400)]
[dev.link] cmd/oldlink: update with recent change

Port CL 227864 to cmd/oldlink.

Change-Id: Ib05628e59a6616f422111b564a72c908c44062a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/228227
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years ago[dev.link] all: merge branch 'master' into dev.link
Cherry Zhang [Tue, 14 Apr 2020 16:08:07 +0000 (12:08 -0400)]
[dev.link] all: merge branch 'master' into dev.link

Change-Id: I31a52b1840ea773d23f5cc60484131ddf898b841

5 years ago[dev.link] cmd/link: remove some globals from symtab.go
Jeremy Faller [Fri, 10 Apr 2020 18:53:01 +0000 (14:53 -0400)]
[dev.link] cmd/link: remove some globals from symtab.go

Change-Id: Ia2540779c1bf01248591568e1ddef1eef6edc20e
Reviewed-on: https://go-review.googlesource.com/c/go/+/227917
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years agocmd/compile: remove "special return in disguise" case
Cuong Manh Le [Sun, 12 Apr 2020 16:38:36 +0000 (23:38 +0700)]
cmd/compile: remove "special return in disguise" case

ascompatee does not generate 'x = x' during return, so we don't have to
check for samelist and disguising special return anymore.

While at it, also remove samelist, as this is the only place it's used.

Passes toolstash-check.

Change-Id: I41c7b077d562aadb5916a61e2ab6229bae3cdef4
Reviewed-on: https://go-review.googlesource.com/c/go/+/227807
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
5 years agogo/types: use same local variable consistently (minor cleanup)
Robert Griesemer [Tue, 14 Apr 2020 04:57:41 +0000 (21:57 -0700)]
go/types: use same local variable consistently (minor cleanup)

Currently this CL has no effect because V == x.typ in the affected
code. But if we should ever manipulate V (e.g., to support some form
of lazy evaluation of the type), not using V consistently would
lead to a subtle bug.

Change-Id: I465e72d18bbd2b6cd8fcbd746e0d28d14f758c03
Reviewed-on: https://go-review.googlesource.com/c/go/+/228105
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agotime: quote original value in errors returned by ParseDuration
Obeyda Djeffal [Sat, 11 Apr 2020 22:21:22 +0000 (23:21 +0100)]
time: quote original value in errors returned by ParseDuration

Quote original values passed as substring of ParseError.Message.
Improves the user experience of ParseDuration by making it
quote its original argument, for example:

   _, err := time.ParseDuration("for breakfast")
 will now produce an error, which when printed out is:

  time: invalid duration "for breakfast"
 instead of:

  time: invalid duration for breakfast

Adapt test cases for format.Parse and format.ParseDuration.

Fixes #38295

Change-Id: Ife322c8f3c859e1e4e8dd546d4cf0d519b4bfa81
Reviewed-on: https://go-review.googlesource.com/c/go/+/227878
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoRevert "time/tzdata: new package"
Ian Lance Taylor [Mon, 13 Apr 2020 23:26:39 +0000 (23:26 +0000)]
Revert "time/tzdata: new package"

This reverts CL 224588.

Reason for revert: Test failing on secondary platforms.

Change-Id: Ic15fdc73a0d2b860e776733abb82c58809e13160
Reviewed-on: https://go-review.googlesource.com/c/go/+/228200
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoio: simplify Examples
Eric [Mon, 13 Apr 2020 21:28:47 +0000 (21:28 +0000)]
io: simplify Examples

- CopyN: 5 creates ambiguity with respect to whitespace and upperbound
- TeeReader less boilerplate and displays a common usage of it
- SectionReader_* all sections unified to 5:17 for clarity
- SectionReader_Seek uses io.Copy to stdout like other examples
- Seeker_Seek remove useless prints
- Pipe print reader like other examples

Updates #36417

Change-Id: Ibd01761d5a5786cdb1ea934f7a98f8302430c8a5
GitHub-Last-Rev: 4c17f9a8e32d89743b7eaec7c52032256972cc0a
GitHub-Pull-Request: golang/go#38379
Reviewed-on: https://go-review.googlesource.com/c/go/+/227868
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/link: don't split container symbols when write blocks
Cherry Zhang [Sat, 11 Apr 2020 02:11:51 +0000 (22:11 -0400)]
cmd/link: don't split container symbols when write blocks

We split the output into blocks and write them in parallel. The
block boundary is placed at symbol boundary. In the case of outer
symbols and sub symbols, currently we may split an outer symbol
into two blocks. This will be bad, as the two blocks will have
overlapping address range, since outer symbol and its sub symbols
occupies the same address range.

Make sure we place block boundary only at top-level symbol
boundaries.

Fix boringcrypto build.

Change-Id: I56811d3969c65c6be97672d8e1f1ea36b2447465
Reviewed-on: https://go-review.googlesource.com/c/go/+/227957
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
(cherry picked from commit 636fa3148fe149923839a86e648dd87dc4d1537a)
Reviewed-on: https://go-review.googlesource.com/c/go/+/228138

5 years agocmd/compile: debug rewrite
Cherry Zhang [Fri, 24 Jan 2020 15:43:09 +0000 (10:43 -0500)]
cmd/compile: debug rewrite

If -d=ssa/PASS/debug=N is specified (N >= 2) for a rewrite pass
(e.g. lower), when a Value (or Block) is rewritten, print the
Value (or Block) before and after.

For #31915.
Updates #19013.

Change-Id: I80eadd44302ae736bc7daed0ef68529ab7a16776
Reviewed-on: https://go-review.googlesource.com/c/go/+/176718
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agotime/tzdata: new package
Ian Lance Taylor [Sun, 22 Mar 2020 01:28:16 +0000 (18:28 -0700)]
time/tzdata: new package

Importing the time/tzdata package will embed a copy of the IANA
timezone database into the program. This will let the program work
correctly when the timezone database is not available on the system.
It will increase the size of the binary by about 800K.

You can also build a program with -tags timetzdata to embed the
timezone database in the program being built.

Fixes #21881
Fixes #38013
Fixes #38017

Change-Id: Iffddee72a8f46c95fee3bcde43c142d6899d9246
Reviewed-on: https://go-review.googlesource.com/c/go/+/224588
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
5 years agocrypto/x509: fix test to prevent Gerrit keycheck errors
Katie Hockman [Mon, 13 Apr 2020 19:47:53 +0000 (15:47 -0400)]
crypto/x509: fix test to prevent Gerrit keycheck errors

Change-Id: I9e6a11c7d8c61d0182467438b35eb6756db7aa89
Reviewed-on: https://go-review.googlesource.com/c/go/+/228198
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
5 years agoruntime/pprof: clarify recursive inline heuristic
Michael Pratt [Tue, 7 Apr 2020 19:17:25 +0000 (15:17 -0400)]
runtime/pprof: clarify recursive inline heuristic

Following CL 226818, the compiler will allow inlining a single cycle in
an inline chain. Immediately-recursive functions are still disallowed,
which is what this heuristic refers to.

Add a regression test for this case.

Note that in addition to this check, if the compiler were to inline
multiple cycles via a loop (i.e., rather than appending duplicate code),
much more work would be required here to handle a single address
appearing in multiple different inline frames.

Updates #29737

Change-Id: I88de15cfbeabb9c04381e1c12cc36778623132a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/227346
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
5 years agoruntime/pprof: try to use real stack in TestTryAdd
Michael Pratt [Tue, 7 Apr 2020 16:12:44 +0000 (12:12 -0400)]
runtime/pprof: try to use real stack in TestTryAdd

TestTryAdd is particularly brittle because it tests some real cases by
constructing fake sample stack frames. If those frames don't correctly
represent what the runtime would generate then they may fail to catch
regressions.

Instead, call runtime.Callers at the bottom of real function calls to
generate real frames as a base for truncation, etc in tests. Several of
these tests still have to fake parts of the frames to test the right
thing, but this is a bit less fragile.

This change is equivalent to the original
0dfb0513ec6a0e97db166bd91a2dc0a1ceb154f7 (golang.org/cl/227484), except
that the test skips if the test functions aren't inline (e.g., noopt
builders).

Change-Id: Ie9e32b5660cfe28a924f9cfcddcd887ea2effd66
Reviewed-on: https://go-review.googlesource.com/c/go/+/227922
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agocrypto/x509: generate SubjectKeyId for CAs
Katie Hockman [Fri, 3 Apr 2020 15:58:12 +0000 (11:58 -0400)]
crypto/x509: generate SubjectKeyId for CAs

Fixes #26676

Change-Id: I5bc91d4a8161bc6ff25effcf93f551f735fef115
Reviewed-on: https://go-review.googlesource.com/c/go/+/227098
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
5 years agoerrors: add example for Is
Jonathan Amsterdam [Sun, 12 Apr 2020 14:00:27 +0000 (10:00 -0400)]
errors: add example for Is

Add ExampleIs to illustrate how errors.Is works.

Updates #31716.
Updates #38369.

Change-Id: I1b9a6667614635aa3a5ed8b2c108d8eb6f35748b
Reviewed-on: https://go-review.googlesource.com/c/go/+/228038
Reviewed-by: Damien Neil <dneil@google.com>
5 years agocmd/cgo: fix parameter name in godoc comment for badPointerTypedef
Tobias Klauser [Mon, 13 Apr 2020 17:40:11 +0000 (19:40 +0200)]
cmd/cgo: fix parameter name in godoc comment for badPointerTypedef

The parameter name is dt, not t. Also, line-wrap the godoc comment.

Change-Id: Ie012d2a5680525b88e244a3380d72bc4f61da8e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/228058
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years ago[dev.link] cmd/link: remove symbol.FuncInfo
Cherry Zhang [Sun, 12 Apr 2020 16:52:16 +0000 (12:52 -0400)]
[dev.link] cmd/link: remove symbol.FuncInfo

It is no longer used. The only remaining use is in generating
Plan 9 debug info, which is already not supported.

Change-Id: Ia023d6f2fa7d57b97ba861ce464e2eec8ac2d1f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/228142
Reviewed-by: Than McIntosh <thanm@google.com>
5 years ago[dev.link] cmd/link: stop populating lib/unit.Textp
Cherry Zhang [Fri, 10 Apr 2020 23:13:01 +0000 (19:13 -0400)]
[dev.link] cmd/link: stop populating lib/unit.Textp

lib.Textp was used for text address assignment and trampoline
insertion. Now that it has been converted to using the loader,
no need to populate lib.Textp.

Port the logic of canonicalizing dupok symbol's package to the
loader.

unit.Textp was used for DWARF generation, which has also been
converted to using the loader.

Change-Id: I22d4dd30a52a29dd5b1b7b795d43a19f6215e4ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/228140
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years agocrypto/tls: failed tls.Conn.Write returns a permanent error
Katie Hockman [Fri, 10 Apr 2020 14:06:29 +0000 (10:06 -0400)]
crypto/tls: failed tls.Conn.Write returns a permanent error

Fixes #29971

Change-Id: I2f1653640c88fafe0ec17a75dcf41d5896c4cb8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/227840
Run-TryBot: Katie Hockman <katie@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agoRevert "cmd/internal/obj/ppc64: add support for pcalign 32 on ppc64x"
Bryan C. Mills [Mon, 13 Apr 2020 14:56:32 +0000 (14:56 +0000)]
Revert "cmd/internal/obj/ppc64: add support for pcalign 32 on ppc64x"

This reverts CL 227775.

Reason for revert: broke aix-ppc64 builder (https://build.golang.org/log/cf3b4f9fd09ee81f422a4b58488b9d0a2692c949).

Change-Id: I2095bb2aadb5a4064eb89ad353012503faf15709
Reviewed-on: https://go-review.googlesource.com/c/go/+/228143
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: update TestIntendedInlining for riscv64
Joel Sing [Mon, 13 Apr 2020 16:36:36 +0000 (02:36 +1000)]
cmd/compile: update TestIntendedInlining for riscv64

Mark nextFreeFast as not inline, as it is too expensive to inline on riscv64.
Also remove riscv64 from non-atomic inline architectures, as we now have
atomic intrisics.

Updates #22239

Change-Id: I6e0e72c1192070e39f065bee486f48df4cc74b35
Reviewed-on: https://go-review.googlesource.com/c/go/+/227808
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/trace: use the focustask mode for user task/region trace views
Hana (Hyang-Ah) Kim [Fri, 10 Apr 2020 18:56:59 +0000 (14:56 -0400)]
cmd/trace: use the focustask mode for user task/region trace views

The taskid mode is based on the goroutine-oriented trace view,
which displays each goroutine as a separate row. This is good when
inspecting the interaction and timeline among related goroutines,
and the user region information (associated with each goroutine)
in detail, but when many goroutines are involved, this mode does
not scale.

The focustask mode is based on the default trace view with the
user task hierarchy at the top. Each row is a P and there are only
a handful number of Ps in most cases, so browsers can handle
this mode more gracefully. But, I had difficulty in displaying
the user region information (because a goroutine can start/stop/
migrate across Ps, and visualizing the stack of regions nicely
was complicated). It may be doable, but it's a work.

This CL surfaces the hidden focustask mode. Moreover, use it
as the default user task view mode. The taskid mode can be still
accessible through 'goroutine view' links.

Unlike taskid-based user annotation view that extends goroutine-based
trace view, the focustask view

Change-Id: Ib691a5e1dd14695fa70a0ae67bff62817025e8c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/227921
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years ago[dev.link] cmd/link: stop loading FuncInfo in LoadFull
Cherry Zhang [Fri, 10 Apr 2020 22:28:26 +0000 (18:28 -0400)]
[dev.link] cmd/link: stop loading FuncInfo in LoadFull

As we have converted the pclntab generation, FuncInfo is not
needed after. No need to load it.

Change-Id: Idcfe4da44dfc94d8d44509d12179b354a2e295e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/228139
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years agocmd/compile: ensure ... rules have compatible aux and auxint types
Keith Randall [Mon, 13 Apr 2020 03:05:14 +0000 (20:05 -0700)]
cmd/compile: ensure ... rules have compatible aux and auxint types

Otherwise, just copying the aux and auxint fields doesn't make much sense.
(Although there's no bug - it just means it isn't typechecked correctly.)

Change-Id: I4e21ac67f0c7bfd04ed5af1713cd24bca08af092
Reviewed-on: https://go-review.googlesource.com/c/go/+/227962
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/compile: convert more AMD64.rules lines to typed aux mode
Keith Randall [Mon, 13 Apr 2020 00:11:25 +0000 (17:11 -0700)]
cmd/compile: convert more AMD64.rules lines to typed aux mode

Change-Id: Idded860128b1a23680520d8c2b9f6d8620dcfcc7
Reviewed-on: https://go-review.googlesource.com/c/go/+/228077
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years ago[dev.link] cmd/link: fix funcfunctab crash with darwin + plugin
Than McIntosh [Mon, 13 Apr 2020 11:31:19 +0000 (07:31 -0400)]
[dev.link] cmd/link: fix funcfunctab crash with darwin + plugin

Fix a bug in findfunctab when building plugin on Darwin (this is
a regression introduced by CL 227842).

Change-Id: Ic610168e45a750c0a2f2b8611d5d9154e6c2622f
Reviewed-on: https://go-review.googlesource.com/c/go/+/228137
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
5 years agointernal/cpu: unify HWCap/HWCap2 comments
Tobias Klauser [Mon, 13 Apr 2020 10:11:23 +0000 (12:11 +0200)]
internal/cpu: unify HWCap/HWCap2 comments

HWCap and HWCap2 are no longer linknamed into package runtime. Also,
merge two sentences both starting with "These are..." and don't mention
any file name where archauxv is defined, as it become outdated if
support for a new $GOOS/$GOARCH combination is added. This is e.g.
already the case for arm64, where archauxv is also defined for
freebsd/arm64.

Change-Id: I9314a66633736b12e777869a832d8b79d442a6f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/228057
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/link: fix spelling error
Kevin Burke [Mon, 13 Apr 2020 01:57:26 +0000 (18:57 -0700)]
cmd/link: fix spelling error

Change-Id: I6e730a99342563a97c3b1556893c8daaf5b6ec90
Reviewed-on: https://go-review.googlesource.com/c/go/+/228097
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agodoc/debugging_with_gdb: fix the link of delve
chainhelen [Sun, 12 Apr 2020 08:38:21 +0000 (08:38 +0000)]
doc/debugging_with_gdb: fix the link of delve

The repository of delve has already switched from the personal
account github.com/derekparker/delve to the organization account
github.com/go-delve/delve. According to go-delve/delve#1456.

Change-Id: Ie64f72c2808a8aca5059a75e2c2f11d8691e66b3
GitHub-Last-Rev: f90120c3b33f2134a572a62aaf291aa2abe58749
GitHub-Pull-Request: golang/go#38387
Reviewed-on: https://go-review.googlesource.com/c/go/+/227999
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile: run TestLogOpt for riscv64 on amd64
Joel Sing [Sun, 12 Apr 2020 16:47:11 +0000 (02:47 +1000)]
cmd/compile: run TestLogOpt for riscv64 on amd64

Run TestLogOpt for riscv64 on amd64, as is done for other architectures.
This would have caught the test failure on riscv64 introduced in
47ade08141b23cfeafed92943e16012d5dc5eb8b.

Change-Id: If29dea2ef383b087154d046728f6d1c96811f5a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/227806
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
5 years ago[dev.link] cmd/link/internal/loader: get rid of the AttrContainer loader method
Than McIntosh [Sun, 12 Apr 2020 18:19:38 +0000 (14:19 -0400)]
[dev.link] cmd/link/internal/loader: get rid of the AttrContainer loader method

Remove the loader's AttrContainer method, since it is no longer
needed. All of the code in the linker that used s.Attr.Container() is
now upstream of loadlibfull(), and the code in question now uses local
bitmaps to keep track of container text symbols as opposed to loader
methods.

Change-Id: Iae956d24bef2776e181c3b8208476dcb0b9a2916
Reviewed-on: https://go-review.googlesource.com/c/go/+/227959
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years ago[dev.link] cmd/link: convert inltree syms to anonymous in pclntab
Than McIntosh [Fri, 10 Apr 2020 17:07:08 +0000 (13:07 -0400)]
[dev.link] cmd/link: convert inltree syms to anonymous in pclntab

The pclntab phase generates a series of "inltree.*" symbols with
inlining related pcdata; these symbols previously were given names and
enterered into the symbol lookup table, but there is no real reason to
do this, since they never need to be looked up when pcln generation is
done. Switch them over to anonymous symbols.

So as to insure that the later symtab phase picks them up correctly,
assign them a type of SGOFUNC instead of SRODATA, and change symtab to
look for this when assigning symbols to groups.

Change-Id: I38225dbb130ad7aea5d16f79cef3d8d388c61c2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/227845
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years ago[dev.link] cmd/link: convert findfunctab to loader APIs
Than McIntosh [Fri, 10 Apr 2020 14:30:27 +0000 (10:30 -0400)]
[dev.link] cmd/link: convert findfunctab to loader APIs

Convert the linker's findfunctab phase to use the new loader APIs.

Change-Id: Ia980a85963fe2e7c554c212c0cc89208272264bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/227842
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: rewrite some AMD64 rules to use typed aux fields
Keith Randall [Sun, 12 Apr 2020 02:51:09 +0000 (19:51 -0700)]
cmd/compile: rewrite some AMD64 rules to use typed aux fields

Surprisingly many rules needed no modification.

Use wrapper functions for aux like we did for auxint.
Simplifies things a bit.

Change-Id: I2e852e77f1585dcb306a976ab9335f1ac5b4a770
Reviewed-on: https://go-review.googlesource.com/c/go/+/227961
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
5 years agocmd/compile: move more generic rewrites to the typed version
Keith Randall [Sat, 11 Apr 2020 17:32:21 +0000 (10:32 -0700)]
cmd/compile: move more generic rewrites to the typed version

Change-Id: I22d0644710d12c7efc509fd2a15789e2e073e6a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/227869
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
5 years agocmd/compile: log large copies on riscv64
Joel Sing [Sun, 12 Apr 2020 15:39:45 +0000 (01:39 +1000)]
cmd/compile: log large copies on riscv64

Log large copies in the riscv64 compiler.

This was missed in 47ade08141b23cfeafed92943e16012d5dc5eb8b, resulting in
the new test added to cmd/compile/internal/logopt failing on riscv64.

Change-Id: I6f763e86f42834148e911d16928f9fbabcfa4290
Reviewed-on: https://go-review.googlesource.com/c/go/+/227804
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/compile: enable Sqrt as a compiler intrinsic on riscv64
Joel Sing [Sun, 12 Apr 2020 15:45:12 +0000 (01:45 +1000)]
cmd/compile: enable Sqrt as a compiler intrinsic on riscv64

Change-Id: I829a02ced9aa73b45079e67194186116b39504b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/227805
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agoruntime/race: rebuild netbsd .syso
Keith Randall [Sat, 11 Apr 2020 15:51:21 +0000 (08:51 -0700)]
runtime/race: rebuild netbsd .syso

Fixes #14481
Fixes #37355

Change-Id: Idfceaf0e64d340b7304ce9562549a82ebfc27e3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/227867
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
5 years ago[dev.link] cmd/link: don't split container symbols when write blocks
Cherry Zhang [Sat, 11 Apr 2020 02:11:51 +0000 (22:11 -0400)]
[dev.link] cmd/link: don't split container symbols when write blocks

We split the output into blocks and write them in parallel. The
block boundary is placed at symbol boundary. In the case of outer
symbols and sub symbols, currently we may split an outer symbol
into two blocks. This will be bad, as the two blocks will have
overlapping address range, since outer symbol and its sub symbols
occupies the same address range.

Make sure we place block boundary only at top-level symbol
boundaries.

Fix boringcrypto build.

Change-Id: I56811d3969c65c6be97672d8e1f1ea36b2447465
Reviewed-on: https://go-review.googlesource.com/c/go/+/227957
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years agodoc/go1.15, net/url: document new method URL.Redacted
Emmanuel T Odeke [Sat, 11 Apr 2020 22:38:51 +0000 (15:38 -0700)]
doc/go1.15, net/url: document new method URL.Redacted

Adds an entry in the Go1.15 release notes, but also
adds an example test for URL.Redacted.

Follow-up of CL 207082.

Updates #37419

Change-Id: Ibf81989778907511a3a3a3e4a03d1802b5dd9762
Reviewed-on: https://go-review.googlesource.com/c/go/+/227997
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agostrconv: add comment re extFloat errorscale
Nigel Tao [Fri, 10 Apr 2020 01:01:14 +0000 (11:01 +1000)]
strconv: add comment re extFloat errorscale

Change-Id: I6f006ba72e1711ba2a24cd71552855ad88284eec
Reviewed-on: https://go-review.googlesource.com/c/go/+/227797
Reviewed-by: Rémy Oudompheng <remyoudompheng@gmail.com>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
5 years agocmd/compile: guard against invalid phis in shortcircuit
Josh Bleecher Snyder [Wed, 11 Mar 2020 21:49:37 +0000 (14:49 -0700)]
cmd/compile: guard against invalid phis in shortcircuit

In the review of CL 222923, Keith expressed concern
that we could end up with invalid phis.

We have some code to handle this, but on further reflection,
I think it might not handle some cases in which phis get moved.

I can't create a failing case, but guard against it nevertheless.

Change-Id: Ib3a07ac1d36a674c72dcb9cc9261ccfcb716b5a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/227697
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agocmd/compile: correct comment for len check when make slice
Cuong Manh Le [Sat, 11 Apr 2020 14:49:10 +0000 (21:49 +0700)]
cmd/compile: correct comment for len check when make slice

CL 226737 optimizes len check when make slice. The comment that cap is
constrainted to [0, 2^31) is not quite true, it's 31 or 63 depends on
whether it's 32/64-bit systems.

Change-Id: I6f54e41827ffe4d0b67a44975da3ce07b2fabbad
Reviewed-on: https://go-review.googlesource.com/c/go/+/227803
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agocmd/compile: move some generic rules to strongly typed
Keith Randall [Sat, 11 Apr 2020 04:38:49 +0000 (21:38 -0700)]
cmd/compile: move some generic rules to strongly typed

Move a lot of the constant folding rules to use strongly
typed AuxInt fields.

We need more than a cast to convert AuxInt to, e.g., float32.
Make conversion functions for converting back and forth.

Change-Id: Ia3d95ee3583ee2179a10938e20210a7617358c88
Reviewed-on: https://go-review.googlesource.com/c/go/+/227866
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Giovanni Bajo <rasky@develer.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
5 years agocmd/link: turn ASLR off for netbsd+race
Keith Randall [Fri, 10 Apr 2020 21:07:13 +0000 (14:07 -0700)]
cmd/link: turn ASLR off for netbsd+race

The race detector can't handle ASLR (adddress space layout randomization).
On some platforms it can re-exec the binary with ASLR off. But not NetBSD.
For NetBSD we have to introduce a special ELF header note that tells
the kernel not to use ASLR.

This works fine for internal linking. For external linking it also works,
but "readelf -n" shows multiple notes in the resulting binary. Maybe the
last one wins? Not sure, but it appears to work.

Change-Id: I5fe6dd861e42a8293f64d0dacb166631ea670fcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/227864
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
5 years agoRevert "cmd/compile: make logopt test skip if cannot create scratch directory"
Alex Brainman [Sat, 11 Apr 2020 03:33:21 +0000 (03:33 +0000)]
Revert "cmd/compile: make logopt test skip if cannot create scratch directory"

This reverts commit 98534812bdcdd22b13469ea587e310187876b7d2.

Reason for revert: The change does not really fixes issue #38251. CL 227497 is real fix.

Change-Id: I9f556005baf1de968f059fb8dad89dae05330aa6
Reviewed-on: https://go-review.googlesource.com/c/go/+/227802
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
5 years agocmd/compile: add explanations to escape-analysis JSON/LSP logging
David Chase [Mon, 11 Nov 2019 18:18:38 +0000 (13:18 -0500)]
cmd/compile: add explanations to escape-analysis JSON/LSP logging

For 1.15.

From the test:

{"range":{"start":{"line":7,"character":13},"end":{...},"severity":3,"code":"leaks","source":"go compiler","message":"parameter z leaks to ~r2 with derefs=0","relatedInformation":[
{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow:    flow: y = z:"},
{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow:      from y = \u003cN\u003e (assign-pair)"},
{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow:    flow: ~r1 = y:"},
{"location":{"uri":"file://T/file.go","range":{"start":{"line":4,"character":11},"end":{...}},"message":"inlineLoc"},

{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow:      from y.b (dot of pointer)"},
{"location":{"uri":"file://T/file.go","range":{"start":{"line":4,"character":11},"end":{...}},"message":"inlineLoc"},

{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow:      from \u0026y.b (address-of)"},
{"location":{"uri":"file://T/file.go","range":{"start":{"line":4,"character":9},"end":...}},"message":"inlineLoc"},

{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow:      from ~r1 = \u003cN\u003e (assign-pair)"},
{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":3},"end":...}},"message":"escflow:    flow: ~r2 = ~r1:"},
{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":3},"end":...}},"message":"escflow:      from return (*int)(~r1) (return)"}]}

Change-Id: Idf02438801f63e487c35a928cf5a0b6d3cc48674
Reviewed-on: https://go-review.googlesource.com/c/go/+/206658
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: change gc logging to report inline failure instead of success
David Chase [Wed, 4 Mar 2020 21:33:54 +0000 (16:33 -0500)]
cmd/compile: change gc logging to report inline failure instead of success

I've been experimenting with this, success is the wrong thing to report
even though it seems to log much less.

Change-Id: I7c25a45d2f41e82b6c8dd8b0a56ba848c63fb21a
Reviewed-on: https://go-review.googlesource.com/c/go/+/223298
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: prevent constant folding of +/- when result is NaN
Keith Randall [Fri, 10 Apr 2020 16:43:22 +0000 (09:43 -0700)]
cmd/compile: prevent constant folding of +/- when result is NaN

Missed as part of CL 221790. It isn't just * and / that can make NaNs.

Update #36400
Fixes #38359

Change-Id: I3fa562f772fe03b510793a6dc0cf6189c0c3e652
Reviewed-on: https://go-review.googlesource.com/c/go/+/227860
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
5 years ago[dev.link] cmd/link: fix aux symbol handling in Funcdata
Cherry Zhang [Fri, 10 Apr 2020 18:12:44 +0000 (14:12 -0400)]
[dev.link] cmd/link: fix aux symbol handling in Funcdata

If a Go symbol is cloned to external, we should preserve its Aux
symbols for FuncInfo, etc.. We already do this in
loader.FuncInfo, but not in FuncInfo.Funcdata. Do it in the
latter as well. In fact, since FuncInfo and Funcdata should use
the same set of auxs, just record the auxs and reuse.

Should fix PPC64 build.

Change-Id: Iab9020eaca15d98fe3bb41f50f0d5bdb4999e8c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/227848
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years agocmd/internal/obj/ppc64: add support for pcalign 32 on ppc64x
Lynn Boger [Tue, 31 Mar 2020 14:08:29 +0000 (10:08 -0400)]
cmd/internal/obj/ppc64: add support for pcalign 32 on ppc64x

Previous PCALIGN support on ppc64x only accepted 8 and 16 byte
alignment since the default function alignment was 16. Now that
the function's alignment can be set to a larger value when needed,
PCALIGN can accept 32. When this happens then the function's
alignment will be changed to 32.

Test has been updated to recognized this new value.

Change-Id: If82c3cd50d7c686fcf8a9e819708b15660cdfa63
Reviewed-on: https://go-review.googlesource.com/c/go/+/227775
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agotest: add test case that gccgo failed to compile
Ian Lance Taylor [Fri, 10 Apr 2020 00:34:07 +0000 (17:34 -0700)]
test: add test case that gccgo failed to compile

Change-Id: I08ca5f77b7352fe3ced1fbe3d027d6f5b4828e35
Reviewed-on: https://go-review.googlesource.com/c/go/+/227783
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years ago[dev.link] all: merge branch 'master' into dev.link
Cherry Zhang [Fri, 10 Apr 2020 17:50:52 +0000 (13:50 -0400)]
[dev.link] all: merge branch 'master' into dev.link

Clean merge.

Change-Id: Ic3634fa450e42635e2daafb53b7dedc6c954d072

5 years ago[dev.link] cmd/internal/goobj2: remove "2"
Cherry Zhang [Fri, 10 Apr 2020 00:45:14 +0000 (20:45 -0400)]
[dev.link] cmd/internal/goobj2: remove "2"

Rename
Sym2 -> Sym
Reloc2 -> Reloc
Aux2 -> Aux

Also the Reader methods.

Change-Id: I49f29e2d1cb480f5309e01d7a74b5e0897d826fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/227900
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
5 years ago[dev.link] cmd/link: use new-style Reloc accessors in loadpe
Cherry Zhang [Fri, 10 Apr 2020 00:21:13 +0000 (20:21 -0400)]
[dev.link] cmd/link: use new-style Reloc accessors in loadpe

Change-Id: I3601a5b4573e3e742a3e48c9709bbff616619d89
Reviewed-on: https://go-review.googlesource.com/c/go/+/227899
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years ago[dev.link] cmd/link: use new-style Reloc accessors in loadxcoff
Cherry Zhang [Thu, 9 Apr 2020 23:56:05 +0000 (19:56 -0400)]
[dev.link] cmd/link: use new-style Reloc accessors in loadxcoff

Change-Id: I606b60807b4a8b6e5c0f489db3c5d9e75bd1e728
Reviewed-on: https://go-review.googlesource.com/c/go/+/227898
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years ago[dev.link] cmd/link: use new-style Reloc accessors in loadelf
Cherry Zhang [Thu, 9 Apr 2020 23:45:48 +0000 (19:45 -0400)]
[dev.link] cmd/link: use new-style Reloc accessors in loadelf

Change-Id: I9c283aa2631dc21c0567a0708b26cdf95a6dc9fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/227897
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years ago[dev.link] cmd/link: convert pcln linker phase to use loader APIs
Than McIntosh [Tue, 7 Apr 2020 21:08:00 +0000 (17:08 -0400)]
[dev.link] cmd/link: convert pcln linker phase to use loader APIs

Rework the linker's pcln phase to work with the new loader. As part of
this set of changes the handling of "go.file..." symbols has been
revised somewhat -- previously they were treated as always live in the
loader, and now we no longer do this.

The original plan had been to have the new implementation generate
nameless "inltree" symbols, however the plan now is to keep them
named for now and convert them to nameless in a subsequent patch.

Change-Id: If71c93ff1f146dbb63b6ee2546308acdc94b643c
Reviewed-on: https://go-review.googlesource.com/c/go/+/227759
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
5 years agocmd/compile: use a Sym type instead of interface{} for symbolic offsets
Keith Randall [Fri, 10 Apr 2020 03:28:55 +0000 (20:28 -0700)]
cmd/compile: use a Sym type instead of interface{} for symbolic offsets

Will help with strongly typed rewrite rules.

Change-Id: Ifbf316a49f4081322b3b8f13bc962713437d9aba
Reviewed-on: https://go-review.googlesource.com/c/go/+/227785
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
5 years ago[dev.link] cmd/link: add IsWasm method for Target
Than McIntosh [Thu, 9 Apr 2020 00:05:31 +0000 (20:05 -0400)]
[dev.link] cmd/link: add IsWasm method for Target

Add Target.IsWasm method.

Change-Id: Ia3bfc359208b8e392b1a484c41aebce9761bc2f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/227758
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
5 years ago[dev.link] cmd/link/internal/loader: add another symbolbuilder method
Than McIntosh [Wed, 8 Apr 2020 11:35:58 +0000 (07:35 -0400)]
[dev.link] cmd/link/internal/loader: add another symbolbuilder method

Introduce SetAddrPlus method for use with SymbolBuilder.

Change-Id: Ieb2986b2fc1675b7a3a71c84b7219b3d564ac122
Reviewed-on: https://go-review.googlesource.com/c/go/+/227757
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
5 years ago[dev.link] cmd/link/internal/loader: expand methods for FuncInfo
Than McIntosh [Wed, 8 Apr 2020 15:56:43 +0000 (11:56 -0400)]
[dev.link] cmd/link/internal/loader: expand methods for FuncInfo

Expand the methods for the FuncInfo helper, to support reading the
contents of an object file FuncInfo aux symbol using the new style
(that is to say, incrementally and without allocating slices to hold
the various bits).

Change-Id: I953d72c4a53f98c840e6b25b08fd33dc4a833dd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/227585
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agoregexp: add (*Regexp).SubexpIndex
Sylvain Zimmer [Mon, 29 Jul 2019 01:15:36 +0000 (03:15 +0200)]
regexp: add (*Regexp).SubexpIndex

SubexpIndex returns the index of the first subexpression with the given name,
or -1 if there is no subexpression with that name.

Fixes #32420

Change-Id: Ie1f9d22d50fb84e18added80a9d9a9f6dca8ffc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/187919
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
5 years agoruntime: replace the type of netpollWakeSig from a uintptr to a uint32
Andy Pan [Fri, 10 Apr 2020 02:45:58 +0000 (10:45 +0800)]
runtime: replace the type of netpollWakeSig from a uintptr to a uint32

There's no need for netpollWakeSig to use a uintptr type, a uint32 is enough.

Relevant CL: CL 212737

Change-Id: Ide24478b217a02bad62f7e000a9680c26a8c5366
Reviewed-on: https://go-review.googlesource.com/c/go/+/227798
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoos/exec: extend grace period in TestExtraFiles to 20% of overall deadline
Bryan C. Mills [Thu, 9 Apr 2020 15:09:00 +0000 (11:09 -0400)]
os/exec: extend grace period in TestExtraFiles to 20% of overall deadline

Updates #25628

Change-Id: I938a7646521b34779a3a57833e7ce9d508b58faf
Reviewed-on: https://go-review.googlesource.com/c/go/+/227765
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile: start implementing strongly typed aux and auxint fields
Keith Randall [Thu, 19 Mar 2020 23:25:08 +0000 (16:25 -0700)]
cmd/compile: start implementing strongly typed aux and auxint fields

Right now the Aux and AuxInt fields of ssa.Values are typed as
interface{} and int64, respectively. Each rule that uses these values
must cast them to the type they actually are (*obj.LSym, or int32, or
ValAndOff, etc.), use them, and then cast them back to interface{} or
int64.

We know for each opcode what the types of the Aux and AuxInt fields
should be. So let's modify the rule generator to declare the types to
be what we know they should be, autoconverting to and from the generic
types for us. That way we can make the rules more type safe.

It's difficult to make a single CL for this, so I've coopted the "=>"
token to indicate a rule that is strongly typed. "->" rules are
processed as before. That will let us migrate a few rules at a time in
separate CLs.  Hopefully we can reach a state where all rules are
strongly typed and we can drop the distinction.

This CL changes just a few rules to get a feel for what this
transition would look like.

I've decided not to put explicit types in the rules. I think it
makes the rules somewhat clearer, but definitely more verbose.
In particular, the passthrough rules that don't modify the fields
in question are verbose for no real reason.

Change-Id: I63a1b789ac5702e7caf7934cd49f784235d1d73d
Reviewed-on: https://go-review.googlesource.com/c/go/+/190197
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
5 years ago[dev.link] cmd/link: use new-style Reloc accessors in loadmacho
Cherry Zhang [Thu, 9 Apr 2020 01:28:17 +0000 (21:28 -0400)]
[dev.link] cmd/link: use new-style Reloc accessors in loadmacho

Change-Id: I890bd8b297fc5612000131fac7c45f5c623ab908
Reviewed-on: https://go-review.googlesource.com/c/go/+/227764
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years ago[dev.link] cmd/link: convert buildinfo pass to new style
Cherry Zhang [Thu, 9 Apr 2020 18:12:17 +0000 (14:12 -0400)]
[dev.link] cmd/link: convert buildinfo pass to new style

Change-Id: I2e1a6d2f1ef7402277c981282556c276ec0585ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/227771
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years agocmd/compile: use isel with variable shifts on ppc64x
Lynn Boger [Wed, 1 Apr 2020 14:30:05 +0000 (10:30 -0400)]
cmd/compile: use isel with variable shifts on ppc64x

This changes the code generated for variable length shift
counts to use isel instead of instructions that set and
read the carry flag.

This reduces the generated code for shifts like this
by 1 instruction and avoids the use of instructions to
set and read the carry flag.

This sequence can be found in strconv with these results
on power9:

Atof64Decimal                          71.6ns ± 0%  68.3ns ± 0%   -4.61%
Atof64Float                            95.3ns ± 0%  90.9ns ± 0%   -4.62%
Atof64FloatExp                          153ns ± 0%   149ns ± 0%   -2.61%
Atof64Big                               234ns ± 0%   232ns ± 0%   -0.85%
Atof64RandomBits                        348ns ± 0%   369ns ± 0%   +6.03%
Atof64RandomFloats                      262ns ± 0%   262ns ± 0%     ~
Atof32Decimal                          72.0ns ± 0%  68.2ns ± 0%   -5.28%
Atof32Float                            92.1ns ± 0%  87.1ns ± 0%   -5.43%
Atof32FloatExp                          159ns ± 0%   158ns ± 0%   -0.63%
Atof32Random                            194ns ± 0%   191ns ± 0%   -1.55%

Some tests in codegen/shift.go are enabled to verify the
expected instructions are generated.

Change-Id: I968715d10ada405a8c46132bf19b8ed9b85796d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/227337
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years ago[dev.link] cmd/link: convert typelink pass to new style
Cherry Zhang [Wed, 8 Apr 2020 23:46:00 +0000 (19:46 -0400)]
[dev.link] cmd/link: convert typelink pass to new style

Change-Id: If861409a5cc4e398496199a89498a141f106f44f
Reviewed-on: https://go-review.googlesource.com/c/go/+/227762
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years ago[dev.link] cmd/link: add methods for adding relocations in Reloc2 format
Cherry Zhang [Wed, 8 Apr 2020 23:45:12 +0000 (19:45 -0400)]
[dev.link] cmd/link: add methods for adding relocations in Reloc2 format

This is in prepration of removing the old loader.Reloc. This also
introduces a way of adding a slice of relocations more
efficiently (will be used in the next CL).

Change-Id: I3eaee7fb3a3e102a8670990f4a31c40d0b17b8c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/227761
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years ago[dev.link] cmd/internal/goobj2: remove old-style types
Cherry Zhang [Wed, 8 Apr 2020 18:30:55 +0000 (14:30 -0400)]
[dev.link] cmd/internal/goobj2: remove old-style types

They are no longer needed.

Also rewrite the test, as the old one no longer meaningful.

Change-Id: Id39ad6bb2a334cb6d61aa0a7c52837e0c3d62432
Reviewed-on: https://go-review.googlesource.com/c/go/+/227641
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years ago[dev.link] cmd/internal/obj: change writer to use new-style accessors
Cherry Zhang [Wed, 8 Apr 2020 17:24:27 +0000 (13:24 -0400)]
[dev.link] cmd/internal/obj: change writer to use new-style accessors

Introduce field setters and use them on the writer side. Now we
are able to eliminate the old-style types.

Change-Id: I650d837328dc02f9be839d16a31812be86721b91
Reviewed-on: https://go-review.googlesource.com/c/go/+/227640
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years agotest: deflaking measures for runtime gdb test
Than McIntosh [Fri, 13 Mar 2020 15:09:05 +0000 (11:09 -0400)]
test: deflaking measures for runtime gdb test

Tweak the runtime's GDB python test to try to reduce flake failures.

Background: the intent of the testpoint in question is to make sure
that python-supported commands like "info goroutines" or "goroutine 1
backtrace" work properly. The Go code being run under the debugger as
part of the test is single-threaded, but the test is written assuming
that in addition to the primary goroutine there will be other
background goroutines available (owned by the runtime). The flakiness
seems to crop up the most when requesting a backtrace for one of these
background goroutines; the speculation is that if we catch a
runtime-owned goroutine in an odd state, this could interfere with the
test.

The change in this patch is to explicitly start an additional
goroutine from the main thread, so that when the debugger stops the
main thread we can be sure that there is some other non-main goroutine
in a known state.

This change authored by Josh Bleecher Snyder <josharian@gmail.com>.

Updates #24616.

Change-Id: I45682323d5898e5187c0adada7c5d117e92f403b
Reviewed-on: https://go-review.googlesource.com/c/go/+/226558
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years ago[dev.link] cmd/link: delete darwin/386 host object loading support
Cherry Zhang [Thu, 9 Apr 2020 02:39:04 +0000 (22:39 -0400)]
[dev.link] cmd/link: delete darwin/386 host object loading support

In Go 1.15, the darwin/386 port is gone.

Updates #37610.

Change-Id: I308561848d90d9a649b3603ab1f7fc1117305ec1
Reviewed-on: https://go-review.googlesource.com/c/go/+/227763
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
5 years agocmd/oldlink: delete darwin/386 host object loading support
Cherry Zhang [Thu, 9 Apr 2020 15:35:24 +0000 (11:35 -0400)]
cmd/oldlink: delete darwin/386 host object loading support

In Go 1.15, the darwin/386 port is gone.

Updates #37610.

Change-Id: I11627c03403d4d4a3e0950fdedd0d850ae24b439
Reviewed-on: https://go-review.googlesource.com/c/go/+/227766
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/internal/obj/ppc64: leverage AND operation to calculate remainder
Andy Pan [Sun, 5 Apr 2020 14:21:11 +0000 (22:21 +0800)]
cmd/internal/obj/ppc64: leverage AND operation to calculate remainder

Change-Id: I03e2a573eb778591071db4f783585a5d71a14c03
Reviewed-on: https://go-review.googlesource.com/c/go/+/227005
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
5 years agonet: convert many Close tests to use parallel subtests
Bryan C. Mills [Wed, 8 Apr 2020 16:51:50 +0000 (12:51 -0400)]
net: convert many Close tests to use parallel subtests

Also set a deadline in TestCloseWrite so that we can more easily
determine which kind of connection is getting stuck on the
darwin-arm64-corellium builder (#34837).

Change-Id: I8ccacbf436e8e493fb2298a79b17e0af8fc6eb81
Reviewed-on: https://go-review.googlesource.com/c/go/+/227588
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile: do not allocate bucket for non-escaping map
Cuong Manh Le [Tue, 7 Apr 2020 20:08:21 +0000 (03:08 +0700)]
cmd/compile: do not allocate bucket for non-escaping map

For map with hint larger than BUCKETSIZE, makemap ignore allocated
bucket and allocate buckets itself. So do not allocate bucket in
this case, save us the cost of zeroing+assignment to the bucket.

name                            old time/op    new time/op    delta
NewEmptyMap-12                    3.89ns ± 4%    3.88ns ± 2%    ~     (p=0.939 n=19+20)
NewSmallMap-12                    23.3ns ± 3%    23.1ns ± 2%    ~     (p=0.307 n=18+17)
NewEmptyMapHintLessThan8-12       6.43ns ± 3%    6.31ns ± 2%  -1.72%  (p=0.000 n=19+18)
NewEmptyMapHintGreaterThan8-12     159ns ± 2%     150ns ± 1%  -5.79%  (p=0.000 n=20+18)

Benchmark run with commit ab7c174 reverted, see #38314.

Fixes #20184

Change-Id: Ic021f57454c3a0dd50601d73bbd77b8faf8d93b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/227458
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agoencoding/xml: fix reserved namespace check to be case-insensitive
Tamás Gulácsi [Fri, 25 Oct 2019 11:48:02 +0000 (13:48 +0200)]
encoding/xml: fix reserved namespace check to be case-insensitive

Fixes the check for the reserved namespace prefix
"xml" to be case insensitive, so as to match all variants of:

    (('X'|'x')('M'|'m')('L'|'l'))

as mandated by Section 2.3 of https://www.w3.org/TR/REC-xml/

Fixes #35151.

Change-Id: Id5a98e5f9d69d3741dc16f567c4320f1ad0b3c70
Reviewed-on: https://go-review.googlesource.com/c/go/+/203417
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/compile: remove gdata layer in slicesym
Josh Bleecher Snyder [Wed, 8 Apr 2020 20:51:25 +0000 (13:51 -0700)]
cmd/compile: remove gdata layer in slicesym

The previous change moved code around to create slicesym.
This change simplifies slicesym and its callsites
by accepting an int64 for lencap instead of a node,
and by removing all the calls to gdata.
It also stops modifying n,
which avoids the need to make a copy of it.

Passes toolstash-check.

Change-Id: I4d25454d11b4bb8941000244443e3c99eef4bdd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/227550
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
5 years agocmd/compile: refactor static slice symbol creation
Josh Bleecher Snyder [Wed, 8 Apr 2020 20:41:59 +0000 (13:41 -0700)]
cmd/compile: refactor static slice symbol creation

This change mostly moves code around to unify it.
A subsequent change will simplify and improve slicesym.

Passes toolstash-check.

Change-Id: I84a877ea747febb2b571d4089ba6d905b51b27ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/227549
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
5 years agocmd/compile: clean up slice and string offsets/sizes
Josh Bleecher Snyder [Wed, 8 Apr 2020 19:36:35 +0000 (12:36 -0700)]
cmd/compile: clean up slice and string offsets/sizes

Minor cleanup:

* Modernize comments.
* Change from int to int64 to avoid conversions.
* Use idiomatic names.

Passes toolstash-check.

Change-Id: I93560c81926c0f4e00f33129cb4846b53bea99e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/227548
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
5 years agocmd/compile: use math/bits for bvec
Josh Bleecher Snyder [Tue, 28 May 2019 17:35:26 +0000 (10:35 -0700)]
cmd/compile: use math/bits for bvec

And delete some dead code.

Minor cleanup. Passes toolstash-check.

Change-Id: Ia3c77c6bf14942654d00d125a6221e63a442f3c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/227317
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
5 years agocmd/compile: use optimized slice zeroing in deadcode
Josh Bleecher Snyder [Tue, 28 May 2019 21:29:28 +0000 (14:29 -0700)]
cmd/compile: use optimized slice zeroing in deadcode

Minor cleanup. Passes toolstash-check.

Change-Id: I97a027c4ca49ded593e9c7989e9e091ab9336fa3
Reviewed-on: https://go-review.googlesource.com/c/go/+/227318
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
5 years agocmd/compile,runtime: pass only ptr and len to some runtime calls
Josh Bleecher Snyder [Sat, 1 Feb 2020 05:01:55 +0000 (21:01 -0800)]
cmd/compile,runtime: pass only ptr and len to some runtime calls

Some runtime calls accept a slice, but only use ptr and len.
This change modifies most such routines to accept only ptr and len.

After this change, the only runtime calls that accept an unnecessary
cap arg are concatstrings and slicerunetostring.
Neither is particularly common, and both are complicated to modify.

Negligible compiler performance impact. Shrinks binaries a little.
There are only a few regressions; the one I investigated was
due to register allocation fluctuation.

Passes 'go test -race std cmd', modulo #38265 and #38266.
Wow, does that take a long time to run.

Updates #36890

file      before    after     Δ       %
compile   19655024  19655152  +128    +0.001%
cover     5244840   5236648   -8192   -0.156%
dist      3662376   3658280   -4096   -0.112%
link      6680056   6675960   -4096   -0.061%
pprof     14789844  14777556  -12288  -0.083%
test2json 2824744   2820648   -4096   -0.145%
trace     11647876  11639684  -8192   -0.070%
vet       8260472   8256376   -4096   -0.050%
total     115163736 115118808 -44928  -0.039%

Change-Id: Idb29fa6a81d6a82bfd3b65740b98cf3275ca0a78
Reviewed-on: https://go-review.googlesource.com/c/go/+/227163
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agocmd/compile: handle some additional phis in shortcircuit
Josh Bleecher Snyder [Wed, 11 Mar 2020 12:39:08 +0000 (05:39 -0700)]
cmd/compile: handle some additional phis in shortcircuit

Prior to this change, the shortcircuit pass could only
handle blocks containing only a single phi control value,
possibly wrapped in some OpNot and OpCopy values.

This change partially lifts this limitation.
It handles some cases in which the block contains other phi values.
This appears to happen most commonly in cases in which
the conditionals being checked involve the memory state,
in which case there is a phi memory value in the block.

The general idea here is to use the information we have about
the CFG to (1) move the other phi values into other blocks
and/or (2) rewrite uses of the other phi values in other blocks.

For example, consider this CFG:

p   q
 \ /
  b
 / \
t   u

And consider a phi value v in block b.
We'll write v = Phi(p: x, q: y) to say that v has value x corresponding
to inbound block p, and value y for block q.

We will rewrite this CFG to:

p    q
|   /
|  b
|/  \
t    u

What should we do with v?

Any uses of v in u can be replaced with y. Why?
If we are in block u, we came from b, and before that from q.
If prior to b we came from p, then we would have gone to t, not u.
Since we came from q, we know that v took the value y.

Uses of v in t are a bit more complicated.
It is going to end up being a phi value: Phi(p: ?, b: ?).

Suppose, after the rewrite, we came from block p.
Then, before the rewrite, we would have gone to b,
where v would have the value x.
So we have Phi(p: x, b: ?).

Suppose, after the rewrite, we came from block b.
Then we must have come from block q.
If we come from block q, v has value y.
So we have Phi(p: x, b: y).
Uses of v in t can thus be replaced with a new phi value,
with the same values as v, but with altered predecessors.

Similar reasoning can be employed to rewrite or replace
other uses of v elsewhere in the CFG, so that v itself can be eliminated,
and the CFG rewrite can proceed.

This change sets up the infrastructure for such optimizations
and adds a few cheap ones. All optimizations in this change depend
only on the shape of the CFG; future changes may also depend on where
v's uses are. That analysis is more powerful but more expensive,
and should be done incrementally.

The use of closures here is perhaps a bit unusual,
but during development it proved critical to having readable code.
We must decide early on whether we can safely do the CFG modifications,
and then later fix up the phis if so.
Safely storing state and decisions across these two phases is hard to do readably.
Closures solve the problem neatly.

I manually instrumented the code paths in shortcircuitPhiPlan.
During make.bash there are nearly 6000 invocations.
The least-visited code path gets run 85 times,
so all the code in this CL is reasonably well-exercised.

Here is a concrete example of code improved by this change:

func f(e interface{}) int {
if x, ok := e.(int); ok {
return x
}
return 0
}

Omitting PCDATA, FUNCDATA, and the like, it used to compile to:

"".f STEXT nosplit size=50 args=0x18 locals=0x0
0x0000 00000 (x.go:4) LEAQ type.int(SB), AX
0x0007 00007 (x.go:4) MOVQ "".e+8(SP), CX
0x000c 00012 (x.go:4) CMPQ AX, CX
0x000f 00015 (x.go:4) JNE 43
0x0011 00017 (x.go:4) MOVQ "".e+16(SP), AX
0x0016 00022 (x.go:4) MOVQ (AX), AX
0x0019 00025 (x.go:4) JNE 33
0x001b 00027 (x.go:5) MOVQ AX, "".~r1+24(SP)
0x0020 00032 (x.go:5) RET
0x0021 00033 (x.go:7) MOVQ $0, "".~r1+24(SP)
0x002a 00042 (x.go:7) RET
0x002b 00043 (x.go:7) MOVL $0, AX
0x0030 00048 (x.go:4) JMP 25

Afterwards, it compiles to:

"".f STEXT nosplit size=41 args=0x18 locals=0x0
0x0000 00000 (x.go:4) LEAQ type.int(SB), AX
0x0007 00007 (x.go:4) MOVQ "".e+8(SP), CX
0x000c 00012 (x.go:4) CMPQ AX, CX
0x000f 00015 (x.go:4) JNE 31
0x0011 00017 (x.go:4) MOVQ "".e+16(SP), AX
0x0016 00022 (x.go:4) MOVQ (AX), AX
0x0019 00025 (x.go:5) MOVQ AX, "".~r1+24(SP)
0x001e 00030 (x.go:5) RET
0x001f 00031 (x.go:7) MOVQ $0, "".~r1+24(SP)
0x0028 00040 (x.go:7) RET

Note that there is now only a single JNE and a single RET $0 path.

Updates #37608

Has a minor good effect on compilation speed and memory use.

Provides widespread improvements to generated code.
The rare, minor regressions I have investigated are due to
register allocation fluctuations.

file      before    after     Δ       %
addr2line 4376080   4371984   -4096   -0.094%
api       5945400   5933112   -12288  -0.207%
asm       5034312   5030216   -4096   -0.081%
buildid   2844952   2840856   -4096   -0.144%
cgo       4812872   4804680   -8192   -0.170%
compile   19622064  19610368  -11696  -0.060%
cover     5236648   5232552   -4096   -0.078%
dist      3658312   3654216   -4096   -0.112%
doc       4653512   4649416   -4096   -0.088%
fix       3370072   3365976   -4096   -0.122%
link      6671864   6667768   -4096   -0.061%
pprof     14781652  14761172  -20480  -0.139%
trace     11639684  11627396  -12288  -0.106%
vet       8252280   8231800   -20480  -0.248%
total     115052984 114934792 -118192 -0.103%

file                                                                     before   after    Δ       %
internal/cpu.s                                                           3298     3296     -2      -0.061%
internal/bytealg.s                                                       1730     1737     +7      +0.405%
cmd/vendor/golang.org/x/mod/semver.s                                     7332     7283     -49     -0.668%
image/color.s                                                            8248     8156     -92     -1.115%
math.s                                                                   35966    35956    -10     -0.028%
math/cmplx.s                                                             6596     6575     -21     -0.318%
runtime.s                                                                480566   480053   -513    -0.107%
sync.s                                                                   16408    16385    -23     -0.140%
math/rand.s                                                              10447    10406    -41     -0.392%
internal/reflectlite.s                                                   28408    28366    -42     -0.148%
errors.s                                                                 2736     2701     -35     -1.279%
sort.s                                                                   17031    17036    +5      +0.029%
io.s                                                                     16993    16964    -29     -0.171%
container/heap.s                                                         2006     1997     -9      -0.449%
text/tabwriter.s                                                         9570     9552     -18     -0.188%
bytes.s                                                                  31823    31594    -229    -0.720%
strconv.s                                                                52760    52717    -43     -0.082%
vendor/golang.org/x/text/transform.s                                     16713    16706    -7      -0.042%
strings.s                                                                42590    42563    -27     -0.063%
bufio.s                                                                  22883    22785    -98     -0.428%
encoding/base32.s                                                        9586     9531     -55     -0.574%
syscall.s                                                                82237    82243    +6      +0.007%
image.s                                                                  37465    37452    -13     -0.035%
regexp/syntax.s                                                          82827    82769    -58     -0.070%
image/draw.s                                                             18698    18584    -114    -0.610%
image/jpeg.s                                                             36560    36549    -11     -0.030%
time.s                                                                   82557    82526    -31     -0.038%
context.s                                                                10863    10820    -43     -0.396%
regexp.s                                                                 64114    64049    -65     -0.101%
os.s                                                                     51751    51524    -227    -0.439%
reflect.s                                                                168240   168049   -191    -0.114%
cmd/go/internal/lockedfile/internal/filelock.s                           2317     2290     -27     -1.165%
path/filepath.s                                                          17831    17766    -65     -0.365%
io/ioutil.s                                                              6994     6990     -4      -0.057%
encoding/binary.s                                                        30791    30726    -65     -0.211%
cmd/vendor/golang.org/x/sys/unix.s                                       78055    78033    -22     -0.028%
encoding/pem.s                                                           9280     9247     -33     -0.356%
crypto/cipher.s                                                          20376    20374    -2      -0.010%
os/exec.s                                                                29229    29140    -89     -0.304%
internal/goroot.s                                                        4588     4579     -9      -0.196%
cmd/internal/browser.s                                                   2246     2240     -6      -0.267%
cmd/vendor/golang.org/x/crypto/ssh/terminal.s                            27183    27149    -34     -0.125%
fmt.s                                                                    76625    76484    -141    -0.184%
encoding/hex.s                                                           6154     6152     -2      -0.032%
compress/lzw.s                                                           7063     7059     -4      -0.057%
database/sql/driver.s                                                    18875    18862    -13     -0.069%
debug/plan9obj.s                                                         8268     8266     -2      -0.024%
net/url.s                                                                29724    29719    -5      -0.017%
encoding/csv.s                                                           12872    12856    -16     -0.124%
debug/gosym.s                                                            25303    25268    -35     -0.138%
compress/flate.s                                                         50952    51019    +67     +0.131%
compress/zlib.s                                                          7277     7266     -11     -0.151%
archive/zip.s                                                            42155    42111    -44     -0.104%
debug/dwarf.s                                                            107632   107541   -91     -0.085%
database/sql.s                                                           98373    98028    -345    -0.351%
os/user.s                                                                14722    14708    -14     -0.095%
encoding/json.s                                                          105836   105711   -125    -0.118%
debug/macho.s                                                            32598    32560    -38     -0.117%
encoding/gob.s                                                           136478   135755   -723    -0.530%
debug/pe.s                                                               31160    30869    -291    -0.934%
debug/elf.s                                                              63495    63302    -193    -0.304%
vendor/golang.org/x/text/unicode/bidi.s                                  27220    27217    -3      -0.011%
vendor/golang.org/x/text/secure/bidirule.s                               3363     3352     -11     -0.327%
go/token.s                                                               12036    12035    -1      -0.008%
flag.s                                                                   22277    22256    -21     -0.094%
mime.s                                                                   39696    39509    -187    -0.471%
go/scanner.s                                                             19033    19020    -13     -0.068%
archive/tar.s                                                            70936    70581    -355    -0.500%
internal/xcoff.s                                                         22823    22820    -3      -0.013%
text/scanner.s                                                           11631    11629    -2      -0.017%
encoding/xml.s                                                           110534   110408   -126    -0.114%
math/big.s                                                               183636   183545   -91     -0.050%
image/gif.s                                                              27376    27343    -33     -0.121%
crypto/dsa.s                                                             6029     5969     -60     -0.995%
image/png.s                                                              42947    42939    -8      -0.019%
crypto/rand.s                                                            6866     6854     -12     -0.175%
vendor/golang.org/x/text/unicode/norm.s                                  66394    66354    -40     -0.060%
runtime/trace.s                                                          2603     2521     -82     -3.150%
crypto/ed25519.s                                                         6321     6300     -21     -0.332%
text/template/parse.s                                                    93910    93844    -66     -0.070%
crypto/rsa.s                                                             31460    31369    -91     -0.289%
encoding/asn1.s                                                          57021    57023    +2      +0.004%
crypto/elliptic.s                                                        51382    51363    -19     -0.037%
crypto/x509/pkix.s                                                       10386    10342    -44     -0.424%
vendor/golang.org/x/net/idna.s                                           24482    24466    -16     -0.065%
vendor/golang.org/x/crypto/cryptobyte.s                                  33479    33280    -199    -0.594%
crypto/ecdsa.s                                                           11936    11883    -53     -0.444%
go/constant.s                                                            43670    42663    -1007   -2.306%
go/ast.s                                                                 80383    80191    -192    -0.239%
testing.s                                                                68069    68057    -12     -0.018%
runtime/pprof.s                                                          59613    59603    -10     -0.017%
testing/iotest.s                                                         4895     4891     -4      -0.082%
internal/trace.s                                                         78136    78089    -47     -0.060%
cmd/internal/goobj2.s                                                    13158    13154    -4      -0.030%
cmd/internal/src.s                                                       17661    17657    -4      -0.023%
go/parser.s                                                              79046    78880    -166    -0.210%
cmd/internal/objabi.s                                                    16367    16343    -24     -0.147%
text/template.s                                                          94899    94486    -413    -0.435%
go/printer.s                                                             77267    76992    -275    -0.356%
cmd/internal/goobj.s                                                     25988    25947    -41     -0.158%
runtime/pprof/internal/profile.s                                         102066   101933   -133    -0.130%
go/format.s                                                              5419     5371     -48     -0.886%
cmd/vendor/golang.org/x/arch/ppc64/ppc64asm.s                            37181    37149    -32     -0.086%
go/doc.s                                                                 74533    74132    -401    -0.538%
html/template.s                                                          88743    88389    -354    -0.399%
cmd/asm/internal/lex.s                                                   24881    24872    -9      -0.036%
cmd/internal/buildid.s                                                   18263    18256    -7      -0.038%
cmd/vendor/golang.org/x/arch/x86/x86asm.s                                80036    79980    -56     -0.070%
go/build.s                                                               68905    68737    -168    -0.244%
cmd/cover.s                                                              46070    45950    -120    -0.260%
cmd/internal/obj.s                                                       117001   116991   -10     -0.009%
cmd/doc.s                                                                62700    62419    -281    -0.448%
cmd/internal/obj/arm.s                                                   66745    66687    -58     -0.087%
cmd/compile/internal/syntax.s                                            145406   145062   -344    -0.237%
cmd/internal/obj/wasm.s                                                  44049    44027    -22     -0.050%
net.s                                                                    291835   291020   -815    -0.279%
cmd/dist.s                                                               209020   208807   -213    -0.102%
cmd/cgo.s                                                                241564   241102   -462    -0.191%
vendor/golang.org/x/net/http/httpproxy.s                                 9407     9399     -8      -0.085%
log/syslog.s                                                             7921     7909     -12     -0.151%
go/types.s                                                               319325   317513   -1812   -0.567%
vendor/golang.org/x/net/http/httpguts.s                                  3834     3825     -9      -0.235%
mime/multipart.s                                                         21414    21343    -71     -0.332%
cmd/internal/obj/ppc64.s                                                 119949   119938   -11     -0.009%
cmd/compile/internal/logopt.s                                            10158    10118    -40     -0.394%
vendor/golang.org/x/net/nettest.s                                        28012    27991    -21     -0.075%
go/internal/srcimporter.s                                                6405     6380     -25     -0.390%
go/internal/gcimporter.s                                                 34525    34493    -32     -0.093%
net/mail.s                                                               23937    23720    -217    -0.907%
go/internal/gccgoimporter.s                                              56095    56038    -57     -0.102%
cmd/compile/internal/types.s                                             47247    47207    -40     -0.085%
cmd/api.s                                                                39582    39558    -24     -0.061%
cmd/go/internal/base.s                                                   12572    12551    -21     -0.167%
cmd/vendor/golang.org/x/xerrors.s                                        17846    17814    -32     -0.179%
cmd/vendor/golang.org/x/mod/sumdb/note.s                                 18142    18070    -72     -0.397%
cmd/go/internal/search.s                                                 19994    19876    -118    -0.590%
cmd/go/internal/imports.s                                                16457    16428    -29     -0.176%
cmd/vendor/golang.org/x/mod/module.s                                     17838    17759    -79     -0.443%
cmd/go/internal/cache.s                                                  30551    30514    -37     -0.121%
cmd/vendor/golang.org/x/mod/sumdb/tlog.s                                 36356    36321    -35     -0.096%
cmd/internal/test2json.s                                                 9452     9408     -44     -0.466%
cmd/go/internal/mvs.s                                                    25136    25092    -44     -0.175%
cmd/go/internal/txtar.s                                                  3488     3461     -27     -0.774%
cmd/vendor/golang.org/x/mod/zip.s                                        18811    18800    -11     -0.058%
cmd/go/internal/version.s                                                11213    11171    -42     -0.375%
cmd/link/internal/benchmark.s                                            4941     4949     +8      +0.162%
cmd/internal/obj/s390x.s                                                 126865   126849   -16     -0.013%
cmd/gofmt.s                                                              30684    30596    -88     -0.287%
cmd/fix.s                                                                87450    86906    -544    -0.622%
cmd/internal/obj/x86.s                                                   88578    88556    -22     -0.025%
cmd/vendor/golang.org/x/mod/modfile.s                                    72450    72363    -87     -0.120%
cmd/oldlink/internal/loader.s                                            16743    16741    -2      -0.012%
cmd/pack.s                                                               14863    14861    -2      -0.013%
cmd/go/internal/load.s                                                   106742   106568   -174    -0.163%
cmd/oldlink/internal/objfile.s                                           21787    21780    -7      -0.032%
cmd/oldlink/internal/loadmacho.s                                         29309    29317    +8      +0.027%
cmd/oldlink/internal/loadelf.s                                           35013    35021    +8      +0.023%
cmd/asm/internal/asm.s                                                   68550    68538    -12     -0.018%
cmd/link/internal/loader.s                                               94765    94564    -201    -0.212%
cmd/link/internal/loadelf.s                                              35663    35667    +4      +0.011%
cmd/link/internal/loadmacho.s                                            29501    29509    +8      +0.027%
cmd/vendor/golang.org/x/tools/go/analysis.s                              4983     4976     -7      -0.140%
cmd/vendor/golang.org/x/tools/go/analysis/internal/analysisflags.s       16771    16709    -62     -0.370%
cmd/vendor/golang.org/x/tools/go/types/objectpath.s                      18481    18456    -25     -0.135%
cmd/vendor/golang.org/x/tools/go/analysis/passes/internal/analysisutil.s 2100     2085     -15     -0.714%
cmd/vendor/github.com/google/pprof/profile.s                             150141   149620   -521    -0.347%
cmd/vendor/github.com/google/pprof/internal/measurement.s                10420    10404    -16     -0.154%
cmd/vendor/golang.org/x/tools/go/analysis/passes/asmdecl.s               36814    36755    -59     -0.160%
cmd/vendor/golang.org/x/tools/go/analysis/passes/bools.s                 6688     6673     -15     -0.224%
cmd/vendor/golang.org/x/tools/go/analysis/passes/cgocall.s               9856     9784     -72     -0.731%
cmd/vendor/golang.org/x/tools/go/analysis/passes/composite.s             3011     2979     -32     -1.063%
cmd/vendor/golang.org/x/tools/go/analysis/passes/copylock.s              9737     9682     -55     -0.565%
cmd/vendor/golang.org/x/tools/go/cfg.s                                   30738    30725    -13     -0.042%
cmd/vendor/github.com/ianlancetaylor/demangle.s                          175195   174513   -682    -0.389%
cmd/vendor/golang.org/x/tools/go/analysis/passes/httpresponse.s          3625     3520     -105    -2.897%
cmd/vendor/golang.org/x/tools/go/analysis/passes/loopclosure.s           2987     2971     -16     -0.536%
cmd/vendor/golang.org/x/tools/go/analysis/passes/shift.s                 4372     4340     -32     -0.732%
cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods.s            8634     8611     -23     -0.266%
cmd/vendor/golang.org/x/tools/go/analysis/passes/tests.s                 6189     6164     -25     -0.404%
cmd/vendor/golang.org/x/tools/go/analysis/passes/structtag.s             8089     8073     -16     -0.198%
cmd/vendor/golang.org/x/tools/go/analysis/passes/unsafeptr.s             2208     2177     -31     -1.404%
cmd/vendor/golang.org/x/tools/go/analysis/passes/unreachable.s           8050     8047     -3      -0.037%
cmd/vendor/golang.org/x/tools/go/analysis/passes/unusedresult.s          3665     3629     -36     -0.982%
cmd/vendor/golang.org/x/tools/go/ast/astutil.s                           65773    65680    -93     -0.141%
cmd/vendor/golang.org/x/tools/go/analysis/unitchecker.s                  13328    13286    -42     -0.315%
cmd/vendor/golang.org/x/tools/go/types/typeutil.s                        12263    12162    -101    -0.824%
cmd/vendor/golang.org/x/tools/go/analysis/passes/errorsas.s              1459     1421     -38     -2.605%
cmd/vendor/golang.org/x/tools/go/analysis/passes/ctrlflow.s              5208     5191     -17     -0.326%
cmd/vendor/golang.org/x/tools/go/analysis/passes/unmarshal.s             1801     1782     -19     -1.055%
cmd/vendor/golang.org/x/tools/go/analysis/passes/lostcancel.s            9569     9528     -41     -0.428%
cmd/go/internal/work.s                                                   304928   304756   -172    -0.056%
crypto/x509.s                                                            147340   147139   -201    -0.136%
cmd/vendor/golang.org/x/tools/go/analysis/passes/printf.s                34287    34019    -268    -0.782%
crypto/tls.s                                                             311603   310644   -959    -0.308%
cmd/oldlink/internal/ld.s                                                533115   532651   -464    -0.087%
cmd/oldlink/internal/wasm.s                                              16484    16458    -26     -0.158%
cmd/oldlink/internal/x86.s                                               18832    18830    -2      -0.011%
cmd/link/internal/ld.s                                                   548200   547626   -574    -0.105%
cmd/link/internal/wasm.s                                                 16760    16734    -26     -0.155%
cmd/link/internal/arm64.s                                                20850    20840    -10     -0.048%
cmd/link/internal/x86.s                                                  17437    17435    -2      -0.011%
net/http.s                                                               556647   555519   -1128   -0.203%
net/http/cookiejar.s                                                     15849    15833    -16     -0.101%
expvar.s                                                                 9521     9508     -13     -0.137%
net/http/httptest.s                                                      16471    16452    -19     -0.115%
cmd/vendor/github.com/google/pprof/internal/plugin.s                     4266     4264     -2      -0.047%
net/http/cgi.s                                                           23448    23428    -20     -0.085%
cmd/go/internal/web.s                                                    16472    16428    -44     -0.267%
net/http/httputil.s                                                      39672    39670    -2      -0.005%
net/rpc.s                                                                33989    33965    -24     -0.071%
net/http/fcgi.s                                                          19167    19162    -5      -0.026%
cmd/vendor/github.com/google/pprof/internal/symbolz.s                    5861     5857     -4      -0.068%
cmd/vendor/github.com/google/pprof/internal/binutils.s                   35842    35823    -19     -0.053%
cmd/vendor/github.com/google/pprof/internal/symbolizer.s                 11449    11404    -45     -0.393%
cmd/go/internal/get.s                                                    62726    62582    -144    -0.230%
cmd/vendor/github.com/google/pprof/internal/report.s                     80032    80022    -10     -0.012%
cmd/go/internal/modfetch/codehost.s                                      89005    88871    -134    -0.151%
cmd/trace.s                                                              116607   116496   -111    -0.095%
cmd/vendor/github.com/google/pprof/internal/driver.s                     143234   143207   -27     -0.019%
cmd/vendor/github.com/google/pprof/driver.s                              9000     8998     -2      -0.022%
cmd/go/internal/modfetch.s                                               126300   125726   -574    -0.454%
cmd/pprof.s                                                              12317    12312    -5      -0.041%
cmd/go/internal/modconv.s                                                17878    17861    -17     -0.095%
cmd/go/internal/modload.s                                                150261   149763   -498    -0.331%
cmd/go/internal/clean.s                                                  11122    11091    -31     -0.279%
cmd/go/internal/help.s                                                   6523     6521     -2      -0.031%
cmd/go/internal/generate.s                                               11627    11614    -13     -0.112%
cmd/go/internal/envcmd.s                                                 22034    21986    -48     -0.218%
cmd/go/internal/modget.s                                                 38478    38398    -80     -0.208%
cmd/go/internal/modcmd.s                                                 46430    46229    -201    -0.433%
cmd/go/internal/test.s                                                   64399    64374    -25     -0.039%
cmd/compile/internal/ssa.s                                               3615264  3608276  -6988   -0.193%
cmd/compile/internal/gc.s                                                1538865  1537625  -1240   -0.081%
cmd/compile/internal/amd64.s                                             33593    33574    -19     -0.057%
cmd/compile/internal/x86.s                                               30871    30852    -19     -0.062%
total                                                                    19343565 19311284 -32281  -0.167%

Change-Id: Ib030eb79458827a5a5b6d0d2f98765f8325a4d7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/222923
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agoruntime: simplify typedmemmovepartial
Ian Lance Taylor [Wed, 8 Apr 2020 04:39:39 +0000 (21:39 -0700)]
runtime: simplify typedmemmovepartial

The offset is always a multiple of the pointer size.

Change-Id: I790e087e89a081044a3ec35d99880533a4c929bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/227540
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
5 years agoos/signal: increase settle time in tests
Bryan C. Mills [Wed, 8 Apr 2020 20:28:33 +0000 (16:28 -0400)]
os/signal: increase settle time in tests

I noticed a timeout in TestIgnore in
https://build.golang.org/log/52d83a72f3a5ea9a16eb5d670c729694144f9624,
which suggests that the settle time is currently set too low.

I've also added a check for the same GO_TEST_TIMEOUT_SCALE used in
TestTerminalSignal, so that if this builder remains too slow we can
increase the builder's scale factor rather than the test's baseline
running time.

Updates #33174

Change-Id: I18b10eaa3bb5ae2f604300aedaaf6f79ee7ad567
Reviewed-on: https://go-review.googlesource.com/c/go/+/227649
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoos/exec: use subprocess deadline in TestExtraFiles
Ian Lance Taylor [Tue, 7 Apr 2020 23:39:42 +0000 (16:39 -0700)]
os/exec: use subprocess deadline in TestExtraFiles

Try to get some output even if the subprocess hangs.

For #25628

Change-Id: I4cc0a8f2c52b03a322b8fd0a620cba37b06ff10a
Reviewed-on: https://go-review.googlesource.com/c/go/+/227517
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agonet/url: add URL.Redacted to return a password scrubbed string
nrxr [Wed, 8 Apr 2020 10:21:40 +0000 (10:21 +0000)]
net/url: add URL.Redacted to return a password scrubbed string

Returning an URL.String() without the password is very useful for
situations where the URL is supposed to be logged and the password is
not useful to be shown.

This method re-uses URL.String() but with the password scrubbed and
substituted for a "xxxxx" in order to make it obvious that there was a
password. If the URL had no password then no "xxxxx" will be shown.

Fixes #34855

Change-Id: I7f17d81aa09a7963d2731d16fe15c6ae8e2285fc
GitHub-Last-Rev: 46d06dbc4f9e30a57667bb8d0627bc1abed83bdc
GitHub-Pull-Request: golang/go#35578
Reviewed-on: https://go-review.googlesource.com/c/go/+/207082
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
5 years agocmd/compile: allow floating point Ops to produce flags on s390x
Ruixin(Peter) Bao [Thu, 21 Nov 2019 15:44:23 +0000 (10:44 -0500)]
cmd/compile: allow floating point Ops to produce flags on s390x

On s390x, some floating point arithmetic instructions (FSUB, FADD)  generate flag.
This patch allows those related SSA ops to return a tuple, where the second argument of
the tuple is the generated flag. We can use the flag and remove the
subsequent comparison instruction (e.g: LTDBR).

This CL also reduces the .text section for math.test binary by 0.4KB.

Benchmarks:
name                    old time/op  new time/op  delta
Acos-18                 12.1ns ± 0%  12.1ns ± 0%     ~     (all equal)
Acosh-18                18.5ns ± 0%  18.5ns ± 0%     ~     (all equal)
Asin-18                 13.1ns ± 0%  13.1ns ± 0%     ~     (all equal)
Asinh-18                19.4ns ± 0%  19.5ns ± 1%     ~     (p=0.444 n=5+5)
Atan-18                 10.0ns ± 0%  10.0ns ± 0%     ~     (all equal)
Atanh-18                19.1ns ± 1%  19.2ns ± 2%     ~     (p=0.841 n=5+5)
Atan2-18                16.4ns ± 0%  16.4ns ± 0%     ~     (all equal)
Cbrt-18                 14.8ns ± 0%  14.8ns ± 0%     ~     (all equal)
Ceil-18                 0.78ns ± 0%  0.78ns ± 0%     ~     (all equal)
Copysign-18             0.80ns ± 0%  0.80ns ± 0%     ~     (all equal)
Cos-18                  7.19ns ± 0%  7.19ns ± 0%     ~     (p=0.556 n=4+5)
Cosh-18                 12.4ns ± 0%  12.4ns ± 0%     ~     (all equal)
Erf-18                  10.8ns ± 0%  10.8ns ± 0%     ~     (all equal)
Erfc-18                 11.0ns ± 0%  11.0ns ± 0%     ~     (all equal)
Erfinv-18               23.0ns ±16%  26.8ns ± 1%  +16.90%  (p=0.008 n=5+5)
Erfcinv-18              23.3ns ±15%  26.1ns ± 7%     ~     (p=0.087 n=5+5)
Exp-18                  8.67ns ± 0%  8.67ns ± 0%     ~     (p=1.000 n=4+4)
ExpGo-18                50.8ns ± 3%  52.4ns ± 2%     ~     (p=0.063 n=5+5)
Expm1-18                9.49ns ± 1%  9.47ns ± 0%     ~     (p=1.000 n=5+5)
Exp2-18                 52.7ns ± 1%  50.5ns ± 3%   -4.10%  (p=0.024 n=5+5)
Exp2Go-18               50.6ns ± 1%  48.4ns ± 3%   -4.39%  (p=0.008 n=5+5)
Abs-18                  0.67ns ± 0%  0.67ns ± 0%     ~     (p=0.444 n=5+5)
Dim-18                  1.02ns ± 0%  1.03ns ± 0%   +0.98%  (p=0.008 n=5+5)
Floor-18                0.78ns ± 0%  0.78ns ± 0%     ~     (all equal)
Max-18                  3.09ns ± 1%  3.05ns ± 0%   -1.42%  (p=0.008 n=5+5)
Min-18                  3.32ns ± 1%  3.30ns ± 0%   -0.72%  (p=0.016 n=5+4)
Mod-18                  62.3ns ± 1%  65.8ns ± 3%   +5.55%  (p=0.008 n=5+5)
Frexp-18                5.05ns ± 2%  4.98ns ± 0%     ~     (p=0.683 n=5+5)
Gamma-18                24.4ns ± 0%  24.1ns ± 0%   -1.23%  (p=0.008 n=5+5)
Hypot-18                10.3ns ± 0%  10.3ns ± 0%     ~     (all equal)
HypotGo-18              10.2ns ± 0%  10.2ns ± 0%     ~     (all equal)
Ilogb-18                3.56ns ± 1%  3.54ns ± 0%     ~     (p=0.595 n=5+5)
J0-18                    113ns ± 0%   108ns ± 1%   -4.42%  (p=0.016 n=4+5)
J1-18                    115ns ± 0%   109ns ± 1%   -4.87%  (p=0.016 n=4+5)
Jn-18                    240ns ± 0%   230ns ± 2%   -4.41%  (p=0.008 n=5+5)
Ldexp-18                6.19ns ± 0%  6.19ns ± 0%     ~     (p=0.444 n=5+5)
Lgamma-18               32.2ns ± 0%  32.2ns ± 0%     ~     (all equal)
Log-18                  13.1ns ± 0%  13.1ns ± 0%     ~     (all equal)
Logb-18                 4.23ns ± 0%  4.22ns ± 0%     ~     (p=0.444 n=5+5)
Log1p-18                12.7ns ± 0%  12.7ns ± 0%     ~     (all equal)
Log10-18                18.1ns ± 0%  18.2ns ± 0%     ~     (p=0.167 n=5+5)
Log2-18                 14.0ns ± 0%  14.0ns ± 0%     ~     (all equal)
Modf-18                 10.4ns ± 0%  10.5ns ± 0%   +0.96%  (p=0.016 n=4+5)
Nextafter32-18          11.3ns ± 0%  11.3ns ± 0%     ~     (all equal)
Nextafter64-18          4.01ns ± 1%  3.97ns ± 0%     ~     (p=0.333 n=5+4)
PowInt-18               32.7ns ± 0%  32.7ns ± 0%     ~     (all equal)
PowFrac-18              33.2ns ± 0%  33.1ns ± 0%     ~     (p=0.095 n=4+5)
Pow10Pos-18             1.58ns ± 0%  1.58ns ± 0%     ~     (all equal)
Pow10Neg-18             5.81ns ± 0%  5.81ns ± 0%     ~     (all equal)
Round-18                0.78ns ± 0%  0.78ns ± 0%     ~     (all equal)
RoundToEven-18          0.78ns ± 0%  0.78ns ± 0%     ~     (all equal)
Remainder-18            40.6ns ± 0%  40.7ns ± 0%     ~     (p=0.238 n=5+4)
Signbit-18              1.57ns ± 0%  1.57ns ± 0%     ~     (all equal)
Sin-18                  6.75ns ± 0%  6.74ns ± 0%     ~     (p=0.333 n=5+4)
Sincos-18               29.5ns ± 0%  29.5ns ± 0%     ~     (all equal)
Sinh-18                 14.4ns ± 0%  14.4ns ± 0%     ~     (all equal)
SqrtIndirect-18         3.97ns ± 0%  4.15ns ± 0%   +4.59%  (p=0.008 n=5+5)
SqrtLatency-18          8.01ns ± 0%  8.01ns ± 0%     ~     (all equal)
SqrtIndirectLatency-18  11.6ns ± 0%  11.6ns ± 0%     ~     (all equal)
SqrtGoLatency-18        44.7ns ± 0%  45.0ns ± 0%   +0.67%  (p=0.008 n=5+5)
SqrtPrime-18            1.26µs ± 0%  1.27µs ± 0%   +0.63%  (p=0.029 n=4+4)
Tan-18                  11.1ns ± 0%  11.1ns ± 0%     ~     (all equal)
Tanh-18                 15.8ns ± 0%  15.8ns ± 0%     ~     (all equal)
Trunc-18                0.78ns ± 0%  0.78ns ± 0%     ~     (all equal)
Y0-18                    113ns ± 2%   108ns ± 3%   -5.11%  (p=0.008 n=5+5)
Y1-18                    112ns ± 3%   107ns ± 0%   -4.29%  (p=0.000 n=5+4)
Yn-18                    229ns ± 0%   220ns ± 1%   -3.76%  (p=0.016 n=4+5)
Float64bits-18          1.09ns ± 0%  1.09ns ± 0%     ~     (all equal)
Float64frombits-18      0.55ns ± 0%  0.55ns ± 0%     ~     (all equal)
Float32bits-18          0.96ns ±16%  0.86ns ± 0%     ~     (p=0.563 n=5+5)
Float32frombits-18      1.03ns ±28%  0.84ns ± 0%     ~     (p=0.167 n=5+5)
FMA-18                  1.60ns ± 0%  1.60ns ± 0%     ~     (all equal)
[Geo mean]              10.0ns        9.9ns        -0.41%
Change-Id: Ief7e63ea5a8ba404b0a4696e12b9b7e0b05a9a03
Reviewed-on: https://go-review.googlesource.com/c/go/+/209160
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/compile: simplify s390x 'operation with memory operand' rules
Michael Munday [Mon, 6 Apr 2020 22:42:55 +0000 (23:42 +0100)]
cmd/compile: simplify s390x 'operation with memory operand' rules

The generated code remains exactly the same.

Change-Id: Id70af46b6c3c18153789961e5589eab717c3316e
Reviewed-on: https://go-review.googlesource.com/c/go/+/227164
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agomath/big: correct off-by-one access in divBasic
Rémy Oudompheng [Thu, 5 Mar 2020 06:59:00 +0000 (07:59 +0100)]
math/big: correct off-by-one access in divBasic

The divBasic function computes the quotient of big nats u/v word by word.
It estimates each word qhat by performing a long division (top 2 words of u
divided by top word of v), looks at the next word to correct the estimate,
then perform a full multiplication (qhat*v) to catch any inaccuracy in the
estimate.

In the latter case, "negative" values appear temporarily and carries
must be carefully managed, and the recursive division refactoring
introduced a case where qhat*v has the same length as v, triggering an
out-of-bounds write in the case it happens when computing the top word
of the quotient.

Fixes #37499

Change-Id: I15089da4a4027beda43af497bf6de261eb792f94
Reviewed-on: https://go-review.googlesource.com/c/go/+/221980
Reviewed-by: Robert Griesemer <gri@golang.org>