summaryrefslogtreecommitdiff
path: root/src/cmd
Commit message (Collapse)AuthorAgeFilesLines
* all: update vendored x dependencies for Go 1.19 development cycleHeschi Kreinick2022-03-17101-3950/+2257
| | | | | | | | | | | | | | Generated with x/build/cmd/updatestd. Updates #36905. Change-Id: I5d12dfc3b49c1476ce4b8d4cbeb35bd3d3443d26 Reviewed-on: https://go-review.googlesource.com/c/go/+/393369 Trust: Heschi Kreinick <heschi@google.com> Run-TryBot: Heschi Kreinick <heschi@google.com> Auto-Submit: Heschi Kreinick <heschi@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/doc: use the 'go' command from buildCtx.GOROOT, not whatever is in $PATHBryan C. Mills2022-03-172-4/+42
| | | | | | | | | | | For #51483. Change-Id: I6150fdf97763d858e9ab012e807515da3387c25f Reviewed-on: https://go-review.googlesource.com/c/go/+/393366 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/doc: use 'go env' to identify GOROOT if it isn't otherwise knownBryan C. Mills2022-03-172-5/+20
| | | | | | | | | | | Updates #51483. Change-Id: I13d8e58b30639d8a5ed3c9e8b72c8bbaa6a6f1cc Reviewed-on: https://go-review.googlesource.com/c/go/+/391813 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/compile: set conversions to unsafe.Pointer as an escaping operation when ↵fanzha022022-03-172-3/+9
| | | | | | | | | | | | | | | | | | | | | | -asan is enabled When ASan is enabled, treat conversions to unsafe.Pointer as an escaping operation. In this way, all pointer operations on the stack objects will become operations on the escaped heap objects. As we've already supported ASan detection of error memory accesses to heap objects. With this trick, we can use -asan option to report errors on bad stack operations. Add test cases. Updates #44853. Change-Id: I6281e77f6ba581d7008d610f0b24316078b6e746 Reviewed-on: https://go-review.googlesource.com/c/go/+/393315 Trust: Fannie Zhang <Fannie.Zhang@arm.com> Run-TryBot: Fannie Zhang <Fannie.Zhang@arm.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Eric Fang <eric.fang@arm.com>
* Revert "cmd/compile: set conversions to unsafe.Pointer as an escaping ↵Fannie Zhang2022-03-172-9/+3
| | | | | | | | | | | | | operation when -asan is enabled" This reverts commit 5fd0ed7aaf39f783ea6f505a3f2ac7d9da7cb03b. Reason for revert: <The internal information in commit message is not removed.> Change-Id: Id6845a9c8114ac71c56a1007a4d133a560a37fbc Reviewed-on: https://go-review.googlesource.com/c/go/+/393314 Trust: Fannie Zhang <Fannie.Zhang@arm.com> Reviewed-by: Eric Fang <eric.fang@arm.com>
* cmd/compile: remove typecheckdef and Name.WalkdefMatthew Dempsky2022-03-178-75/+9
| | | | | | | | | | | | | | | The only remaining use for typecheckdef after CL 393256 is to typecheck the ONAME node that represents function names, so we might as well just move that code into tcFunc instead. Updates #51691. Change-Id: Icbca51d4b0fb33c90faa95f16254c7171b171d8a Reviewed-on: https://go-review.googlesource.com/c/go/+/393367 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
* all: update vendored golang.org/x/toolsRobert Findley2022-03-1711-39/+396
| | | | | | | | | | | | | | | | | Update the vendored golang.org/x/tools to pick up the fix for #51717. This also picks up some changes to support Fuzz tests in the tests analyzer, but they are currently still guarded by an internal flag. Fixes #51717 Updates #36905 Change-Id: Ibcd5006624dd9cd9797c811093985e8775c57d51 Reviewed-on: https://go-review.googlesource.com/c/go/+/393373 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/compile: allow noop conversions when comparing expressionsKeith Randall2022-03-161-5/+6
| | | | | | | | | | | | | | Allows mapclear optimization to trigger in more cases, including some generic instantiations. Fixes #51699 Change-Id: Ic54f7686e5fcb8fbcad640aa77ed326d7338b938 Reviewed-on: https://go-review.googlesource.com/c/go/+/393434 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/api: remove debug printRuss Cox2022-03-161-1/+0
| | | | | | | | | | | Left over from CL 392414. Change-Id: I32ff1d660ba03d6c2005ad247e2129daf83aac04 Reviewed-on: https://go-review.googlesource.com/c/go/+/393361 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
* cmd/link: mark unexported methods for pluginsCherry Mui2022-03-161-1/+1
| | | | | | | | | | | | | | | | | When plugin is used, we already mark all exported methods reachable. However, when the plugin and the host program share a common package, an unexported method could also be reachable from both the plugin and the host via interfaces. We need to mark them as well. Fixes #51621. Change-Id: I1a70d3f96b66b803f2d0ab14d00ed0df276ea500 Reviewed-on: https://go-review.googlesource.com/c/go/+/393365 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
* cmd/compile: remove unused code from typecheckdefMatthew Dempsky2022-03-161-150/+6
| | | | | | | | | | | | | | | | | | | | | typecheckdef used to be used to handle references to package-level declarations that hadn't yet been typechecked yet. It's no longer needed, as the current IR frontends construct package-level declarations with proper types upfront. Exception: this code is still used for compiler-generated function declarations, so that code needs to be kept. Eventually that code can be moved elsewhere, but for now this CL makes it obvious that the rest of the code paths really are unused. Updates #51691. Change-Id: I5322edb686aaf5dc4627288f3d9ba910a017b41d Reviewed-on: https://go-review.googlesource.com/c/go/+/393256 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
* cmd/compile: remove OIOTAMatthew Dempsky2022-03-168-100/+53
| | | | | | | | | | | | | | | | | | OIOTA used to be used to represent "iota" in the pre-typechecked IR, before we knew whether it was safe to replace it with a constant (because it could be redefined as a global symbol later). However, now types2 handles constant folding, including handling of "iota". So this can go away. Updates #51691. Change-Id: I3cec45b22c4c8f1c357dcc4003292c21ae32aa90 Reviewed-on: https://go-review.googlesource.com/c/go/+/393255 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
* cmd/compile: Fatalf in Type.SetBroke(true) and Node.SetDiag(true)Matthew Dempsky2022-03-162-6/+5
| | | | | | | | | | | | | | | | Type.Broke and Node.Diag were used in the legacy typechecker to allow reporting of multiple errors in a compilation unit, while suppressing unhelpful follow-on errors. However, that's no longer needed now that types2 handles (most) user-visible diagnostics. Updates #51691. Change-Id: I919c1598d8acebe5703939256bdca3e8d021f7ad Reviewed-on: https://go-review.googlesource.com/c/go/+/392918 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
* cmd/compile: detect invalid NIH conversions within unified IRMatthew Dempsky2022-03-161-0/+14
| | | | | | | | | | | | | | | | | | | | Unified IR currently relies on typecheck to diagnose invalid //go:notinheap conversions, which prevents removing all of its (otherwise) dead error-reporting code. This CL updates the unified IR reader to instead proactively diagnose these invalid conversions. This logic can be removed again once #46731 is implemented, but in the mean time it allows progress on #51691. Updates #46731. Updates #51691. Change-Id: Ifae81aaad770209ec7a67bc10b55660f291e403e Reviewed-on: https://go-review.googlesource.com/c/go/+/392917 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
* internal/txtar: bring back to main repo, for tests in stdRuss Cox2022-03-168-151/+6
| | | | | | | | | | | | | | | | | | | | | | | | | This used to be cmd/go/internal/txtar, and then it was moved to golang.org/x/tools/txtar and revendored from there into cmd/vendor/golang.org/x/tools/txtar. We have a use for txtar in a new test in the standard library, which cannot access cmd/vendor. But we also don't really want to vendor it into the standard library as is, because that would be the first vendoring of x/tools in std, and it would be better to keep std separate from x/tools, even for testing. Instead, since a little copying is better than a little dependency, just make a copy in internal/txtar. The package does not change. Having done that, replace the uses in cmd/go so that there's only one copy in the main repo. Change-Id: I70b5cc05da3f6ebcc0fd9052ebcb3d369fb57956 Reviewed-on: https://go-review.googlesource.com/c/go/+/384254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/compile: set conversions to unsafe.Pointer as an escaping operation when ↵fanzha022022-03-162-3/+9
| | | | | | | | | | | | | | | | | | | | | -asan is enabled When ASan is enabled, treat conversions to unsafe.Pointer as an escaping operation. In this way, all pointer operations on the stack objects will become operations on the escaped heap objects. As we've already supported ASan detection of error memory accesses to heap objects. With this trick, we can use -asan option to report errors on bad stack operations. Add test cases. Updates #44853. CustomizedGitHooks: yes Change-Id: I4e7fe46a3ce01f0d219e6a67dc50f4aff7d2ad87 Reviewed-on: https://go-review.googlesource.com/c/go/+/325629 Trust: Fannie Zhang <Fannie.Zhang@arm.com> Reviewed-by: Keith Randall <khr@golang.org>
* cmd/link: default generic ABI compression for ELFMeng Zhuo2022-03-166-7/+41
| | | | | | | | | | | | | | | | This CL change all debug dwarf headers to generic ABI "Compression header" for ELF (http://www.sco.com/developers/gabi/latest/ch4.sheader.html#compression_header) Fixes #50796 Change-Id: I188625e596f11cd120dbd802ac2d79341d5eaf41 Reviewed-on: https://go-review.googlesource.com/c/go/+/380755 Trust: mzh <mzh@golangcn.org> Run-TryBot: mzh <mzh@golangcn.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* go/types, cmd/compile: remove unused Interface.obj fieldMatthew Dempsky2022-03-164-7/+3
| | | | | | | | | | Change-Id: I6d0f629f9c7379074a03c8f13b99924d872872a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/385996 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
* cmd/asm: support -d=pctab flagCherry Mui2022-03-152-0/+2
| | | | | | | | | | | To debug PC data generation. Change-Id: Id7ac8d607cc27ad52db490bd758c3a768c3e1df2 Reviewed-on: https://go-review.googlesource.com/c/go/+/388015 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: document that 'go run' strips debug infoIan Lance Taylor2022-03-152-0/+8
| | | | | | | | | Change-Id: Ie7293a33862853ac56ee0a9017b201d8ff0ba1f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/392574 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
* all: untab /* */ doc commentsRuss Cox2022-03-154-34/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | A long time ago, gofmt insisted on inserting tabs in /* */ comments at the top level of the file, like this: /* Package doc comment. */ package p Gofmt still insists on the tab for comments not at top level, but it has relaxed the rules about top-level comments. A few very old doc comments are indented, left over from the old rule. We are considering formatting doc comments, and so to make everything consistent, standardize on unindented doc comments by removing tabs in the few doc comments that are still indented this way. Also update some cmd/gofmt testdata to match. Change-Id: I293742e39b52f8a48ec41f72ca4acdafa7ce43bc Reviewed-on: https://go-review.googlesource.com/c/go/+/384261 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/compile: fix PrefetchStreamed builtin implementation on PPC64Archana R2022-03-152-4/+8
| | | | | | | | | | | | | | | | | This CL fixes encoding of PrefetchStreamed on PPC64 to be consistent with what is implemented on AMD64 and ARM64 platforms which is prefetchNTA (prefetch non-temporal access). Looking at the definition of prefetchNTA, the closest corresponding Touch hint (TH) value to be used on PPC64 is 16 that states that the address is accessed in a transient manner. Current usage of TH=8 may cause degraded performance. Change-Id: I393bf5a9b971a22f632b3cbfb4fa659062af9a27 Reviewed-on: https://go-review.googlesource.com/c/go/+/390316 Reviewed-by: Paul Murphy <murp@ibm.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/internal/obj/arm64: add TRN1 and TRN2 instructions supportfanzha022022-03-154-0/+16
| | | | | | | | | | | | | Add test cases. Fixes #51628 Change-Id: I433367d87e6bb5da5579c4be540079b92701c1fa Reviewed-on: https://go-review.googlesource.com/c/go/+/392294 Trust: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Trust: Fannie Zhang <Fannie.Zhang@arm.com>
* cmd/internal/obj/arm64: refactor the handling of shifted RSPeric fang2022-03-153-48/+35
| | | | | | | | | | | | | | | | | | | | | | | Some arithmetic operation instructions such as ADD and SUB support two formats of left shift (<<) operation, namely shifted register format and extended register format. And the encoding, supported registers and shifted amount are both different. The assembly parser doesn't distinguish them and parses them into TYPE_SHIFT type, because the parser can't tell them apart and in most cases extended left-shift can be replaced by shifted left-shift. The only exception is when the second source register or the destination register is RSP. This CL converts this case into the extended format in the preprocess stage, which helps to simplify some of the logic of the new assembler implementation and also makes this situation look more reasonable. Change-Id: I2cd7d2d663b38a7ba77a9fef1092708b8cb9bc3d Reviewed-on: https://go-review.googlesource.com/c/go/+/311709 Trust: Eric Fang <eric.fang@arm.com> Run-TryBot: Eric Fang <eric.fang@arm.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
* cmd/compile: disable rewrite loop detector for deadcode-only changesKeith Randall2022-03-151-3/+5
| | | | | | | | | | | | | | | | | | | | We're guaranteed we won't infinite loop on deadcode-only changes, because each change converts valid -> invalid, and there are only a finite number of valid values. The loops this test is looking for are those generated by rule applications, so it isn't useful to check for loops when rules aren't involved. Fixes #51639 Change-Id: Idf1abeab9d47baafddc3a1197d5064faaf07ef78 Reviewed-on: https://go-review.googlesource.com/c/go/+/392760 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Trust: Josh Bleecher Snyder <josharian@gmail.com>
* cmd/api: require proposal # for new API featuresRuss Cox2022-03-142-41/+83
| | | | | | | | | | | | | Having the proposal numbers recorded in the API files should help significantly when it comes time to audit the new API additions at the end of each release cycle. Change-Id: Id18e8cbdf892228a10ac17e4e21c7e17de5d4ff7 Reviewed-on: https://go-review.googlesource.com/c/go/+/392414 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* go/types, types2: use correct underlying type in union set computationRobert Griesemer2022-03-142-1/+40
| | | | | | | | | | Fixes #51658. Change-Id: Ibf415d7e12849b8f50b58d74713613d4e65bc347 Reviewed-on: https://go-review.googlesource.com/c/go/+/392575 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
* cmd/compile: fix wrong dict param when getting dict typeCuong Manh Le2022-03-141-1/+1
| | | | | | | | | | | | | | | | | CL 338129 added getDictionaryType to get the dictionary type from the specified dict param, but still using the one in info.dictParam, which is wrong. Fixes #51413 Change-Id: Ie13460c1e5751c4c5fc44479a44f6eed8b3b06e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/391994 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org>
* cmd/go: use testGOROOT in TestListTemplateContextFunctionBryan C. Mills2022-03-141-1/+1
| | | | | | | | | | | | | | | | | This test uses testgo to run 'go list', so it should use the correct GOROOT for testgo. (This may be particularly relevant when the test binary itself is build with -trimpath, in which case runtime.GOROOT() is not valid.) Updates #51483 Change-Id: I79b310f88e3a200122d6289073df1385e3e97cca Reviewed-on: https://go-review.googlesource.com/c/go/+/391801 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Trust: Daniel Martí <mvdan@mvdan.cc>
* cmd/compile: remove unified IR stmtTypeDeclHackCuong Manh Le2022-03-141-3/+0
| | | | | | | | | | | | After CL 385998, unified IR quirks mode was gone, it's time to remove stmtTypeDeclHack, too. Change-Id: Id73dd1d6c11b91c0c6c6cbe85f1b06977a9876d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/392214 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* cmd/asm: add support for bdnz/bdz extended mnemonics on PPC64Paul E. Murphy2022-03-115-25/+44
| | | | | | | | | | | | | | | Support BDNZ and BDZ mnemonics, they are commonly used POWER instructions. The raw BC mnemonic is not easy to read. Likewise, cleanup code surrounding these changes. Change-Id: I72f1dad5013f7856bd0dd320bfb17b5a9f3c69ee Reviewed-on: https://go-review.googlesource.com/c/go/+/390696 Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Trust: Paul Murphy <murp@ibm.com> Run-TryBot: Paul Murphy <murp@ibm.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/compile/internal/amd64: fix "missing objdump" skip in TestGoAMD64v1Bryan C. Mills2022-03-111-1/+5
| | | | | | | | | | | | The skip was erroneously applied to errors from the call to StdoutPipe instead of Start, and even then was a bit too broad. Change-Id: I417c9a74692383230fc6d99ebb4149fdc532533e Reviewed-on: https://go-review.googlesource.com/c/go/+/391800 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: use the correct gofmt binary in TestScript/fmt_load_errorsBryan C. Mills2022-03-111-4/+3
| | | | | | | | | | | Otherwise, this test may fail when GOROOT/bin is not in $PATH. Change-Id: Id744f365f6604716207184c9ea49436ab2e3a835 Reviewed-on: https://go-review.googlesource.com/c/go/+/391802 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/compile: fix re-export closureCuong Manh Le2022-03-112-0/+5
| | | | | | | | | | | | | | | | | | | For hidden closure built during stenciling to implement a function instantiation, the function may come from other package, not local package, which causes the ICE for code that re-export the hidden closure after inlining. To fix it, use the closure package for export writer when writing out the closure itself. Fixes #51423 Change-Id: I23b067ba14e2d602a0fc3b2e99bd9317afbe53ff Reviewed-on: https://go-review.googlesource.com/c/go/+/391574 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* internal/fuzz: minimization should not reduce coverageSteven Johnstone2022-03-101-11/+0
| | | | | | | | | | | | | | | | Minimization should result in a fuzz input which includes the same coverage bits as the original input. Updates #48326 Change-Id: I6c5f30058b57ccd1a096ad0e9452a4dfbb7d9aab Reviewed-on: https://go-review.googlesource.com/c/go/+/391454 Trust: Bryan Mills <bcmills@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* internal/fuzz: don't use dirty coverage maps during minimizationRoland Shoemaker2022-03-101-0/+84
| | | | | | | | | | | | | | | | | | | When minimizing a value, if the value cannot be minimized (i.e. it is the final value is the same value as was sent for minimization) return the initial coverage map, rather than the coverageSnapshot, which is actually the coverage map for the final minimization step and may not accurately reflect whether the input actually expands the coverage set or not. Updates #48326 Change-Id: I01f0eebe5841e808b6799647d2e5fe3aa45cd2e0 Reviewed-on: https://go-review.googlesource.com/c/go/+/391614 Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* go/types, types2: remove incorrect assertion (don't crash)Robert Griesemer2022-03-102-2/+13
| | | | | | | | | | | | | | | | | | | The removed assertion was never incorrect, as signatures may be from methods in interfaces, and (some) interfaces set the receivers of their methods (so we have a position for error reporting). This CL changes the issue below from a release blocker to an issue for Go 1.19. For #51593. Change-Id: I0c5f2913b397b9ab557ed74a80cc7a715e840412 Reviewed-on: https://go-review.googlesource.com/c/go/+/391615 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/compile: fix expression switches using type parametersKeith Randall2022-03-102-1/+21
| | | | | | | | | | | | | | | | Both the thing we're switching on, as well as the cases we're switching for. Convert anything containing a type parameter to interface{} before the comparison happens. Fixes #51522 Change-Id: I97ba9429ed332cb7d4240cb60f46d42226dcfa5f Reviewed-on: https://go-review.googlesource.com/c/go/+/391594 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* cmd/compile: fix transform of OEQ/ONE when one arg is a type paramKeith Randall2022-03-101-1/+1
| | | | | | | | | | | | | | | At this point in stenciling, we have shape types, not raw type parameters. The code was correct in the other part of this function. Update #51522 Change-Id: Ife495160a2be5f6af5400363c3efb68dda518b5f Reviewed-on: https://go-review.googlesource.com/c/go/+/391475 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* runtime,cmd/compile: change reg duff{zero,copy} for regabi riscv64Meng Zhuo2022-03-103-13/+13
| | | | | | | | | | | | | | | | As CL 356519 require, X8-X23 will be argument register, however X10, X11 is used by duff device. This CL changes X10, X11 into X24, X25 to meet the prerequisite. Update #40724 Change-Id: Ie9b899afbba7e9a51bb7dacd89e49ca1c1fc33ff Reviewed-on: https://go-review.googlesource.com/c/go/+/357976 Trust: mzh <mzh@golangcn.org> Run-TryBot: mzh <mzh@golangcn.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joel Sing <joel@sing.id.au>
* cmd/compile,bytealg: change context register on riscv64Meng Zhuo2022-03-104-8/+8
| | | | | | | | | | | | | | | | The register ABI will use X8-X23 (CL 356519), this CL changes context register from X20(S4) to X26(S10) to meet the prerequisite. Update #40724 Change-Id: I93d51d22fe7b3ea5ceffe96dff93e3af60fbe7f6 Reviewed-on: https://go-review.googlesource.com/c/go/+/357974 Trust: mzh <mzh@golangcn.org> Run-TryBot: mzh <mzh@golangcn.org> Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* go/types, types2: pointer base types cannot be type constraintsRobert Griesemer2022-03-093-3/+25
| | | | | | | | | | | | | | | | | Pointer types may appear in expressions *P and we don't know if we have an indirection (P is a pointer value) or a pointer type (P is a type) until we type-check P. Don't forget to check that a type P must be an ordinary (not a constraint) type in this special case. Fixes #51578. Change-Id: If782cc6dd2a602a498574c78c99e40c3b72274a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/391275 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* go/types, types2: clarify documentation with respect to generic typesRobert Findley2022-03-094-14/+21
| | | | | | | | | | | | | | | | Address several areas where documentation was inaccurate or unclear regarding generic types. Also prefer the use of the word 'generic' over 'parameterized', and add additional documentation for the use of SetConstraint. For #49593 Change-Id: Iccac60d1b3e2c45a57a3d03b3c10984293af57dd Reviewed-on: https://go-review.googlesource.com/c/go/+/391154 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/compile: require -p flagRuss Cox2022-03-0911-27/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The -p flag specifies the import path of the package being compiled. This CL makes it required when invoking the compiler and adjusts tests that invoke the compiler directly to conform to this new requirement. The go command already passes the flag, so it is unmodified in this CL. It is expected that any other Go build systems also already pass -p, or else they will need to arrange to do so before updating to Go 1.19. Of particular note, Bazel already does for rules with an importpath= attribute, which includes all Gazelle-generated rules. There is more cleanup possible now in cmd/compile, cmd/link, and other consumers of Go object files, but that is left to future CLs. Additional historical background follows but can be ignored. Long ago, before the go command, or modules, or any kind of versioning, symbols in Go archive files were named using just the package name, so that for example func F in math/rand and func F in crypto/rand would both be the object file symbol 'rand.F'. This led to collisions even in small source trees, which made certain packages unusable in the presence of other packages and generally was a problem for Go's goal of scaling to very large source trees. Fixing this problem required changing from package names to import paths in symbol names, which was mostly straightforward. One wrinkle, though, is that the compiler did not know the import path of the package being compiled; it only knew the package name. At the time, there was no go command, just Makefiles that people had invoking 6g (now “go tool compile”) and then copying the resulting object file to an importable location. That is, everyone had a custom build setup for Go, because there was no standard one. So it was not particularly attractive to change how the compiler was invoked, since that would break approximately every Go user at the time. Instead, we arranged for the compiler to emit, and other tools reading object files to recognize, a special import path (the empty string, it turned out) denoting “the import path of this object file”. This worked well enough at the time and maintained complete command-line compatibility with existing Go usage. The changes implementing this transition can be found by searching the Git history for “package global name space”, which is what they eliminated. In particular, CL 190076 (a6736fa4), CL 186263 (758f2bc5), CL 193080 (1cecac81), CL 194053 (19126320), and CL 194071 (531e6b77) did the bulk of this transformation in January 2010. Later, in September 2011, we added the -p flag to the compiler for diagnostic purposes. The problem was that it was easy to create import cycles, especially in tests, and these could not be diagnosed until link time. You'd really want the compiler to diagnose these, for example if the compilation of package sort noticed it was importing a package that itself imported "sort". But the compilation of package sort didn't know its own import path, and so it could not tell whether it had found itself as a transitive dependency. Adding the -p flag solved this problem, and its use was optional, since the linker would still diagnose the import cycle in builds that had not updated to start passing -p. This was CL 4972057 (1e480cd1). There was still no go command at this point, but when we introduced the go command we made it pass -p, which it has for many years at this point. Over time, parts of the compiler began to depend on the presence of the -p flag for various reasonable purposes. For example: In CL 6497074 (041fc8bf; Oct 2012), the race detector used -p to detect packages that should not have race annotations, such as runtime/race and sync/atomic. In CL 13367052 (7276c02b; Sep 2013), a bug fix used -p to detect the compilation of package reflect. In CL 30539 (8aadcc55; Oct 2016), the compiler started using -p to identify package math, to be able to intrinsify calls to Sqrt inside that package. In CL 61019 (9daee931; Sep 2017), CL 71430 (2c1d2e06; Oct 2017), and later related CLs, the compiler started using the -p value when creating various DWARF debugging information. In CL 174657 (cc5eaf93; May 2019), the compiler started writing symbols without the magic empty string whenever -p was used, to reduce the amount of work required in the linker. In CL 179861 (dde7c770; Jun 2019), the compiler made the second argument to //go:linkname optional when -p is used, because in that case the compiler can derive an appropriate default. There are more examples. Today it is impossible to compile the Go standard library without using -p, and DWARF debug information is incomplete without using -p. All known Go build systems pass -p. In particular, the go command does, which is what nearly all Go developers invoke to build Go code. And Bazel does, for go_library rules that set the importpath attribute, which is all rules generated by Gazelle. Gccgo has an equivalent of -p and has required its use in order to disambiguate packages with the same name but different import paths since 2010. On top of all this, various parts of code generation for generics are made more complicated by needing to cope with the case where -p is not specified, even though it's essentially always specified. In summary, the current state is: - Use of the -p flag with cmd/compile is required for building the standard library, and for complete DWARF information, and to enable certain linker speedups. - The go command and Bazel, which we expect account for just about 100% of Go builds, both invoke cmd/compile with -p. - The code in cmd/compile to support builds without -p is complex and has become more complex with generics, but it is almost always dead code and therefore not worth maintaining. - Gccgo already requires its equivalent of -p in any build where two packages have the same name. All this supports the change in this CL, which makes -p required and adjusts tests that invoke cmd/compile to add -p appropriately. Future CLs will be able to remove all the code dealing with the possibility of -p not having been specified. Change-Id: I6b95b9d4cffe59c7bac82eb273ef6c4a67bb0e43 Reviewed-on: https://go-review.googlesource.com/c/go/+/391014 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* go/types, types2: disable field accesses through type parametersRobert Griesemer2022-03-093-14/+26
| | | | | | | | | | | | | | | | | This is a feature that is not understood well enough and may have subtle repercussions impacting future changes. Disable for Go 1.18. The actual change is trivial: disable a branch through a flag. The remaining changes are adjustments to tests. Fixes #51576. Change-Id: Ib77b038b846711a808315a8889b3904e72367bce Reviewed-on: https://go-review.googlesource.com/c/go/+/391135 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: fix buildvcs when using older git versionsMark Pulford2022-03-092-2/+2
| | | | | | | | | | | | | | | Git versions before v2.10.0 do not support --no-show-signature. Using "-c" allows Git to ignore the configuration option if it does not exist. Fixes #51253 Change-Id: I2b1adaca0eb18ae31f2e1119e354ce515b00cfc2 Reviewed-on: https://go-review.googlesource.com/c/go/+/388194 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/compile: mark instantiated generic functions as DUPOKMatthew Dempsky2022-03-091-0/+8
| | | | | | | | | | | | | | | | | | | | | Unified IR wasn't marking instantiated generic functions as DUPOK, even though they can appear in multiple compilation units, which evidently interfered with cmd/link's dead code elimination logic. Manually confirmed to fix the issue, but non-trivial to test within $GOROOT/test currently, because it's only reproducible when cmd/compile is invoked with -p. @rsc is currently investigating updating test/run.go appropriately, after which I'll revisit writing a test case. Fixes #51519. Change-Id: I74a79ed0ca15b25b826e419714af5ceb6e567012 Reviewed-on: https://go-review.googlesource.com/c/go/+/390956 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
* cmd/internal/obj/arm64: optimize function prologue/epilogue with STP/LDPeric fang2022-03-091-88/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In function prologue and epilogue, we save and restore FP and LR registers, and adjust RSP. The current instruction sequence is as follow. For frame size <= 240B, prologue: MOVD.W R30, -offset(RSP) MOVD R29, -8(RSP) epilogue: MOVD -8(RSP), R29 MOVD.P offset(RSP), R30 For frame size > 240B, prologue: SUB $offset, RSP, R27 MOVD R30, (R27) MOVD R27, RSP MOVD R29, -8(RSP) epilogue: MOVD -8(RSP), R29 MOVD (RSP), R30 ADD $offset, RSP Each sequence uses two load or store instructions, actually we can load or store two registers with one LDP or STP instruction. This CL changes the sequences as follow. For frame size <= 496B, prologue: STP (R29, R30), -(offset+8)(RSP) SUB $offset, RSP, RSP epilogue: LDP -8(RSP), (R29, R30) ADD $offset, RSP, RSP For frame size > 496B, prologue: SUB $offset, RSP, R20 STP (R29, R30), -8(R20) MOVD R20, RSP epilogue: LDP -8(RSP), (R29, R30) ADD $offset, RSP, RSP Change-Id: Ia58af85fc81cce9b7c393dc38df43bffb203baad Reviewed-on: https://go-review.googlesource.com/c/go/+/379075 Reviewed-by: Cherry Mui <cherryyz@google.com> Trust: Eric Fang <eric.fang@arm.com> Run-TryBot: Eric Fang <eric.fang@arm.com>
* cmd/compile/internal: add ABI register information for riscv64Meng Zhuo2022-03-091-0/+51
| | | | | | | | | | | | | | This CL adds the defines for ABI registers on riscv64. Updates #40724 Change-Id: I53a89d88b6feb1a88cf7008b8484d444791e8a55 Reviewed-on: https://go-review.googlesource.com/c/go/+/356519 Trust: mzh <mzh@golangcn.org> Run-TryBot: mzh <mzh@golangcn.org> Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/go: for gccgo expect one fewer file in TestScript/list_swigcxxIan Lance Taylor2022-03-081-2/+3
| | | | | | | | | | | | One of the files in CompileGoFiles is actually _cgo_import.go, but that file is only generated for gc, not for gccgo. Change-Id: I87bb55552e1409cc57da8f35a32b37ce4a3df60c Reviewed-on: https://go-review.googlesource.com/c/go/+/390895 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>