summaryrefslogtreecommitdiff
path: root/src/cmd
Commit message (Collapse)AuthorAgeFilesLines
* cmd/go/internal/modfetch: update expected tags for TestCodeRepoVersionsTobias Klauser2020-10-281-1/+1
| | | | | | | | | | | | Updates #28856 Change-Id: I89c564cefd7c5777904bc00c74617dab693373bf Reviewed-on: https://go-review.googlesource.com/c/go/+/265819 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org>
* cmd/compile,cmd/internal/obj/riscv,runtime: use Duff's devices on riscv64Michał Derkacz2020-10-287-4/+141
| | | | | | | | | | | | Implement runtime.duffzero and runtime.duffcopy for riscv64. Use obj.ADUFFZERO/obj.ADUFFCOPY for medium size, word aligned zeroing/moving. Change-Id: I42ec622055630c94cb77e286d8d33dbe7c9f846c Reviewed-on: https://go-review.googlesource.com/c/go/+/237797 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* cmd/compile: optimize generated struct/array equality codeKeith Randall2020-10-281-45/+99
| | | | | | | | | | | | | | | Use a standard "not-equal" label that we can jump to when we detect that the arguments are not equal. This prevents the recombination that was noticed in #39428. Fixes #39428 Change-Id: Ib7c6b3539f4f6046043fd7148f940fcdcab70427 Reviewed-on: https://go-review.googlesource.com/c/go/+/255317 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
* cmd/compile: make sure field offset is aligned for structure splittingDavid Chase2020-10-281-6/+1
| | | | | | | | | | | | | | Always use the aligned form -- the old code sometimes could at least nominally use a misaligned field in an SSA-able struct, even if not actually. Fixes #42181. Change-Id: Ibdce0985f9349da70921a37423054b85ee4200d0 Reviewed-on: https://go-review.googlesource.com/c/go/+/265277 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: David Chase <drchase@google.com>
* cmd/link: remove all constants of elfMeng Zhuo2020-10-2810-789/+455
| | | | | | | | | | | | | | | | Use debug/elf instead. Related: CL 252478 CL 265317 Change-Id: If63b0458d9a6e825b40616bfb7a5a2c2e32402b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/265318 Trust: Meng Zhuo <mzh@golangcn.org> Run-TryBot: Meng Zhuo <mzh@golangcn.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/go: add -include to cgo whitelistDave Pifke2020-10-282-0/+4
| | | | | | | | | | | Fixes #39988. Change-Id: Ia6f5b73e6508f27e3badbcbd29dbeadffd55a932 Reviewed-on: https://go-review.googlesource.com/c/go/+/240739 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/dist: use GOOS=ios for iOS simulator testCherry Zhang2020-10-281-4/+5
| | | | | | | | | | | Updates #42100. Change-Id: Ib59432bea99a9dd6e25fbd759b31e423dc250f42 Reviewed-on: https://go-review.googlesource.com/c/go/+/265197 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/compile: print pointers to go:notinheap types without converting to ↵Keith Randall2020-10-273-216/+228
| | | | | | | | | | | | | | | | | unsafe.Pointer Pretty minor concern, but after auditing the compiler/runtime for conversions from pointers to go:notinheap types to unsafe.Pointer, this is the only remaining one I found. Update #42076 Change-Id: I81d5b893c9ada2fc19a51c2559262f2e9ff71c35 Reviewed-on: https://go-review.googlesource.com/c/go/+/265757 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* cmd/compile, runtime: store pointers to go:notinheap types indirectlyKeith Randall2020-10-272-3/+5
| | | | | | | | | | | | | | | pointers to go:notinheap types should be treated as scalars. That means they shouldn't be stored directly in interfaces, or directly in reflect.Value.ptr. Also be sure to use uintpr to compare such pointers in reflect.DeepEqual. Fixes #42076 Change-Id: I53735f6d434e9c3108d4940bd1bae14c61ef2a74 Reviewed-on: https://go-review.googlesource.com/c/go/+/264480 Trust: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/compile: fix storeType to handle pointers to go:notinheap typesKeith Randall2020-10-271-1/+7
| | | | | | | | | | | | | | | | | storeType splits compound stores up into a scalar parts and a pointer parts. The scalar part happens unconditionally, and the pointer part happens under the guard of a write barrier check. Types which are declared as pointers, but are represented as scalars because they might have "bad" values, were not handled correctly here. They ended up not getting stored in either set. Fixes #42032 Change-Id: I46f6600075c0c370e640b807066247237f93c7ac Reviewed-on: https://go-review.googlesource.com/c/go/+/264300 Trust: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* doc/go1.16: document BuildID in 'go list -export'Daniel Martí2020-10-273-3/+3
| | | | | | | | | | | | | | | | This corresponds to the feature in https://golang.org/cl/263542, since this can be a noteworthy change to people writing tools to inspect Go builds. Also amend the wording to clarify that build IDs are for an entire compiled package, not just their export data or object file. Change-Id: I2eb295492807d5d2997a35e5e2371914cb3ad3a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/264158 Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
* cmd/compile: replace int32(b2i(x)) with b2i32(x) in rulesAlberto Donizetti2020-10-276-9/+9
| | | | | | | Change-Id: I7fbb0c1ead6e29a7445c8ab43f7050947597f3e8 Reviewed-on: https://go-review.googlesource.com/c/go/+/265497 Trust: Alberto Donizetti <alb.donizetti@gmail.com> Reviewed-by: Keith Randall <khr@golang.org>
* cmd/compile: delete isPowerOfTwo, switch to isPowerOfTwo64Alberto Donizetti2020-10-279-292/+289
| | | | | | | | | | | | | | | | | rewrite.go has two identical functions isPowerOfTwo and isPowerOfTwo64; the former has been there for a while, while the latter was added together with isPowerOfTwo{8,16,32} for use in typed rules. This change deletes isPowerOfTwo and switch to using isPowerOfTwo64 everywhere. Change-Id: If26c94565d2393fac6f0ba117ee7ee2fc915f7cd Reviewed-on: https://go-review.googlesource.com/c/go/+/265417 Trust: Alberto Donizetti <alb.donizetti@gmail.com> Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
* cmd/compile: clean up ValAndOff funcs after untyped aux removalAlberto Donizetti2020-10-272-32/+12
| | | | | | | | | | | | | | | Changes: - makeValAndOff is deleted in favour of MakeValAndOff{32,64} - canAdd is renamed to canAdd64 to uniform with existing canAdd32 - addOffset{32,64} is simplified by directly using MakeValAndOff{32,64} - ValAndOff.Int64 is removed Change-Id: Ic01db7fa31ddfe0aaaf1d1d77af823d48a7bee84 Reviewed-on: https://go-review.googlesource.com/c/go/+/265357 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Alberto Donizetti <alb.donizetti@gmail.com>
* cmd/compile: remove support for untyped ssa rulesAlberto Donizetti2020-10-271-65/+22
| | | | | | | | | | | This change removes support in rulegen for untyped -> ssa rules. Change-Id: I202018e191fc74f027243351bc8cf96145f2482c Reviewed-on: https://go-review.googlesource.com/c/go/+/264679 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Alberto Donizetti <alb.donizetti@gmail.com>
* cmd/compile: combine more 32 bit shift and mask operations on ppc64Paul E. Murphy2020-10-277-0/+782
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Combine (AND m (SRWconst x)) or (SRWconst (AND m x)) when mask m is and the shift value produce constant which can be encoded into an RLWINM instruction. Combine (CLRLSLDI (SRWconst x)) if the combining of the underling rotate masks produces a constant which can be encoded into RLWINM. Likewise for (SLDconst (SRWconst x)) and (CLRLSDI (RLWINM x)). Combine rotate word + and operations which can be encoded as a single RLWINM/RLWNM instruction. The most notable performance improvements arise from the crypto benchmarks below (GOARCH=power8 on a ppc64le/linux): pkg:golang.org/x/crypto/blowfish goos:linux goarch:ppc64le ExpandKeyWithSalt 52.2µs ± 0% 47.5µs ± 0% -8.88% ExpandKey 44.4µs ± 0% 40.3µs ± 0% -9.15% pkg:golang.org/x/crypto/ssh/internal/bcrypt_pbkdf goos:linux goarch:ppc64le Key 57.6ms ± 0% 52.3ms ± 0% -9.13% pkg:golang.org/x/crypto/bcrypt goos:linux goarch:ppc64le Equal 90.9ms ± 0% 82.6ms ± 0% -9.13% DefaultCost 91.0ms ± 0% 82.7ms ± 0% -9.12% Change-Id: I59a0ca29face38f4ab46e37124c32906f216c4ce Reviewed-on: https://go-review.googlesource.com/c/go/+/260798 Run-TryBot: Carlos Eduardo Seo <carlos.seo@linaro.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.com> Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
* cmd/compile: remove isLiteralCuong Manh Le2020-10-271-8/+3
| | | | | | | | | | | | | It has duplicated logic with "n.isGoConst". Passes toolstash-check. Change-Id: I5bf871ef81c7188ca09dae29c7ff55b3a254d972 Reviewed-on: https://go-review.googlesource.com/c/go/+/265437 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* cmd/dist: fix build failure of misc/cgo/test on arm64xd2020-10-271-2/+7
| | | | | | | | | | | | | | | | | | | | | misc/cgo/test fails in 'dist test' on arm64 if the C compiler is of GCC-9.4 or above and its 'outline atomics' feature is enabled, since the internal linking hasn't yet supported "__attribute__((constructor))" and also mis-handles hidden visibility. This change addresses the problem by skipping the internal linking cases of misc/cgo/test on linux/arm64. It fixes 'dist test' failure only, user is expected to pass a GCC option '-mno-outline-atomics' via CGO_CFLAGS if running into the same problem when building cgo programs using internal linking. Updates #39466 Change-Id: I57f9e85fca881e5fd2dae6c1b4446bce9e0c1975 Reviewed-on: https://go-review.googlesource.com/c/go/+/262357 Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
* cmd/go/internal/fsys: add GlobRuss Cox2020-10-272-68/+353
| | | | | | | | | | | | | | | Glob is needed for //go:embed processing. Also change TestReadDir to be deterministic and print more output about failures. Change-Id: Ie22a9c5b32bda753579ff98cec1d28e3244c4e06 Reviewed-on: https://go-review.googlesource.com/c/go/+/264538 Trust: Russ Cox <rsc@golang.org> Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
* cmd/go/internal/imports: make Tags and AnyTags safe for concurrent useBryan C. Mills2020-10-271-7/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AnyTags turned up as a data race while running 'go test -race cmd/go'. I'm not sure how long the race has been present. ================== WARNING: DATA RACE Read at 0x000001141ec0 by goroutine 8: cmd/go/internal/imports.AnyTags() /usr/local/google/home/bcmills/go/src/cmd/go/internal/imports/tags.go:45 +0x10e cmd/go/internal/modload.QueryPattern.func2() /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:539 +0x11d cmd/go/internal/modload.QueryPattern.func4.1() /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:607 +0x3db cmd/go/internal/modload.queryPrefixModules.func1() /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:677 +0xa7 Previous write at 0x000001141ec0 by goroutine 7: cmd/go/internal/imports.AnyTags() /usr/local/google/home/bcmills/go/src/cmd/go/internal/imports/tags.go:46 +0x26b cmd/go/internal/modload.QueryPattern.func2() /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:539 +0x11d cmd/go/internal/modload.QueryPattern.func4.1() /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:607 +0x3db cmd/go/internal/modload.queryPrefixModules.func1() /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:677 +0xa7 Goroutine 8 (running) created at: cmd/go/internal/modload.queryPrefixModules() /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:676 +0x284 cmd/go/internal/modload.QueryPattern.func4() /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:624 +0x2e4 cmd/go/internal/modfetch.TryProxies() /usr/local/google/home/bcmills/go/src/cmd/go/internal/modfetch/proxy.go:220 +0x107 cmd/go/internal/modload.QueryPattern() /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:590 +0x69e cmd/go/internal/work.installOutsideModule() /usr/local/google/home/bcmills/go/src/cmd/go/internal/work/build.go:744 +0x4b0 cmd/go/internal/work.runInstall() /usr/local/google/home/bcmills/go/src/cmd/go/internal/work/build.go:556 +0x217 main.main() /usr/local/google/home/bcmills/go/src/cmd/go/main.go:194 +0xb94 Goroutine 7 (finished) created at: cmd/go/internal/modload.queryPrefixModules() /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:676 +0x284 cmd/go/internal/modload.QueryPattern.func4() /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:624 +0x2e4 cmd/go/internal/modfetch.TryProxies() /usr/local/google/home/bcmills/go/src/cmd/go/internal/modfetch/proxy.go:220 +0x107 cmd/go/internal/modload.QueryPattern() /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:590 +0x69e cmd/go/internal/work.installOutsideModule() /usr/local/google/home/bcmills/go/src/cmd/go/internal/work/build.go:744 +0x4b0 cmd/go/internal/work.runInstall() /usr/local/google/home/bcmills/go/src/cmd/go/internal/work/build.go:556 +0x217 main.main() /usr/local/google/home/bcmills/go/src/cmd/go/main.go:194 +0xb94 ================== Change-Id: Id394978fd6ea0c30614caf8f90ee4f8e2d272843 Reviewed-on: https://go-review.googlesource.com/c/go/+/265278 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
* cmd/go: fix bug introduced in CL 264537Russ Cox2020-10-271-1/+2
| | | | | | | | | | | Shadowing bug noted after submit by Tom Thorogood. Change-Id: I5f40cc3863dcd7dba5469f8530e9d0460e7c3e7e Reviewed-on: https://go-review.googlesource.com/c/go/+/265537 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org>
* cmd/compile: eliminate unnecessary sign/zero extension for riscv64Joel Sing2020-10-275-32/+843
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add additional rules to eliminate unnecessary sign/zero extension for riscv64. Also where possible, replace an extension following a load with a different typed load. This removes almost another 8,000 instructions from the go binary. Of particular note, change Eq16/Eq8/Neq16/Neq8 to zero extend each value before subtraction, rather than zero extending after subtraction. While this appears to double the number of zero extensions, it often lets us completely eliminate them as the load can already be performed in a properly typed manner. As an example, prior to this change runtime.memequal16 was: 0000000000013028 <runtime.memequal16>: 13028: 00813183 ld gp,8(sp) 1302c: 00019183 lh gp,0(gp) 13030: 01013283 ld t0,16(sp) 13034: 00029283 lh t0,0(t0) 13038: 405181b3 sub gp,gp,t0 1303c: 03019193 slli gp,gp,0x30 13040: 0301d193 srli gp,gp,0x30 13044: 0011b193 seqz gp,gp 13048: 00310c23 sb gp,24(sp) 1304c: 00008067 ret Whereas it now becomes: 0000000000012fa8 <runtime.memequal16>: 12fa8: 00813183 ld gp,8(sp) 12fac: 0001d183 lhu gp,0(gp) 12fb0: 01013283 ld t0,16(sp) 12fb4: 0002d283 lhu t0,0(t0) 12fb8: 405181b3 sub gp,gp,t0 12fbc: 0011b193 seqz gp,gp 12fc0: 00310c23 sb gp,24(sp) 12fc4: 00008067 ret Change-Id: I16321feb18381241cab121c0097a126104c56c2c Reviewed-on: https://go-review.googlesource.com/c/go/+/264659 Trust: Joel Sing <joel@sing.id.au> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* cmd/compile: use MOV pseudo-instructions for sign/zero extensionJoel Sing2020-10-275-231/+178
| | | | | | | | | | | | | | | | | Rather than handling sign and zero extension via rules, defer to the assembler and use MOV pseudo-instructions. The instruction can also be omitted where the type and size is already correct. This change results in more than 6,000 instructions being removed from the go binary (in part due to omitted instructions, in part due to MOVBU having a more efficient implementation in the assembler than what is used in the current ZeroExt8to{16,32,64} rules). This will also allow for further rewriting to remove redundant sign/zero extension. Change-Id: I05e42fd9f09f40a69948be7de772cce8946c8744 Reviewed-on: https://go-review.googlesource.com/c/go/+/264658 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* cmd/go/internal/modload: embed PackageOpts in loaderParamsBryan C. Mills2020-10-272-13/+15
| | | | | | | | | | | | | | | | | Instead of duplicating PackageOpts fields in the loaderParams struct, embed the PackageOpts directly. Many of the fields are duplicated, and further fields that would also be duplicated will be added in subsequent changes. For #36460 Change-Id: I3b0770d162e901d23ec1643183eb07c413d51e0a Reviewed-on: https://go-review.googlesource.com/c/go/+/263138 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
* Revert "cmd/link: remove all constants of elf"Meng Zhuo2020-10-2710-454/+788
| | | | | | | | | | | This reverts CL 252478. Reason for revert: debug/Elfhdr has no Flags fields, some other CLs has removed it. Change-Id: Ie199ac29f382c56aaf37a2e8338f2dafe6e79297 Reviewed-on: https://go-review.googlesource.com/c/go/+/265317 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Meng Zhuo <mzh@golangcn.org>
* cmd/link: remove all constants of elfMeng Zhuo2020-10-2710-788/+454
| | | | | | | | | | | Use debug/elf instead. Change-Id: Ia6580648b6440e4a352f5c5ed59ac4d1c95e0175 Reviewed-on: https://go-review.googlesource.com/c/go/+/252478 Run-TryBot: Meng Zhuo <mzh@golangcn.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Meng Zhuo <mzh@golangcn.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* cmd/link,cmd/internal/obj/riscv: add TLS support for linux/riscv64Joel Sing2020-10-274-12/+44
| | | | | | | | | | | | | | Add support for Thread Local Storage (TLS) for linux/riscv64 with external linking, using the initial-exec model. Update #36641 Change-Id: I3106ef9a29cde73215830b00deff43dbec1c76e0 Reviewed-on: https://go-review.googlesource.com/c/go/+/263478 Trust: Joel Sing <joel@sing.id.au> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* cmd/compile,cmd/internal/sys: enable additional build modes on linux/riscv64Joel Sing2020-10-274-9/+9
| | | | | | | | | | | Enable c-archive, c-shared, shared and pie build modes for linux/riscv64. Change-Id: I15a8a51b84dbbb82a5b6592aec84a7f09f0cc37f Reviewed-on: https://go-review.googlesource.com/c/go/+/263457 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
* cmd/compile: defer lowering OANDNOT until SSACuong Manh Le2020-10-273-19/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, "x &^ y" gets rewriten into "x & ^y" during walk. It adds unnecessary complexity to other parts, which must aware about this. Instead, we can just implement "&^" in the conversion to SSA, so "&^" can be handled like other binary operators. However, this CL does not pass toolstash-check. It seems that implements "&^" in the conversion to SSA causes registers allocation change. With the parent: obj: 00212 (.../src/runtime/complex.go:47) MOVQ X0, AX obj: 00213 (.../src/runtime/complex.go:47) BTRQ $63, AX obj: 00214 (.../src/runtime/complex.go:47) MOVQ "".n(SP), CX obj: 00215 (.../src/runtime/complex.go:47) MOVQ $-9223372036854775808, DX obj: 00216 (.../src/runtime/complex.go:47) ANDQ DX, CX obj: 00217 (.../src/runtime/complex.go:47) ORQ AX, CX With this CL: obj: 00212 (.../src/runtime/complex.go:47) MOVQ X0, AX obj: 00213 (.../src/runtime/complex.go:47) BTRQ $63, AX obj: 00214 (.../src/runtime/complex.go:47) MOVQ $-9223372036854775808, CX obj: 00215 (.../src/runtime/complex.go:47) MOVQ "".n(SP), DX obj: 00216 (.../src/runtime/complex.go:47) ANDQ CX, DX obj: 00217 (.../src/runtime/complex.go:47) ORQ AX, DX Change-Id: I80acf8496a91be4804fb7ef3df04c19baae2754c Reviewed-on: https://go-review.googlesource.com/c/go/+/264660 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* cmd/compile: port last ARM rules to typedAlberto Donizetti2020-10-262-18/+84
| | | | | | | | | | | | Passes GOARCH=arm gotip build -toolexec 'toolstash -cmp' -a std Change-Id: I4a1cace82c5d957774ea20572406af276f02bf97 Reviewed-on: https://go-review.googlesource.com/c/go/+/264680 Trust: Alberto Donizetti <alb.donizetti@gmail.com> Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> Reviewed-by: Keith Randall <khr@golang.org>
* cmd/go,cmd/compile,sync: remove special import case in cmd/goAustin Clements2020-10-262-5/+4
| | | | | | | | | | | | | | | | | | | | | | | CL 253748 introduced a special case in cmd/go to allow sync to import runtime/internal/atomic. Besides introducing unnecessary complexity into cmd/go, this breaks other packages (like gopls) that understand how imports work, but don't understand this special case. Fix this by using the more standard linkname-based approach to pull the necessary functions from runtime/internal/atomic into sync. Since these are compiler intrinsics, we also have to tell the compiler that the linknamed symbols are intrinsics to get this optimization in sync. Fixes #42196. Change-Id: I1f91498c255c91583950886a89c3c9adc39a32f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/265124 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Paul Murphy <murp@ibm.com> TryBot-Result: Go Bot <gobot@golang.org>
* cmd/internal/obj/{arm,s390x}: make return jump print nicerCherry Zhang2020-10-262-2/+6
| | | | | | | | | | | | | | | | | | | | | When a function with non-zero frame size makes a return jump (RET target), it assembles to, conceptually, MOV (SP), LR ADD $framesize, SP JMP target We did not clear some fields in the first instruction's Prog.To, causing it printed like (on ARM) MOVW.P 4(R13), (R14)(R14)(REG) Clear the fields to make it print nicer. Change-Id: I180901aeea41f1ff287d7c6034a6d69005927744 Reviewed-on: https://go-review.googlesource.com/c/go/+/264343 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Joel Sing <joel@sing.id.au>
* runtime,runtime/metrics: add memory metricsMichael Anthony Knyszek2020-10-261-1/+5
| | | | | | | | | | | | | | | | | | This change adds support for a variety of runtime memory metrics and contains the base implementation of Read for the runtime/metrics package, which lives in the runtime. It also adds testing infrastructure for the metrics package, and a bunch of format and documentation tests. For #37112. Change-Id: I16a2c4781eeeb2de0abcb045c15105f1210e2d8a Reviewed-on: https://go-review.googlesource.com/c/go/+/247041 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Trust: Michael Knyszek <mknyszek@google.com>
* cmd/go/internal/fsys: rewrite non-idiomatic if statementsRuss Cox2020-10-261-10/+14
| | | | | | | | | | | | https://golang.org/doc/effective_go.html#if Change-Id: I4d868e05c7827638f45b3b06d8762f5a298d56f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/264537 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
* runtime,cmd/cgo: simplify C -> Go call pathAustin Clements2020-10-263-112/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This redesigns the way calls work from C to exported Go functions. It removes several steps from the call path, makes cmd/cgo no longer sensitive to the Go calling convention, and eliminates the use of reflectcall from cgo. In order to avoid generating a large amount of FFI glue between the C and Go ABIs, the cgo tool has long depended on generating a C function that marshals the arguments into a struct, and then the actual ABI switch happens in functions with fixed signatures that simply take a pointer to this struct. In a way, this CL simply pushes this idea further. Currently, the cgo tool generates this argument struct in the exact layout of the Go stack frame and depends on reflectcall to unpack it into the appropriate Go call (even though it's actually reflectcall'ing a function generated by cgo). In this CL, we decouple this struct from the Go stack layout. Instead, cgo generates a Go function that takes the struct, unpacks it, and calls the exported function. Since this generated function has a generic signature (like the rest of the call path), we don't need reflectcall and can instead depend on the Go compiler itself to implement the call to the exported Go function. One complication is that syscall.NewCallback on Windows, which converts a Go function into a C function pointer, depends on cgocallback's current dynamic calling approach since the signatures of the callbacks aren't known statically. For this specific case, we continue to depend on reflectcall. Really, the current approach makes some overly simplistic assumptions about translating the C ABI to the Go ABI. Now we're at least in a much better position to do a proper ABI translation. For comparison, the current cgo call path looks like: GoF (generated C function) -> crosscall2 (in cgo/asm_*.s) -> _cgoexp_GoF (generated Go function) -> cgocallback (in asm_*.s) -> cgocallback_gofunc (in asm_*.s) -> cgocallbackg (in cgocall.go) -> cgocallbackg1 (in cgocall.go) -> reflectcall (in asm_*.s) -> _cgoexpwrap_GoF (generated Go function) -> p.GoF Now the call path looks like: GoF (generated C function) -> crosscall2 (in cgo/asm_*.s) -> cgocallback (in asm_*.s) -> cgocallbackg (in cgocall.go) -> cgocallbackg1 (in cgocall.go) -> _cgoexp_GoF (generated Go function) -> p.GoF Notably: 1. We combine _cgoexp_GoF and _cgoexpwrap_GoF and move the combined operation to the end of the sequence. This combined function also handles reflectcall's previous role. 2. We combined cgocallback and cgocallback_gofunc since the only purpose of having both was to convert a raw PC into a Go function value. We instead construct the Go function value in cgocallbackg1. 3. cgocallbackg1 no longer reaches backwards through the stack to get the arguments to cgocallback_gofunc. Instead, we just pass the arguments down. 4. Currently, we need an explicit msanwrite to mark the results struct as written because reflectcall doesn't do this. Now, the results are written by regular Go assignments, so the Go compiler generates the necessary MSAN annotations. This also means we no longer need to track the size of the arguments frame. Updates #40724, since now we don't need to teach cgo about the register ABI or change how it uses reflectcall. Change-Id: I7840489a2597962aeb670e0c1798a16a7359c94f Reviewed-on: https://go-review.googlesource.com/c/go/+/258938 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* cmd/link: preserve alignment for stackmap symbolsCherry Zhang2020-10-261-2/+6
| | | | | | | | | | | | | | | | | Stackmap symbols are content-addressable, so it may be dedup'd with another symbol with same content. We want stackmap symbols 4-byte aligned. But if it dedup's with another symbol with larger alignment, preserve that alignment. Fixes #42071. Change-Id: I1616dd2b0c175b2aac8f68782a5c7a62053c0b57 Reviewed-on: https://go-review.googlesource.com/c/go/+/264897 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Than McIntosh <thanm@google.com>
* cmd/dist: document why test fails on incomplete portsTobias Klauser2020-10-241-0/+3
| | | | | | | | | | | It might not be obvious from reading the code why we consider the test as failed on incomplete ports even though it passed. Add a comment documenting this behavior, as suggested by Dmitri in CL 155839. Change-Id: I3eb7db27d01d63db277172381e5fa51577dad941 Reviewed-on: https://go-review.googlesource.com/c/go/+/264682 Trust: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
* cmd/dist: add openbsd/mips64 as incomplete portJoel Sing2020-10-241-1/+3
| | | | | | | | | Update #40995 Change-Id: Id497f7688b00658b50feb7338157e0411b861910 Reviewed-on: https://go-review.googlesource.com/c/go/+/250578 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
* cmd/compile: enforce strongly typed rules for ARM (read)Constantin Konstantinidis2020-10-242-23/+23
| | | | | | | | | | | | | | | Add type casting to offset. L246-L247 L1473-L1475 toolstash-check successful. Change-Id: I816c7556609ca6dd67bff8007c2d006cab89ee2b Reviewed-on: https://go-review.googlesource.com/c/go/+/257639 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Alberto Donizetti <alb.donizetti@gmail.com>
* cmd/internal/obj/riscv: support additional register to register movesJoel Sing2020-10-242-26/+59
| | | | | | | | | | | | | | Add support for signed and unsigned register to register moves of various sizes. This makes it easier to handle zero and sign extension and will allow for further changes that improve the compiler optimisations for riscv64. While here, change the existing register to register moves from obj.Prog rewriting to instruction generation. Change-Id: Id21911019b76922367a134da13c3449a84a1fb08 Reviewed-on: https://go-review.googlesource.com/c/go/+/264657 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* cmd/go: change error message for missing import with unused replacementJay Conrod2020-10-234-63/+99
| | | | | | | | | | | | | | | | | In readonly mode, if a package is not provided by any module in the build list, and there is an unused replacement that contains the package, we now recommend a 'go get' command to add a requirement on the highest replaced version. Fixes #41416 Change-Id: Iedf3539292c70ea6ba6857433fd184454d9325da Reviewed-on: https://go-review.googlesource.com/c/go/+/263146 Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Trust: Jay Conrod <jayconrod@google.com>
* cmd/go: save sums for zips needed to diagnose ambiguous importsJay Conrod2020-10-234-27/+138
| | | | | | | | | | | | | | | | | | | Previously, we would retain entries in go.sum for .mod files in the module graph (reachable from the main module) and for .zip files of modules providing packages. This isn't quite enough: when we load a package, we need the content of each module in the build list that *could* provide the package (that is, each module whose path is a prefix of the package's path) so we can diagnose ambiguous imports. For #33008 Change-Id: I0b4d9d68c1f4ca382f0983a3a7e537764f35c3aa Reviewed-on: https://go-review.googlesource.com/c/go/+/262781 Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Trust: Jay Conrod <jayconrod@google.com>
* cmd/go: don't fetch files missing sums in readonly modeJay Conrod2020-10-2314-49/+216
| | | | | | | | | | | | | | | | | | | | | | | If the go command needs a .mod or .zip file in -mod=readonly mode (now the default), and that file doesn't have a hash in the main module's go.sum file, the go command will now report an error before fetching the file, rather than at the end when failing to update go.sum. The error says specifically which entry is missing. If this error is encountered when loading the build list, it will suggest 'go mod tidy'. If this error is encountered when loading a specific package (an import or command line argument), the error will mention that package and will suggest 'go mod tidy' or 'go get -d'. Fixes #41934 Fixes #41935 Change-Id: I96ec2ef9258bd4bade9915c43d47e6243c376a81 Reviewed-on: https://go-review.googlesource.com/c/go/+/262341 Reviewed-by: Bryan C. Mills <bcmills@google.com> Trust: Jay Conrod <jayconrod@google.com>
* cmd/go: in 'go mod init', suggest running 'go mod tidy'Jay Conrod2020-10-232-0/+53
| | | | | | | | | | | | | | | | | | | | | | | | When 'go mod init' is run in an existing project, it may import requirements from a vendor configuration file, but the requirements may not be complete, and go.sum won't contain sums for module zips. With -mod=readonly, the next build command is likely to fail. 'go mod init' will now suggest running 'go mod tidy' if there are .go files or subdirectories in the current directory. We could potentially run 'go mod tidy' automatically within 'go mod init', but it seems better to guide users to using 'go mod tidy' as a separate command to fix missing dependencies. For #41712 Updates #40278 Change-Id: Iaece607f291244588a732ef4c5d576108965ca91 Reviewed-on: https://go-review.googlesource.com/c/go/+/264622 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
* cmd/go: refactor modload.InitModJay Conrod2020-10-237-72/+73
| | | | | | | | | | | | | | | | | | | | | | | InitMod is split into two functions. LoadModFile parses an existing go.mod file and loads the build list (or checks vendor/modules.txt for consistency in vendor mode). CreateModFile creates a new go.mod file, possibly inferring the module path and importing a vendor configuration file. Some logic is moved from runInit to CreateModFile. init-specific logic is removed from other functions. This CL shouldn't cause substantial differences in behavior, though some error messages are slightly different. For #41712 Change-Id: Ia684945cfcf5beca30bbb81e7144fc246c4f27ed Reviewed-on: https://go-review.googlesource.com/c/go/+/264621 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
* cmd/go: don't import requirements into existing go.mod filesJay Conrod2020-10-231-10/+0
| | | | | | | | | | | | | | | | | | | | Previously, if a go.mod file was present, and it only contained a module directive, any module-aware command would attempt to import requirements from a vendor configuration file like Gopkg.lock. This CL removes that functionality. It was undocumented and untested, and it can cause problems with -mod=readonly. It should never come up for go.mod files created with 'go mod init', since they have a "go" directive. For #40278 Change-Id: I64c0d67d204560aa5c775d29553883d094fd3b72 Reviewed-on: https://go-review.googlesource.com/c/go/+/264620 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org>
* cmd/go: break after terminal loop conditionMark Rushakoff2020-10-231-0/+2
| | | | | | | | | | | | | | | After the first time needCostly is set to true, there is no need to continue checking the remaining args. Change-Id: I07171ce50d20e2a917117a0f84c442fe978cb274 GitHub-Last-Rev: 6d0c19341b7a85d507c3ec4967bab5f83b0fad8d GitHub-Pull-Request: golang/go#41859 Reviewed-on: https://go-review.googlesource.com/c/go/+/260638 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Bryan C. Mills <bcmills@google.com> Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Go Bot <gobot@golang.org>
* cmd/go: replace some more stats with fsys.StatMichael Matloob2020-10-234-5/+5
| | | | | | | | | | | | | | To support overlays For #39958 Change-Id: I5ffd72aeb7f5f30f6c60f6334a01a0a1383c7945 Reviewed-on: https://go-review.googlesource.com/c/go/+/264478 Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com>
* cmd/compile: avoid generating CSEs; do all aggregates; maintain debug namesDavid Chase2020-10-239-524/+1163
| | | | | | | | | | | | | | | | | | | | | | | | | | This adds a pass to detect common selection operations, to avoid generating duplicates. Duplicate offsets are also detected. All aggregate types are now handled; there is some freedom in where expand_calls is run, though it must run before softfloat. Debug-name-maintenance is now incremental both in decompose builtin and in expand_calls; it might be good to push this into all the decompose passes. (this is a smash of 5 CLs that rewrote some of the same code several times to deal with phase-ordering problems, and included an abandoned attempt.) For #40724. Change-Id: I2a0c32f20660bf8b99e2bcecd33545d97d2bd3c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/249458 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* cmd/compile: intrinsify runtime/internal/atomic.{And,Or} on MIPSMichael Pratt2020-10-233-2/+11
| | | | | | | | | | | | This one is trivial, as there are already 32-bit AND and OR ops used to implement the more complex 8-bit versions. Change-Id: Ic48a53ea291d0067ebeab8e96c82e054daf20ae7 Reviewed-on: https://go-review.googlesource.com/c/go/+/263149 Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>