aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2022-07-26[release-branch.go1.17] cmd/compile: do not use special literal assignment ↵Cherry Mui
if LHS is address-taken A composite literal assignment x = T{field: v} may be compiled to x = T{} x.field = v We already do not use this form is RHS uses LHS. If LHS is address-taken, RHS may uses LHS implicitly, e.g. v = &x.field x = T{field: *v} The lowering above would change the value of RHS (*v). Updates #52953. Fixes #52960. Change-Id: I3f798e00598aaa550b8c17182c7472fef440d483 Reviewed-on: https://go-review.googlesource.com/c/go/+/407014 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> (cherry picked from commit 1c77137d4fdfbb3e7e8d9efaab3bab5ee736a19d) Reviewed-on: https://go-review.googlesource.com/c/go/+/419451 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-07-25[release-branch.go1.17] cmd/compile: fix prove pass when upper condition is ↵Keith Randall
<= maxint When the terminating condition is <= X, we need to make sure that X+step doesn't overflow. Fixes #53617 Change-Id: I36e5384d05b4d7168e48db6094200fcae409bfe5 Reviewed-on: https://go-review.googlesource.com/c/go/+/415219 Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Keith Randall <khr@golang.org> (cherry picked from commit 31b8c23c5702f129aca9241bbb2132c90b1929cc) Reviewed-on: https://go-review.googlesource.com/c/go/+/415415 Reviewed-by: Keith Randall <khr@google.com>
2022-07-06[release-branch.go1.17] cmd/compile: allow 128-bit values to be spilledKeith Randall
We sometimes use 16-byte load+store to move values around in memory. In rare circumstances, the loaded value must be spilled because the store can't happen yet. In that case, we need to be able to spill the 16-byte value. Fixes #53470 Change-Id: I09fd08e11a63c6ba3ef781d3f5ede237e9b0132e Reviewed-on: https://go-review.googlesource.com/c/go/+/413294 Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> (cherry picked from commit c2d373d5d1802d7479f3c81dcf01d41bef3646dd) Reviewed-on: https://go-review.googlesource.com/c/go/+/413456 Reviewed-by: Carlos Amedee <carlos@golang.org>
2022-02-18[release-branch.go1.17] cmd/compile: correct type of pointer difference on ↵Cherry Mui
RISCV64 Pointer comparison is lowered to the following on RISCV64 (EqPtr x y) => (SEQZ (SUB <x.Type> x y)) The difference of two pointers (the SUB) should not be pointer type. Otherwise it can cause the GC to find a bad pointer. Updates #51101. Fixes #51199. Change-Id: I7e73c2155c36ff403c032981a9aa9cccbfdf0f64 Reviewed-on: https://go-review.googlesource.com/c/go/+/385655 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> (cherry picked from commit 1ed30ca537a05b887f8479027b6363a03f957610) Reviewed-on: https://go-review.googlesource.com/c/go/+/386474
2022-02-07[release-branch.go1.17] cmd/compile: remove incorrect arm,arm64 CMP->CMN ↵David Chase
transformations These can go wrong when one of the operands is the minimum integer value. Fixes #50867. Change-Id: I238fe284f60c7ee5aeb9dc9a18e8b1578cdb77d0 Reviewed-on: https://go-review.googlesource.com/c/go/+/381318 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> (cherry picked from commit b7b44b3173f151a2313da7072afd25de80511605) Reviewed-on: https://go-review.googlesource.com/c/go/+/381474 Run-TryBot: Cherry Mui <cherryyz@google.com>
2022-02-07[release-branch.go1.17] cmd/compile: don't elide extension for LoadReg to FP ↵Cherry Mui
register on MIPS64 For an extension operation like MOVWreg, if the operand is already extended, we optimize the second extension out. Usually a LoadReg of a proper type would come already extended, as a MOVW/MOVWU etc. instruction does. But for a LoadReg to a floating point register, the instruction does not do the extension. So we cannot elide the extension. Updates #50671. Fixes #50683. Change-Id: Id8991df78d5acdecd3fd6138c558428cbd5f6ba3 Reviewed-on: https://go-review.googlesource.com/c/go/+/379236 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> (cherry picked from commit d93ff73ae207763871bee38590242be968b2e743) Reviewed-on: https://go-review.googlesource.com/c/go/+/379514
2021-12-21[release-branch.go1.17] cmd/compile: avoid adding LECall to the entry block ↵hanpro
when has opendefers The openDeferRecord always insert vardef/varlive pairs into the entry block, it may destroy the mem chain when LECall's args are writing into the same block. So create a new block before that happens. Fixes #49413 Change-Id: Ibda6c4a45d960dd412a641f5e02276f663c80785 Reviewed-on: https://go-review.googlesource.com/c/go/+/361410 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Alberto Donizetti <alb.donizetti@gmail.com> Trust: Than McIntosh <thanm@google.com> Reviewed-by: David Chase <drchase@google.com> (cherry picked from commit 4f083c7dcf6ace3e837b337e10cf2f4e3160677e) Reviewed-on: https://go-review.googlesource.com/c/go/+/362054 Reviewed-by: Keith Randall <khr@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-02[release-branch.go1.17] cmd/compile: only update source type when processing ↵Cuong Manh Le
struct/array This is backport of CL 3651594, with the test from CL 360057. CL 360057 fixed missing update source type in storeArgOrLoad. However, we should only update the type when processing struct/array. If we update the type right before calling storeArgOrLoad, we may generate a value with invalid type, e.g, OpStructSelect with non-struct type. Fixes #49392 Change-Id: Ib7e10f72f818880f550aae5c9f653db463ce29b0 Reviewed-on: https://go-review.googlesource.com/c/go/+/361594 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: David Chase <drchase@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/361596 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2021-11-24[release-branch.go1.17] cmd/compile: fix case where init info of OAS node is ↵Dan Scales
dropped When an OAS node is converted to an OSELRECV2 node in tcSelect(), the possible DCL node in the Init field was being dropped, since a completely new node was being created and the Init field was not set. I don't expect n.Init() to be set for the ORECV case, but the code now deals with that too. Fixed bug in both tcSelect() and transformSelect(). Cherry-picked from https://go-review.googlesource.com/c/go/+/348569 Fixes #49511 Change-Id: Id5b736daa8e90afda88aaa3769dde801db294c0d Reviewed-on: https://go-review.googlesource.com/c/go/+/363664 Trust: Dan Scales <danscales@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-11-24[release-branch.go1.17] cmd/compile: fix fuse pass to do CFG surgery correctlyKeith Randall
removePred and removeArg do different things. removePred moves the last predecessor to index k, whereas removeArg slides all the args k or greater down by 1 index. Kind of unfortunate different behavior in things named similarly. Fixes #49129 Change-Id: I9ae409bdac744e713f4c121f948e43db6fdc8542 Reviewed-on: https://go-review.googlesource.com/c/go/+/358117 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> (cherry picked from commit 8dbf3e9393400d72d313e5616c88873e07692c70) Reviewed-on: https://go-review.googlesource.com/c/go/+/358118 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-10-27[release-branch.go1.17] cmd/compile: ensure constant shift amounts are in ↵Keith Randall
range for arm Ensure constant shift amounts are in the range [0-31]. When shift amounts are out of range, bad things happen. Shift amounts out of range occur when lowering 64-bit shifts (we take an in-range shift s in [0-63] and calculate s-32 and 32-s, both of which might be out of [0-31]). The constant shift operations themselves still work, but their shift amounts get copied unmolested to operations like ORshiftLL which use only the low 5 bits. That changes an operation like <<100 which unconditionally produces 0, to <<4, which doesn't. Fixes #48479 Change-Id: I87363ef2b4ceaf3b2e316426064626efdfbb8ee3 Reviewed-on: https://go-review.googlesource.com/c/go/+/350969 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> (cherry picked from commit eff27e858b771bf5e0b5e7e836827c7d2941e6d4) Reviewed-on: https://go-review.googlesource.com/c/go/+/351069 Reviewed-by: Austin Clements <austin@google.com>
2021-10-27[release-branch.go1.17] cmd/compile: fix simplification rules on arm/arm64Keith Randall
Fixes #48475 Change-Id: Ic1e918f916eae223a3b530a51a58f03031924670 Reviewed-on: https://go-review.googlesource.com/c/go/+/350913 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/351071 Reviewed-by: Austin Clements <austin@google.com>
2021-09-01[release-branch.go1.17] cmd/compile: fix method expression lookup during importCuong Manh Le
CL 309831 fixed importing of method expressions, by re-using the same code already have for ODOTMETH. But that code does not work with embedded field. To fix this, we need to calculate all methods of the receiver base type of method expression, before looking up the selection. Fixes #48102 Change-Id: Ia244d36a3ed0f989735eb57becdfa70a81912f57 Reviewed-on: https://go-review.googlesource.com/c/go/+/346489 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> Reviewed-on: https://go-review.googlesource.com/c/go/+/346670 Reviewed-by: Keith Randall <khr@golang.org>
2021-07-22cmd/compile: do not change field offset in ABI analysisCherry Mui
Currently, the ABI analysis assigns parameter/result offsets to the fields of function *Type. In some cases, we may have an ABI0 function reference and an ABIInternal reference share the same function *Type. For example, for an ABI0 function F, "f := F" will make f and (ABI0) F having the same *Type. But f, as a func value, should use ABIInternal. Analyses on F and f will collide and cause ICE. Also, changing field offsets in ABI analysis has to be done very carefully to avoid data races. It has been causing trickiness/difficulty. This CL removes the change of field offsets in ABI analysis altogether. The analysis result is stored in ABIParamAssignment, which is the only way to access parameter/result stack offset now. Fixes #47317. Fixes #47227. Change-Id: I23a3e081a6cf327ac66855da222daaa636ed1ead Reviewed-on: https://go-review.googlesource.com/c/go/+/336629 Trust: Cherry Mui <cherryyz@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Than McIntosh <thanm@google.com>
2021-07-19cmd/{compile,link}: fix bug in map.zero handlingThan McIntosh
In CL 326211 a change was made to switch "go.map.zero" symbols from non-pkg DUPOK symbols to hashed symbols. The intent of this change was ensure that in cases where there are multiple competing go.map.zero symbols feeding into a link, the largest map.zero symbol is selected. The change was buggy, however, and resulted in duplicate symbols in the final binary (see bug cited below for details). This duplication was relatively benign for linux/ELF, but causes duplicate definition errors on Windows. This patch switches "go.map.zero" symbols back from hashed symbols to non-pkg DUPOK symbols, and updates the relevant code in the loader to ensure that we do the right thing when there are multiple competing DUPOK symbols with different sizes. Fixes #47185. Change-Id: I8aeb910c65827f5380144d07646006ba553c9251 Reviewed-on: https://go-review.googlesource.com/c/go/+/334930 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-07-18test/bench/go1: fix size for RegexpMatchMedium_32nimelehin
Change-Id: Idc67abb95248bc010820a89dd6096a2da334e723 GitHub-Last-Rev: ae9014b011efb2692f853888c1860920d1acc3cb GitHub-Pull-Request: golang/go#47254 Reviewed-on: https://go-review.googlesource.com/c/go/+/335189 Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Alberto Donizetti <alb.donizetti@gmail.com>
2021-07-15cmd/compile: fix lookup package of redeclared dot import symbolCuong Manh Le
The compiler is relying on Sym.Def field to lookup symbol package in DotImportRefs map. But the Sym.Def field is clear whenever the compiler finish processing a file. If the dot import happen in file A, then the redeclaration happen in file B, then the symbol lookup in file B will see a nil Sym.Def, that cause the compiler crashes. To fix this, we can interate over DotImportRefs and check for matching symbol name and return the corresponding package. Though this operation can be slow, but it only happens in invalid program, when printing error message, so it's not worth to optimize it further. Fixes #47201 Change-Id: I4ca1cb0a8e7432b19cf71434592a4cbb58d54adf Reviewed-on: https://go-review.googlesource.com/c/go/+/334589 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>
2021-07-07cmd/compile: remove special-casing of blank in types.sconv{,2}Matthew Dempsky
I'm not sure why blank was special-cased here before, but it's wrong. Blank is a non-exported identifier, and writing it out without package-qualification can result in linker symbol collisions. Fixes #47087. Change-Id: Ie600037c8e54e3d4fdaeec21e2ca212badbd830b Reviewed-on: https://go-review.googlesource.com/c/go/+/333163 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-29cmd/compile: suppress details error for invalid variadic argument typeCuong Manh Le
CL 255241 made error message involving variadic calls clearer. To do it, we added a check that the type of variadic argument must be a slice. That's why the compiler crashes for invalid variadic argument type. Instead, we can just omit the details error message, and report not enough arguments error, which matches the behavior of go/types and types2. Fixes #46957 Change-Id: I638d7e8f031f0ee344d5d802104fd93a60aae00a Reviewed-on: https://go-review.googlesource.com/c/go/+/331569 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>
2021-06-28cmd/compile,runtime: change unsafe.Slice((*T)(nil), 0) to return []T(nil)Matthew Dempsky
This CL removes the unconditional OCHECKNIL check added in walkUnsafeSlice by instead passing it as a pointer to runtime.unsafeslice, and hiding the check behind a `len == 0` check. While here, this CL also implements checkptr functionality for unsafe.Slice and disallows use of unsafe.Slice with //go:notinheap types. Updates #46742. Change-Id: I743a445ac124304a4d7322a7fe089c4a21b9a655 Reviewed-on: https://go-review.googlesource.com/c/go/+/331070 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2021-06-24cmd/compile: fix wrong type in SSA generation for OSLICE2ARRPTRCuong Manh Le
Fixes #46907 Change-Id: I6a2728d2f2159df583b32f40f6100d3e90c34dd7 Reviewed-on: https://go-review.googlesource.com/c/go/+/330672 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-06-16cmd/compile: better error message for invalid untyped operationCuong Manh Le
For typed vs un-typed operation, the compiler do the conversion un-conditionally, so if the operation is invalid, the error report is pointed to the conversion, instead of the invalid operation itself. To fix this, only do the conversion when the operations are valid for both types. Fixes #46749 Change-Id: Ib71c7bcd3ed5454e6df55b6a8db4e0f189259ba7 Reviewed-on: https://go-review.googlesource.com/c/go/+/328050 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>
2021-06-14cmd/compile: rewrite a, b = f() to use temporaries when type not identicalCuong Manh Le
If any of the LHS expressions of an OAS2FUNC are not identical to the respective function call results, escape analysis mishandles the implicit conversion, causes memory corruption. Instead, we should insert autotmps like we already do for f(g()) calls and return g() statements. Fixes #46725 Change-Id: I71a08da0bf1a03d09a023da5b6f78fb37a4a4690 Reviewed-on: https://go-review.googlesource.com/c/go/+/327651 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>
2021-06-13cmd/compile: allow ir.OSLICE2ARRPTR in mayCallCuong Manh Le
CL 301650 adds conversion from slice to array ptr. The conversion expression may appear as argument to a function call, so it will be tested by mayCall. But ir.OSLICE2ARRPTR op is not handled by mayCall, causes the compiler crashes. Updates #395 Fixes #46720 Change-Id: I39e1b3e38e224a31f3dec46dbbdc855ff3b2c6a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/327649 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-06-09cmd/compile: make map.zero symbol content-addressableThan McIntosh
The compiler machinery that generates "map.zero" symbols marks them as RODATA and DUPOK, which is problematic when a given application has multiple map zero symbols (from different packages) with varying sizes: the dupok path in the loader assumes that if two symbols have the same name, it is safe to pick any of the versions. In the case of map.zero, the link needs to select the largest symbol, not an arbitrary sym. To fix this problem, mark map.zero symbols as content-addressable, since the loader's content addressability processing path already supports selection of the larger symbol in cases where there are dups. Fixes #46653. Change-Id: Iabd2feef01d448670ba795c7eaddc48c191ea276 Reviewed-on: https://go-review.googlesource.com/c/go/+/326211 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-06-08cmd/compile: use t.AllMethods when sorting typesByStringCuong Manh Le
For interface types, t.Methods contains only unexpanded method set, i.e exclusive of interface embedding. Thus, we can't use it to detect an interface contains embedding empty interface, like in: type EI interface{} func f() interface{ EI } { return nil } At the time we generate runtime types, we want to check against the full method set of interface instead. Fixes #46386 Change-Id: Idff53ad39276be6632eb5932b76e855c15cbdd2e Reviewed-on: https://go-review.googlesource.com/c/go/+/323649 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>
2021-06-04cmd/compile,go/types: restrict use of unsafe.{Add,Slice} to go1.17 or newerMatthew Dempsky
This CL updates cmd/compile (including types2) and go/types to report errors about using unsafe.Add and unsafe.Slice when language compatibility is set to Go 1.16 or older. Fixes #46525. Change-Id: I1bfe025a672d9f4b929f443064ad1effd38d0363 Reviewed-on: https://go-review.googlesource.com/c/go/+/324369 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com>
2021-05-22cmd/compile: revert CL/316890Than McIntosh
This is a revert of https://go-review.googlesource.com/c/go/+/316890, which has positive effects on debugging + DWARF variable locations for register parameters when the reg abi is in effect, but also turns out to interact badly with the register allocator. Fixes #46304. Change-Id: I624bd980493411a9cde45d44fcd3c46cad796909 Reviewed-on: https://go-review.googlesource.com/c/go/+/321830 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-05-20test: re-enable test on riscv64 now that it supports external linkingJoel Sing
Update #36739 Change-Id: I14ab2cd0e29966b9a2f992e8c3bcb415203e63e6 Reviewed-on: https://go-review.googlesource.com/c/go/+/321449 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-05-19test: check portable error message on issue46234.goCherry Mui
issue46234.go expects an error output "segmentation violation", which is UNIX-specific. Check for "nil pointer dereference" instead, which is emitted by the Go runtime and should work on all platforms. Should fix Windows builders. Change-Id: I3f5a66a687d43cae5eaf6a9e942b877e5a248900 Reviewed-on: https://go-review.googlesource.com/c/go/+/321072 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2021-05-18cmd/compile: don't emit inltree for closure within body of inlined funcThan McIntosh
When inlining functions with closures, ensure that we don't mark the body of the closure with a src.Pos marker that reflects the inline, since this will result in the generation of an inltree table for the closure itself (as opposed to the routine that the func-with-closure was inlined into). Fixes #46234. Change-Id: I348296de6504fc4745d99adab436640f50be299a Reviewed-on: https://go-review.googlesource.com/c/go/+/320913 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Than McIntosh <thanm@google.com>
2021-05-12cmd/compile: add arch-specific inlining for runtime.memmoveRuslan Andreev
This CL add runtime.memmove inlining for AMD64 and ARM64. According to ssa dump from testcases generic rules can't inline memmomve properly due to one of the arguments is Phi operation. But this Phi op will be optimized out by later optimization stages. As a result memmove can be inlined during arch-specific rules. The commit add new optimization rules to arch-specific rules that can inline runtime.memmove if it possible during lowering stage. Optimization fires 5 times in Go source-code using regabi. Fixes #41662 Change-Id: Iaffaf4c482d068b5f0683d141863892202cc8824 Reviewed-on: https://go-review.googlesource.com/c/go/+/289151 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: David Chase <drchase@google.com>
2021-05-08cmd/compile: remove bit operations that modify memory directlyKeith Randall
These operations (BT{S,R,C}{Q,L}modify) are quite a bit slower than other ways of doing the same thing. Without the BTxmodify operations, there are two fallback ways the compiler performs these operations: AND/OR/XOR operations directly on memory, or load-BTx-write sequences. The compiler kinda chooses one arbitrarily depending on rewrite rule application order. Currently, it uses load-BTx-write for the Const benchmarks and AND/OR/XOR directly to memory for the non-Const benchmarks. TBD, someone might investigate which of the two fallback strategies is really better. For now, they are both better than BTx ops. name old time/op new time/op delta BitSet-8 1.09µs ± 2% 0.64µs ± 5% -41.60% (p=0.000 n=9+10) BitClear-8 1.15µs ± 3% 0.68µs ± 6% -41.00% (p=0.000 n=10+10) BitToggle-8 1.18µs ± 4% 0.73µs ± 2% -38.36% (p=0.000 n=10+8) BitSetConst-8 37.0ns ± 7% 25.8ns ± 2% -30.24% (p=0.000 n=10+10) BitClearConst-8 30.7ns ± 2% 25.0ns ±12% -18.46% (p=0.000 n=10+10) BitToggleConst-8 36.9ns ± 1% 23.8ns ± 3% -35.46% (p=0.000 n=9+10) Fixes #45790 Update #45242 Change-Id: Ie33a72dc139f261af82db15d446cd0855afb4e59 Reviewed-on: https://go-review.googlesource.com/c/go/+/318149 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ben Shi <powerman1st@163.com>
2021-05-06cmd/compile: set unsayable "names" for regabi testing triggersDavid Chase
This disables the "testing names" for method names and trailing input types passed to closure/interface/other calls. The logic using the names remains, so that editing the change to enable local testing is not too hard. Also fixes broken build tag in reflect/abi_test.go Updates #44816. Change-Id: I3d222d2473c98d04ab6f1122ede9fea70c994af1 Reviewed-on: https://go-review.googlesource.com/c/go/+/300150 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>
2021-05-05cmd/compile: do not substitute OGOTO inside a closure when inliningCuong Manh Le
The inlsubst already does the same thing for OLABEL, so we must do the same thing for OGOTO. Otherwise, new inlined OGOTO node will be associated with non-existed label. Fixes #45947 Change-Id: I40eef095f57fd3438c38a0b5d9751d5d7ebf759e Reviewed-on: https://go-review.googlesource.com/c/go/+/316931 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Dan Scales <danscales@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
2021-05-05cmd/compile: handle degenerate entry blocks in -N debug genThan McIntosh
The code that created DWARF debug var locations for input parameters in the non-optimized case for regabi was not doing the right thing for degenerate functions with infinite loops. Detect these cases and don't try to emit the normal location data. Fixes #45948. Change-Id: I2717fc4bac2e03d5d850a6ec8a09ed05fed0c896 Reviewed-on: https://go-review.googlesource.com/c/go/+/316752 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-05-03cmd/compile: make the stack allocator more careful about register args.David Chase
Assignment between input parameters causes them to have more than one "Name", and running this backwards from names to values can end up confusing (conflating) parameter spill slots. Around 105a6e9518, this cases a stack overflow running go test -race encoding/pem because two slice parameters spill (incorrectly) into the same stack slots (in the AB?I-defined parameter spill area). This also tickles a failure in cue, which turned out to be easier to isolate. Fixes #45851. Updates #40724. Change-Id: I39c56815bd6abb652f1ccbe83c47f4f373a125c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/313212 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>
2021-05-03cmd/compile: make typecheckaste correctly report invalid use of "..."Cuong Manh Le
Currently, when "..." argument is passed to non-variadic function, the compiler may skip that check, but continue checking whether the number of arguments matches the function signature. That causes the sanity check which was added in CL 255241 trigger. Instead, we should report an invalid use of "...", which matches the behavior of new type checker and go/types. Fixes #45913 Change-Id: Icbb254052cbcd756bbd41f966c2c8e316c44420f Reviewed-on: https://go-review.googlesource.com/c/go/+/315796 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>
2021-05-02cmd/compile: implement unsafe.Add and unsafe.SliceMatthew Dempsky
Updates #19367. Updates #40481. Change-Id: Iabd2afdd0d520e5d68fd9e6dedd013335a4b3886 Reviewed-on: https://go-review.googlesource.com/c/go/+/312214 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Trust: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org>
2021-04-28cmd/compile: use desired register only if it satisfies register maskCherry Zhang
In the register allocator, if possible, we allocate a value to its desired register (the ideal register for its next use). In some cases the desired register does not satisfies the value's output register mask. We should not use the register in this case. In the following example, v33 is going to be returned as a function result, so it is allocated to its desired register AX. However, its Op cannot use AX as output, causing miscompilation. v33 = CMOVQEQF <int> v24 v28 v29 : AX (~R0[int]) v35 = MakeResult <int,int,mem> v33 v26 v18 Ret v35 Change-Id: Id0f4f27c4b233ee297e83077e3c8494fe193e664 Reviewed-on: https://go-review.googlesource.com/c/go/+/314630 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-28test: do not run fuse test in noopt modeCherry Zhang
Change-Id: Iad8ac2253ce28fd0a331bde36836d1b7f25797bd Reviewed-on: https://go-review.googlesource.com/c/go/+/314632 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-04-28cmd/compile/ssa: optimize the derivable known branch of If blockeric fang
When the control value of a If block is known for a particular inbound edge because its value can be inferred from the control value of its predecessor, then this inbound edge can be redirected to the known successor directly, This CL optimizes this kind of cases to eliminate unnecessary comparision. For example, the following piece of code comes from runtime.atoi, if !neg && un > uint(maxInt) { return 0, false } if neg && un > uint(maxInt)+1 { return 0, false } Before this optimization, if the first "if" statement does not return, both conditions of the second "if" statement will be checked. But obviously the value of neg is known through the first "if" statement, and there is no need to check neg repeatedly. After this optimization, this redundancy check is eliminated, and the execution logic becomes as follows. if !neg { if un > uint(maxInt) { return 0, false } } else { if un > uint(maxInt)+1 { return 0, false } } This CL does not bring significant performance changes, but it makes the code structure look more reasonable. Statistical data from tool compilecmp on Linux/amd64: name old time/op new time/op delta Template 380ms ± 4% 385ms ± 3% +1.16% (p=0.000 n=50+49) Unicode 168ms ± 9% 169ms ± 9% ~ (p=0.421 n=49+46) GoTypes 1.99s ± 4% 2.02s ± 4% +1.48% (p=0.000 n=49+49) Compiler 188ms ± 8% 188ms ± 9% ~ (p=0.997 n=49+50) SSA 11.8s ± 2% 12.0s ± 2% +1.24% (p=0.000 n=48+50) Flate 242ms ± 6% 244ms ± 9% ~ (p=0.307 n=46+49) GoParser 361ms ± 3% 366ms ± 4% +1.23% (p=0.000 n=48+49) Reflect 836ms ± 3% 842ms ± 3% +0.70% (p=0.004 n=48+48) Tar 335ms ± 3% 340ms ± 4% +1.47% (p=0.000 n=49+46) XML 432ms ± 4% 437ms ± 4% +1.11% (p=0.002 n=49+49) LinkCompiler 701ms ± 4% 704ms ± 5% ~ (p=0.278 n=49+50) ExternalLinkCompiler 1.83s ± 3% 1.84s ± 3% +0.51% (p=0.034 n=48+49) LinkWithoutDebugCompiler 436ms ± 6% 438ms ± 6% ~ (p=0.419 n=48+49) [Geo mean] 612ms 617ms +0.84% name old alloc/op new alloc/op delta Template 38.7MB ± 1% 39.1MB ± 1% +1.19% (p=0.000 n=50+50) Unicode 28.1MB ± 0% 28.1MB ± 0% +0.20% (p=0.000 n=49+45) GoTypes 168MB ± 1% 170MB ± 1% +1.05% (p=0.000 n=48+49) Compiler 23.0MB ± 1% 23.1MB ± 1% +0.63% (p=0.000 n=50+50) SSA 1.54GB ± 1% 1.55GB ± 1% +0.85% (p=0.000 n=50+50) Flate 23.6MB ± 1% 23.9MB ± 1% +1.36% (p=0.000 n=43+46) GoParser 35.0MB ± 1% 35.3MB ± 1% +0.94% (p=0.000 n=50+50) Reflect 84.7MB ± 1% 86.1MB ± 1% +1.72% (p=0.000 n=49+49) Tar 34.5MB ± 1% 34.9MB ± 1% +1.07% (p=0.000 n=47+48) XML 44.2MB ± 3% 44.6MB ± 3% +0.70% (p=0.003 n=50+49) LinkCompiler 128MB ± 0% 128MB ± 0% +0.01% (p=0.004 n=49+50) ExternalLinkCompiler 120MB ± 0% 120MB ± 0% +0.01% (p=0.000 n=49+50) LinkWithoutDebugCompiler 77.3MB ± 0% 77.3MB ± 0% +0.02% (p=0.000 n=50+50) [Geo mean] 69.1MB 69.6MB +0.75% file before after Δ % addr2line 4049276 4051308 +2032 +0.050% api 5248940 5248996 +56 +0.001% asm 4868093 4868037 -56 -0.001% buildid 2627666 2626026 -1640 -0.062% cgo 4614432 4615040 +608 +0.013% compile 23298888 23301267 +2379 +0.010% cover 4591609 4591161 -448 -0.010% dist 3449638 3450254 +616 +0.018% doc 3925667 3926363 +696 +0.018% fix 3322936 3323464 +528 +0.016% link 6628632 6629560 +928 +0.014% nm 3991753 3996497 +4744 +0.119% objdump 4396119 4395615 -504 -0.011% pack 2399719 2399535 -184 -0.008% pprof 13616418 13622866 +6448 +0.047% test2json 2646121 2646081 -40 -0.002% trace 10233087 10226359 -6728 -0.066% vet 7117994 7121066 +3072 +0.043% total 111026988 111039495 +12507 +0.011% On linux arm64: name old time/op new time/op delta Template 284ms ± 1% 286ms ± 1% +0.70% (p=0.000 n=49+50) Unicode 125ms ± 3% 125ms ± 2% ~ (p=0.548 n=50+50) GoTypes 1.69s ± 1% 1.71s ± 1% +1.02% (p=0.000 n=49+49) Compiler 125ms ± 1% 124ms ± 2% -0.35% (p=0.020 n=50+50) SSA 12.7s ± 1% 12.8s ± 1% +1.21% (p=0.000 n=49+49) Flate 172ms ± 1% 173ms ± 1% +0.20% (p=0.047 n=50+50) GoParser 265ms ± 1% 266ms ± 1% +0.64% (p=0.000 n=50+50) Reflect 651ms ± 1% 650ms ± 1% ~ (p=0.079 n=48+48) Tar 246ms ± 1% 246ms ± 1% ~ (p=0.202 n=50+46) XML 328ms ± 1% 332ms ± 1% +1.28% (p=0.000 n=50+49) LinkCompiler 600ms ± 1% 599ms ± 1% ~ (p=0.264 n=50+50) ExternalLinkCompiler 1.88s ± 1% 1.90s ± 0% +1.36% (p=0.000 n=50+50) LinkWithoutDebugCompiler 365ms ± 1% 365ms ± 1% ~ (p=0.602 n=50+46) [Geo mean] 490ms 492ms +0.47% name old alloc/op new alloc/op delta Template 38.8MB ± 1% 39.1MB ± 1% +0.92% (p=0.000 n=44+42) Unicode 28.4MB ± 0% 28.4MB ± 0% +0.22% (p=0.000 n=44+45) GoTypes 169MB ± 1% 171MB ± 1% +1.12% (p=0.000 n=50+50) Compiler 23.2MB ± 1% 23.3MB ± 1% +0.56% (p=0.000 n=42+43) SSA 1.55GB ± 0% 1.56GB ± 0% +0.91% (p=0.000 n=48+49) Flate 23.7MB ± 2% 24.0MB ± 1% +1.20% (p=0.000 n=50+50) GoParser 35.3MB ± 1% 35.6MB ± 1% +0.88% (p=0.000 n=50+50) Reflect 85.0MB ± 0% 86.5MB ± 0% +1.70% (p=0.000 n=49+48) Tar 34.5MB ± 1% 34.9MB ± 1% +1.03% (p=0.000 n=47+50) XML 43.8MB ± 2% 44.0MB ± 0% +0.41% (p=0.002 n=49+38) LinkCompiler 136MB ± 0% 136MB ± 0% +0.01% (p=0.006 n=50+49) ExternalLinkCompiler 127MB ± 0% 127MB ± 0% +0.02% (p=0.000 n=49+50) LinkWithoutDebugCompiler 84.1MB ± 0% 84.1MB ± 0% ~ (p=0.534 n=50+50) [Geo mean] 70.4MB 70.9MB +0.69% file before after Δ % addr2line 4006004 4004556 -1448 -0.036% api 5029716 5028828 -888 -0.018% asm 4936863 4934943 -1920 -0.039% buildid 2594947 2594099 -848 -0.033% cgo 4399702 4399502 -200 -0.005% compile 22233139 22230486 -2653 -0.012% cover 4443681 4443881 +200 +0.005% dist 3365902 3365486 -416 -0.012% doc 3776175 3776151 -24 -0.001% fix 3218624 3218600 -24 -0.001% link 6365001 6361409 -3592 -0.056% nm 3923345 3923065 -280 -0.007% objdump 4295473 4296673 +1200 +0.028% pack 2390561 2389393 -1168 -0.049% pprof 12866419 12865115 -1304 -0.010% test2json 2587113 2585561 -1552 -0.060% trace 9609814 9610846 +1032 +0.011% vet 6790272 6789760 -512 -0.008% total 106832751 106818354 -14397 -0.013% Update: #37608 Change-Id: I2831238b12e3af5aef2261f64f804bf0a8b43f86 Reviewed-on: https://go-review.googlesource.com/c/go/+/244737 Reviewed-by: eric fang <eric.fang@arm.com> Reviewed-by: Keith Randall <khr@golang.org> Trust: eric fang <eric.fang@arm.com> Run-TryBot: eric fang <eric.fang@arm.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-04-28cmd/compile: fix typechecking logical operators panic with non-boolean operandCuong Manh Le
In CL 255899, we added code to make clearer error when non-bool used as operand to logical operators. The code is safe, because node type is guaranteed to be non-nil. In CL 279442, we refactored typechecking arith, including moving typechecking logical operators to separate case. Now we have to explicitly check if operand type is not nil, because calling Expr can set operand type nil for non-bool operands. Fixes #45804 Change-Id: Ie2b6e18f65c0614a803b343f60e78ee1d660bbeb Reviewed-on: https://go-review.googlesource.com/c/go/+/314209 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>
2021-04-27cmd/compile: fix nongeneric closures in generic functionsKeith Randall
Ensure that formal parameter Names are correctly copied and marked with the correct Curfn. We need to ensure this even when the underlying closure has no type parameters. (Aside: it is strange that the types of things contain formal parameter names that need to be copied. Maybe that's an underlying larger problem that needs to be fixed.) Fixes #45738 Change-Id: Ia13d69eea992ff7080bd44065115bc52eb624e73 Reviewed-on: https://go-review.googlesource.com/c/go/+/313652 Trust: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
2021-04-27cmd/compile: fix handling of ir.CurFunc during stencilingDan Scales
The transform functions (specifically transformArgs, which is used from transformCall/transformReturn) require that ir.CurFunc is set correctly. Since transformCall() is used on the call of an instantiated generic function, we need to set ir.CurFunc correctly in stencil(). Also, correctly save/restore ir.CurFunc in genericSubst(). Without this fix, ir.CurFunc can be nil when we call TransformCall() from stencil(), which leads to some temp variables being added incorrectly to ir.TodoFunc (which leads to the fatal panic in the issue). Fixes #45722 Change-Id: Iddf4a67d28f2100dde8cde5dbc9ca1e00dad6089 Reviewed-on: https://go-review.googlesource.com/c/go/+/313869 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
2021-04-27cmd/compile: fix wrong package path for unsafe.PointerCuong Manh Le
It's not a predeclared type, but a type defined in "unsafe" package. Fixes #44830 Change-Id: If39815b1070059b608be8231dfac9b7f3307cb15 Reviewed-on: https://go-review.googlesource.com/c/go/+/313349 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>
2021-04-26cmd/compile: workaround inlining of closures with type switchesMatthew Dempsky
Within clovar, n.Defn can also be *ir.TypeSwitchGuard. The proper fix here would be to populate m.Defn and have it filled in too, but we already leave it nil in inlvar. So for consistency, this CL does the same in clovar too. Eventually inl.go should be rewritten to fully respect IR invariants. Fixes #45743. Change-Id: I8b38e5d8b2329ad242de97670f2141f713954d28 Reviewed-on: https://go-review.googlesource.com/c/go/+/313289 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Trust: Dan Scales <danscales@google.com> Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-04-23cmd/compile: generalize fix for lvalue-init evaluationMatthew Dempsky
The previous fix to ensure early evaluation of lvalue-init statements (CL 312632) added it after we'd already peeled away any array-OINDEX expressions. But those might have init statements too, so we need to do this earlier actually and perhaps more than once. Longer term, lvalue expressions shouldn't have init statements anyway. But rsc and I both spent a while looking into this earlier in the dev cycle and couldn't come up with anything reasonable. Fixes #45706. Change-Id: I2d19c5ba421b3f019c62eec45774c84cf04b30ef Reviewed-on: https://go-review.googlesource.com/c/go/+/313011 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-23cmd/compile: make sure ascompatee walk lhs init statementsCuong Manh Le
CL 281152 improved ascompatee by removing the call to safeExpr on lhs. But we forgot that lhs int statements, if any, must be walked prior saving subexpressions, which cause the bug in #45706. Fixes #45706 Change-Id: I0064315056ef4ca92ebf3c332c2e3a9bb2b26f68 Reviewed-on: https://go-review.googlesource.com/c/go/+/312632 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>
2021-04-23cmd/compile: set correct Defn for inlined varsCuong Manh Le
Currently, when copying definition node of an inlined var, we do not update var Defn field to point to new copied node. That causes all inlined vars point to the same Defn, and ir.StaticValue can not find inlined var in the lhs of its definition. clovar creates new ONAME node for local variables or params of closure inside inlined function, by copying most of the old node fields. So the new Node.Defn is not modified, its lhs still refer to old node instead of new one. To fix this, we need to do two things: - In subst.clovar, set a dummy Defn node for inlvar - During subst.node, when seeing OAS/OAS2 nodes, after substituting, we check if any node in lhs has the dummy Defn, then set it to the current OAS/OAS2 node. Fixes #45606 Change-Id: Ib517b753a7643756dcd61d36deae60f1a0fc53c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/312630 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>