aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2021-12-02[release-branch.go1.16] 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 #49391 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/+/361597 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2021-10-27[release-branch.go1.16] 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 #48478 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/+/351070 Reviewed-by: Austin Clements <austin@google.com>
2021-10-27[release-branch.go1.16] cmd/compile: fix simplification rules on arm/arm64Keith Randall
Fixes #48474 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/+/351072 Reviewed-by: Austin Clements <austin@google.com>
2021-08-02[release-branch.go1.16] cmd/{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 #47289. 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> (cherry picked from commit 49402bee36fd3d5cee9f4b2d2e1e8560ead0203b) Reviewed-on: https://go-review.googlesource.com/c/go/+/335629
2021-06-29[release-branch.go1.16] cmd/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 #46657. 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> (cherry picked from commit aa5540cd82170f82c6fe11511e12de96aa58cbc1) Reviewed-on: https://go-review.googlesource.com/c/go/+/326212 Run-TryBot: Cherry Mui <cherryyz@google.com>
2021-03-31[release-branch.go1.16] cmd/compile: fix long RMW bit operations on AMD64Pat Gavlin
Under certain circumstances, the existing rules for bit operations can produce code that writes beyond its intended bounds. For example, consider the following code: func repro(b []byte, addr, bit int32) { _ = b[3] v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 | 1<<(bit&31) b[0] = byte(v) b[1] = byte(v >> 8) b[2] = byte(v >> 16) b[3] = byte(v >> 24) } Roughly speaking: 1. The expression `1 << (bit & 31)` is rewritten into `(SHLL 1 bit)` 2. The expression `uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24` is rewritten into `(MOVLload &b[0])` 3. The statements `b[0] = byte(v) ... b[3] = byte(v >> 24)` are rewritten into `(MOVLstore &b[0], v)` 4. `(ORL (SHLL 1, bit) (MOVLload &b[0]))` is rewritten into `(BTSL (MOVLload &b[0]) bit)`. This is a valid transformation because the destination is a register: in this case, the bit offset is masked by the number of bits in the destination register. This is identical to the masking performed by `SHL`. 5. `(MOVLstore &b[0] (BTSL (MOVLload &b[0]) bit))` is rewritten into `(BTSLmodify &b[0] bit)`. This is an invalid transformation because the destination is memory: in this case, the bit offset is not masked, and the chosen instruction may write outside its intended 32-bit location. These changes fix the invalid rewrite performed in step (5) by explicitly maksing the bit offset operand to `BT(S|R|C)(L|Q)modify`. In the example above, the adjusted rules produce `(BTSLmodify &b[0] (ANDLconst [31] bit))` in step (5). These changes also add several new rules to rewrite bit sets, toggles, and clears that are rooted at `(OR|XOR|AND)(L|Q)modify` operators into appropriate `BT(S|R|C)(L|Q)modify` operators. These rules catch cases where `MOV(L|Q)store ((OR|XOR|AND)(L|Q) ...)` is rewritten to `(OR|XOR|AND)(L|Q)modify` before the `(OR|XOR|AND)(L|Q) ...` can be rewritten to `BT(S|R|C)(L|Q) ...`. Overall, compilecmp reports small improvements in code size on darwin/amd64 when the changes to the compiler itself are exlcuded: file before after Δ % runtime.s 536464 536412 -52 -0.010% bytes.s 32629 32593 -36 -0.110% strings.s 44565 44529 -36 -0.081% os/signal.s 7967 7959 -8 -0.100% cmd/vendor/golang.org/x/sys/unix.s 81686 81678 -8 -0.010% math/big.s 188235 188253 +18 +0.010% cmd/link/internal/loader.s 89295 89056 -239 -0.268% cmd/link/internal/ld.s 633551 633232 -319 -0.050% cmd/link/internal/arm.s 18934 18928 -6 -0.032% cmd/link/internal/arm64.s 31814 31801 -13 -0.041% cmd/link/internal/riscv64.s 7347 7345 -2 -0.027% cmd/compile/internal/ssa.s 4029173 4033066 +3893 +0.097% total 21298280 21301472 +3192 +0.015% Fixes #45253 Change-Id: I2e560548b515865129e1724e150e30540e9d29ce GitHub-Last-Rev: ab94ede1d097f920a9d1d3da403c8e4a3d8f6d44 GitHub-Pull-Request: golang/go#45242 Reviewed-on: https://go-review.googlesource.com/c/go/+/305069 Trust: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2021-03-31[release-branch.go1.16] cmd/compile: disable shortcircuit optimization for ↵Keith Randall
intertwined phi values We need to be careful that when doing value graph surgery, we not re-substitute a value that has already been substituted. That can lead to confusing a previous iteration's value with the current iteration's value. The simple fix in this CL just aborts the optimization if it detects intertwined phis (a phi which is the argument to another phi). It might be possible to keep the optimization with a more complicated CL, but: 1) This CL is clearly safe to backport. 2) There were no instances of this abort triggering in all.bash, prior to the test introduced in this CL. Fixes #45192 Change-Id: I2411dca03948653c053291f6829a76bec0c32330 Reviewed-on: https://go-review.googlesource.com/c/go/+/304251 Trust: Keith Randall <khr@golang.org> Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> (cherry picked from commit 771c57e68ed5ef2bbb0eafc0d48419f59d143932) Reviewed-on: https://go-review.googlesource.com/c/go/+/304530
2021-03-01[release-branch.go1.16] cmd/compile: fix escape analysis of heap-allocated ↵Matthew Dempsky
results One of escape analysis's responsibilities is to summarize whether/how each function parameter flows to the heap so we can correctly incorporate those flows into callers' escape analysis data flow graphs. As an optimization, we separately record when parameters flow to result parameters, so that we can more precisely analyze parameter flows based on how the results are used at the call site. However, if a named result parameter itself needs to be heap allocated, this optimization isn't safe and the parameter needs to be recorded as flowing to heap rather than flowing to result. Escape analysis used to get this correct because it conservatively rewalked the data-flow graph multiple times. So even though it would incorrectly record the result parameter flow, it would separately find a flow to the heap. However, CL 196811 (specifically, case 3) optimized the walking logic to reduce unnecessary rewalks causing us to stop finding the extra heap flow. This CL fixes the issue by correcting location.leakTo to be sensitive to sink.escapes and not record result-flows when the result parameter escapes to the heap. Fixes #44659. Change-Id: I48742ed35a6cab591094e2d23a439e205bd65c50 Reviewed-on: https://go-review.googlesource.com/c/go/+/297289 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-on: https://go-review.googlesource.com/c/go/+/297290
2021-03-01[release-branch.go1.16] cmd/compile: fix mishandling of unsafe-uintptr ↵Cuong Manh Le
arguments with call method in go/defer In CL 253457, we did the same fix for direct function calls. But for method calls, the receiver argument also need to be passed through the wrapper function, which we are not doing so the compiler crashes with the code in #44415. It will be nicer if we can rewrite OCALLMETHOD to normal OCALLFUNC, but that will be for future CL. The passing receiver argument to wrapper function is easier for backporting to go1.16 branch. Fixes #44464 Change-Id: I03607a64429042c6066ce673931db9769deb3124 Reviewed-on: https://go-review.googlesource.com/c/go/+/296490 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> Reviewed-on: https://go-review.googlesource.com/c/go/+/296769 Trust: Bryan C. Mills <bcmills@google.com>
2021-03-01[release-branch.go1.16] cmd/compile: fix panic in DWARF-gen handling ↵Than McIntosh
obfuscated code DWARF generation uses variable source positions (file/line/col) as a way to uniquely identify locals and parameters, as part of the process of matching up post-optimization variables with the corresponding pre-optimization versions (since the DWARF needs to be in terms of the original source constructs). This strategy can run into problems when compiling obfuscated or machine-generated code, where you can in some circumstances wind up with two local variables that appear to have the same name, file, line, and column. This patch changes DWARF generation to skip over such duplicates as opposed to issuing a fatal error (if an obfuscation tool is in use, it is unlikely that a human being will be able to make much sense of DWARF info in any case). Fixes #44433. Change-Id: I198022d184701aa9ec3dce42c005d29b72d2e321 Reviewed-on: https://go-review.googlesource.com/c/go/+/294289 TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> (cherry picked from commit e78e04ce39b9df316edda08f43f253f5e9ac509e) Reviewed-on: https://go-review.googlesource.com/c/go/+/294789
2021-03-01[release-branch.go1.16] cmd/compile: declare inlined result params early for ↵Matthew Dempsky
empty returns The code for delayed declaration of inlined result parameters only handles non-empty return statements. This is generally okay, because we already early declare if there are any (non-blank) named result parameters. But if a user writes a function with only blank result parameters and with exactly one return statement, which is empty, then they could end up hitting the dreaded "Value live at entry" ICE. This CL fixes the issue by ensuring we always early declare inlined result parameters if there are any empty return statements. Fixes #44358. Change-Id: I315f3853be436452883b1ce31da1bdffdf24d506 Reviewed-on: https://go-review.googlesource.com/c/go/+/293293 TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/296569
2021-02-10cmd/compile: mark concrete call of reflect.(*rtype).Method as REFLECTMETHODCherry Zhang
For functions that call reflect.Type.Method (or MethodByName), we mark it as REFLECTMETHOD, which tells the linker that methods can be retrieved via reflection and the linker keeps all exported methods live. Currently, this marking expects exactly the interface call reflect.Type.Method (or MethodByName). But now the compiler can devirtualize that call to a concrete call reflect.(*rtype).Method (or MethodByName), which is not handled and causing the linker to discard methods too aggressively. Handle the latter in this CL. Fixes #44207. Change-Id: Ia4060472dbff6ab6a83d2ca8e60a3e3f180ee832 Reviewed-on: https://go-review.googlesource.com/c/go/+/290950 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-02-01test: fix incorrectly laid out instructions in issue11656.goTom Thorogood
CL 279423 introduced a regression in this test as it incorrectly laid out various instructions. In the case of arm, the second instruction was overwriting the first. In the case of 386, amd64 and s390x, the instructions were being appended to the end of the slice after 64 zero bytes. This was causing test failures on "linux/s390x on z13". Fixes #44028 Change-Id: Id136212dabdae27db7e91904b0df6a3a9d2f4af4 Reviewed-on: https://go-review.googlesource.com/c/go/+/288278 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-01-25cmd/compile: fix order-of-assignment issue w/ defersMatthew Dempsky
CL 261677 fixed a logic issue in walk's alias detection, where it was checking the RHS expression instead of the LHS expression when trying to determine the kind of assignment. However, correcting this exposed a latent issue with assigning to result parameters in functions with defers, where an assignment could become visible earlier than intended if a later expression could panic. Fixes #43835. Change-Id: I061ced125e3896e26d65f45b28c99db2c8a74a8c Reviewed-on: https://go-review.googlesource.com/c/go/+/285633 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> Trust: Matthew Dempsky <mdempsky@google.com>
2021-01-19cmd/compile: require 'go 1.16' go.mod line for //go:embedRuss Cox
This will produce better errors when earlier versions of Go compile code using //go:embed. (The import will cause a compilation error but then the go command will add to the output that the Go toolchain in use looks too old and maybe that's the problem.) This CL also adds a test for disallowing embed of a var inside a func. It's a bit too difficult to rebase down into that CL. The build system configuration check is delayed in order to make it possible to use errorcheck for these tests. Change-Id: I12ece4ff2d8d53380b63f54866e8f3497657d54c Reviewed-on: https://go-review.googlesource.com/c/go/+/282718 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-01-14cmd/compile: fix wrong complement for arm64 floating-point comparisonsJunchen Li
Consider the following example, func test(a, b float64, x uint64) uint64 { if a < b { x = 0 } return x } func main() { fmt.Println(test(1, math.NaN(), 123)) } The output is 0, but the expectation is 123. This is because the rewrite rule (CSEL [cc] (MOVDconst [0]) y flag) => (CSEL0 [arm64Negate(cc)] y flag) converts FCMP NaN, 1 CSEL MI, 0, 123, R0 // if 1 < NaN then R0 = 0 else R0 = 123 to FCMP NaN, 1 CSEL GE, 123, 0, R0 // if 1 >= NaN then R0 = 123 else R0 = 0 But both 1 < NaN and 1 >= NaN are false. So the output is 0, not 123. The root cause is arm64Negate not handle negation of floating comparison correctly. According to the ARM manual, the meaning of MI, GE, and PL are MI: Less than GE: Greater than or equal to PL: Greater than, equal to, or unordered Because NaN cannot be compared with other numbers, the result of such comparison is unordered. So when NaN is involved, unlike integer, the result of !(a < b) is not a >= b, it is a >= b || a is NaN || b is NaN. This is exactly what PL means. We add NotLessThanF to represent PL. Then the negation of LessThanF is NotLessThanF rather than GreaterEqualF. The same reason for the other floating comparison operations. Fixes #43619 Change-Id: Ia511b0027ad067436bace9fbfd261dbeaae01bcd Reviewed-on: https://go-review.googlesource.com/c/go/+/283572 Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Keith Randall <khr@golang.org>
2021-01-08cmd/compile: fix exponential-time init-cycle reportingRuss Cox
I have a real 7,000-line Go program (not so big) that took over two minutes to report a trivial init cycle. I thought the compiler was in an infinite loop but it was actually just very slow. CL 170062 rewrote init cycle reporting but replaced a linear-time algorithm with an exponential one: it explores all paths through the call graph of functions involved in the cycle. The net effect was that Go 1.12 took 0.25 seconds to load, typecheck, and then diagnose the cycle in my program, while Go 1.13 takes 600X longer. This CL makes the new reporting code run in linear time, restoring the speed of Go 1.12 but preserving the semantic fixes from CL 170062. Change-Id: I7d6dc95676d577d9b96f5953b516a64db93249bf Reviewed-on: https://go-review.googlesource.com/c/go/+/282314 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-08test: fix timeout code for invoking compilerRuss Cox
When running go tool compile, go tool is running compile as a subprocess. Killing go tool with Process.Kill leaves the subprocess behind. Send an interrupt signal first, which it can forward on to the compile subprocess. Also report the timeout in errorcheck -t. Change-Id: I7ae0029bbe543ed7e60e0fea790dd0739d10bcaa Reviewed-on: https://go-review.googlesource.com/c/go/+/282313 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-08cmd/compile: don't short-circuit copies whose source is volatileKeith Randall
Current optimization: When we copy a->b and then b->c, we might as well copy a->c instead of b->c (then b might be dead and go away). *Except* if a is a volatile location (might be clobbered by a call). In that case, we really do want to copy a immediately, because there might be a call before we can do the a->c copy. User calls can't happen in between, because the rule matches up the memory states. But calls inserted for memory barriers, particularly runtime.typedmemmove, can. (I guess we could introduce a register-calling-convention version of runtime.typedmemmove, but that seems a bigger change than this one.) Fixes #43570 Change-Id: Ifa518bb1a6f3a8dd46c352d4fd54ea9713b3eb1a Reviewed-on: https://go-review.googlesource.com/c/go/+/282492 Trust: Keith Randall <khr@golang.org> Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-01-07cmd/compile: fix late expand_calls leaf type for OpStructSelect/OpArraySelectCuong Manh Le
For the example in #43551, before late call expansion, the OpArg type is decomposed to int64. But the late call expansion is currently decompose it to "x.Key" instead. This CL make expand_calls decompose further for struct { 1-field type } and array [1]elem. This matches the previous rules for early decompose args: (StructSelect (StructMake1 x)) => x (ArraySelect (ArrayMake1 x)) => x Fixes #43551 Change-Id: I2f1ebe18cb81cb967f494331c3d237535d2859e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/282332 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>
2020-12-22test: trigger SIGSEGV instead of SIGTRAP in issue11656.goCherry Zhang
In issue11656.go, it tests that if the runtime can get a reasonable traceback when it faults at a non-function PC. It does it by jumping to an address that contains an illegal or trap instruction. When it traps, the SIGTRAP crashes the runtime. This CL changes it to use an instruction that triggers SIGSEGV. This is due to two reasons: - currently, the handling of bad PC is done by preparePanic, which is only used for a panicking signal (SIGSEGV, SIGBUS, SIGFPE), not a fatal signal (e.g. SIGTRAP). - the test uses defer+recover to get a traceback, which only works for panicking signals, not fatal signals. Ideally, we should handle all kinds of faults (SIGSEGV, SIGBUS, SIGILL, SIGTRAP, etc.) with a nice traceback. I'll leave this for the future. This CL also adds RISCV64 support. Fixes #43283. Change-Id: I5e0fbf8530cc89d16e05c3257d282bc1d4d03405 Reviewed-on: https://go-review.googlesource.com/c/go/+/279423 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-21test: skip issue11656.go on mips/mips64/ppc64Ian Lance Taylor
For #11656 For #43283 Change-Id: I1fcf2b24800f421e36201af43130b487abe605b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/279312 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2020-12-20cmd/compile: recognize reassignments involving receivesMatthew Dempsky
Previously, reassigned was failing to detect reassignments due to channel receives in select statements (OSELRECV, OSELRECV2), or due to standalone 2-value receive assignments (OAS2RECV). This was reported as a devirtualization panic, but could have caused mis-inlining as well. Fixes #43292. Change-Id: Ic8079c20c0587aeacff9596697fdeba80a697b12 Reviewed-on: https://go-review.googlesource.com/c/go/+/279352 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
2020-12-19test: for issue11656 try to execute trap, not call itIan Lance Taylor
The issue11656 code was using the trap instruction as a PC value, but it is intended to call a PC value that contains the trap instruction. It doesn't matter too much as in practice the address is not executable anyhow. But may as well have the code act the way it is documented to act. Also, don't run the test with gccgo/GoLLVM, as it can't work. The illegal instruction will have no unwind data, so the unwinder won't be able to get past it. In other words, gccgo/GoLLVM suffer from the exact problem that the issue describes, but it seems insoluble. For golang/go#11656 Change-Id: Ib2e50ffc91d215fd50e78f742fafe476c92d704e Reviewed-on: https://go-review.googlesource.com/c/go/+/278473 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-18test: permit "exponent too large" errorIan Lance Taylor
The language spec only requires a signed binary exponent of 16 bits for floating point constants. Permit a "exponent too large" error for larger exponents. Don't run test 11326b with gccgo, as it requires successful compilation of floating point constants with exponents that don't fit in 16 bits. Change-Id: I98688160c76864aba525a151a14aaaf86bc36a6f Reviewed-on: https://go-review.googlesource.com/c/go/+/279252 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2020-12-18test: recognize and use gc build tagIan Lance Taylor
Change the run.go driver to recognize the "gc" build tag. Change existing tests to use the "gc" build tag if they use some feature that seems specific to the gc compiler, such as passing specific options to or expecting specific behavior from "go tool compile". Change tests to use the "!gccgo" build tag if they use "go build" or "go run", as while those might work with compilers other than gc, they won't work with the way that gccgo runs its testsuite (which happens independently of the go command). For #43252 Change-Id: I666e04b6d7255a77dfc256ee304094e3a6bb15ad Reviewed-on: https://go-review.googlesource.com/c/go/+/279052 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-15test: update for gofrontend error message changesIan Lance Taylor
fixedbugs/bug195.go:9:20: error: interface contains embedded non-interface fixedbugs/bug195.go:12:20: error: interface contains embedded non-interface fixedbugs/bug195.go:15:22: error: interface contains embedded non-interface fixedbugs/bug195.go:18:9: error: invalid recursive interface fixedbugs/bug195.go:26:9: error: invalid recursive interface fixedbugs/bug251.go:15:9: error: invalid recursive interface fixedbugs/issue23823.go:15:9: error: invalid recursive interface Change-Id: If4c22430557459d5b361beda7168f8cb42b58811 Reviewed-on: https://go-review.googlesource.com/c/go/+/278512 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2020-12-15test: match gofrontend error messagesIan Lance Taylor
fixedbugs/issue11614.go:14:9: error: interface contains embedded non-interface fixedbugs/issue11614.go:22:20: error: interface contains embedded non-interface Change-Id: Ie9875916697833f5fa28ab890218851a741120ac Reviewed-on: https://go-review.googlesource.com/c/go/+/278175 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-15test: only require issue11674 errors with gc compilerIan Lance Taylor
The gofrontend code sees that the denominator is not zero, so it computes the values. Dividing zero by a non-zero value produces zero. The language spec doesn't require any of these cases to report an error, so make the errors compiler-specific. Change-Id: I5ed759a3121e38b937744d32250adcbdf2c4d3c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/278117 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-12-15test: remove bug429 (duplicates runtime.TestSimpleDeadlock)Ian Lance Taylor
The bug429 tests is an exact duplicate of TestSimpleDeadlock in the runtime package. The runtime package is the right place for this test, and the version in the runtime package will run faster as the build step is combined with other runtime package tests. Change-Id: I6538d24e6df8e8c5e3e399d3ff37d68f3e52be56 Reviewed-on: https://go-review.googlesource.com/c/go/+/278173 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-15test: adjust issue11371 to fit in required precisionIan Lance Taylor
The language spec only requires that floating point values be represented with 256 bits, which is about 1e75. The issue11371 test was assuming that the compiler could represent 1e100. Adjusting the test so that it only assumes 256 bits of precision still keeps the test valid, and permits it to pass when using the gofrontend. Change-Id: I9d1006e9adc9438277f4b8002488c912e5d61cc1 Reviewed-on: https://go-review.googlesource.com/c/go/+/278116 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-15test: only check for issue11362 error with gcIan Lance Taylor
With the gc compiler the import path implies the package path, so keeping a canonical path is important. With the gofrontend this is not the case, so we don't need to report this as a bug. Change-Id: I245e34f9b66383bd17e79438d4b002a3e20aa994 Reviewed-on: https://go-review.googlesource.com/c/go/+/278115 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-15test: import file name for issue19028Ian Lance Taylor
The pattern in NNN.dir directories is that if we have a.go, the other files import "./a". For gc it happens to work to use a path, but not for gofrontend. Better to be consistent. Change-Id: I2e023cbf6bd115f9fb77427b097b0ff9b9992f17 Reviewed-on: https://go-review.googlesource.com/c/go/+/278113 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-15test: recognize gofrontend error messagesIan Lance Taylor
fixedbugs/issue26416.go:24:16: error: unknown field ‘t1f1’ in ‘t2’ fixedbugs/issue26416.go:25:16: error: unknown field ‘t1f2’ in ‘t3’ fixedbugs/issue26416.go:26:16: error: unknown field ‘t2f1’ in ‘t3’ fixedbugs/issue26616.go:15:9: error: single variable set to multiple-value function call fixedbugs/issue26616.go:9:5: error: incompatible type in initialization (multiple-value function call in single-value context) fixedbugs/issue26616.go:12:13: error: incompatible type in initialization (multiple-value function call in single-value context) fixedbugs/issue26616.go:13:13: error: incompatible type in initialization (multiple-value function call in single-value context) fixedbugs/issue26616.go:15:9: error: incompatible type in initialization (multiple-value function call in single-value context) fixedbugs/issue26616.go:14:11: error: incompatible types in assignment (multiple-value function call in single-value context) fixedbugs/issue26855.go:23:12: error: incompatible type for field 1 in struct construction fixedbugs/issue26855.go:27:12: error: incompatible type for field 1 in struct construction fixedbugs/issue25958.go:14:18: error: expected ‘<-’ or ‘=’ fixedbugs/issue25958.go:15:35: error: expected ‘<-’ or ‘=’ fixedbugs/issue28079b.go:13:9: error: array bound is not constant fixedbugs/issue28079b.go:16:22: error: invalid context-determined non-integer type for left operand of shift fixedbugs/issue28079c.go:14:22: error: invalid context-determined non-integer type for left operand of shift fixedbugs/issue28450.go:9:19: error: ‘...’ only permits one name fixedbugs/issue28450.go:10:18: error: ‘...’ must be last parameter fixedbugs/issue28450.go:11:16: error: ‘...’ must be last parameter fixedbugs/issue28450.go:11:24: error: ‘...’ must be last parameter fixedbugs/issue28450.go:13:25: error: ‘...’ must be last parameter fixedbugs/issue28450.go:15:19: error: ‘...’ must be last parameter fixedbugs/issue28450.go:16:21: error: ‘...’ must be last parameter fixedbugs/issue28450.go:16:31: error: ‘...’ must be last parameter fixedbugs/issue28268.go:20:1: error: method ‘E’ redeclares struct field name fixedbugs/issue28268.go:19:1: error: method ‘b’ redeclares struct field name fixedbugs/issue27356.go:14:14: error: expected function fixedbugs/issue27356.go:18:9: error: expected function fixedbugs/issue29855.go:13:11: error: unknown field ‘Name’ in ‘T’ fixedbugs/issue27938.go:14:15: error: expected package fixedbugs/issue27938.go:18:13: error: expected package fixedbugs/issue27938.go:22:13: error: expected package fixedbugs/issue27938.go:22:9: error: expected signature or type name fixedbugs/issue29870b.go:13:9: error: ‘x’ declared but not used fixedbugs/issue30085.go:10:18: error: wrong number of initializations fixedbugs/issue30085.go:11:21: error: wrong number of initializations fixedbugs/issue30087.go:10:18: error: wrong number of initializations fixedbugs/issue30087.go:11:11: error: number of variables does not match number of values fixedbugs/issue30087.go:12:9: error: wrong number of initializations fixedbugs/issue30087.go:13:9: error: wrong number of initializations fixedbugs/issue28926.go:16:14: error: use of undefined type ‘G’ fixedbugs/issue28926.go:18:14: error: use of undefined type ‘E’ fixedbugs/issue28926.go:22:24: error: use of undefined type ‘T’ fixedbugs/issue30722.go:13:13: error: invalid numeric literal fixedbugs/issue30722.go:14:13: error: invalid numeric literal fixedbugs/issue30722.go:15:13: error: invalid numeric literal fixedbugs/issue33308.go:12:19: error: invalid context-determined non-integer type for left operand of shift fixedbugs/issue33386.go:16:9: error: expected operand fixedbugs/issue33386.go:22:9: error: expected operand fixedbugs/issue33386.go:26:17: error: expected operand fixedbugs/issue33386.go:27:18: error: expected operand fixedbugs/issue33386.go:28:29: error: expected operand fixedbugs/issue33386.go:15:17: error: reference to undefined name ‘send’ fixedbugs/issue33386.go:27:13: error: reference to undefined name ‘a’ fixedbugs/issue33386.go:21:19: error: value computed is not used fixedbugs/issue33460.go:34:10: error: duplicate key in map literal fixedbugs/issue33460.go:21:9: error: duplicate case in switch fixedbugs/issue33460.go:24:9: error: duplicate case in switch fixedbugs/issue33460.go:25:9: error: duplicate case in switch fixedbugs/issue32723.go:12:14: error: invalid comparison of non-ordered type fixedbugs/issue32723.go:13:13: error: invalid comparison of non-ordered type fixedbugs/issue32723.go:16:16: error: invalid comparison of non-ordered type fixedbugs/issue32723.go:17:16: error: invalid comparison of non-ordered type fixedbugs/issue32723.go:18:15: error: invalid comparison of non-ordered type fixedbugs/issue32723.go:21:15: error: invalid comparison of non-ordered type fixedbugs/issue35291.go:13:9: error: duplicate value for index 1 fixedbugs/issue38745.go:12:12: error: reference to undefined field or method ‘M’ fixedbugs/issue38745.go:13:16: error: reference to undefined field or method ‘M’ fixedbugs/issue38745.go:17:19: error: reference to undefined field or method ‘M’ fixedbugs/issue38745.go:17:9: error: not enough arguments to return fixedbugs/issue41500.go:16:22: error: incompatible types in binary expression fixedbugs/issue41500.go:17:26: error: incompatible types in binary expression fixedbugs/issue41500.go:18:22: error: incompatible types in binary expression fixedbugs/issue41500.go:19:26: error: incompatible types in binary expression fixedbugs/issue41575.go:23:6: error: invalid recursive type fixedbugs/issue41575.go:9:6: error: invalid recursive type ‘T1’ fixedbugs/issue41575.go:13:6: error: invalid recursive type ‘T2’ fixedbugs/issue41575.go:17:6: error: invalid recursive type ‘a’ fixedbugs/issue41575.go:18:6: error: invalid recursive type ‘b’ fixedbugs/issue41575.go:19:6: error: invalid recursive type ‘c’ fixedbugs/issue41575.go:25:6: error: invalid recursive type ‘g’ fixedbugs/issue41575.go:32:6: error: invalid recursive type ‘x’ fixedbugs/issue41575.go:33:6: error: invalid recursive type ‘y’ fixedbugs/issue4215.go:10:9: error: not enough arguments to return fixedbugs/issue4215.go:14:9: error: return with value in function with no return type fixedbugs/issue4215.go:19:17: error: not enough arguments to return fixedbugs/issue4215.go:21:9: error: not enough arguments to return fixedbugs/issue4215.go:27:17: error: not enough arguments to return fixedbugs/issue4215.go:29:17: error: too many values in return statement fixedbugs/issue4215.go:31:17: error: not enough arguments to return fixedbugs/issue4215.go:43:17: error: not enough arguments to return fixedbugs/issue4215.go:46:17: error: not enough arguments to return fixedbugs/issue4215.go:48:9: error: too many values in return statement fixedbugs/issue4215.go:52:9: error: too many values in return statement fixedbugs/issue41247.go:10:16: error: incompatible type for return value 1 fixedbugs/issue41440.go:13:9: error: too many arguments fixedbugs/issue6772.go:10:16: error: ‘a’ repeated on left side of := fixedbugs/issue6772.go:17:16: error: ‘a’ repeated on left side of := fixedbugs/issue6402.go:12:16: error: incompatible type for return value 1 fixedbugs/issue6403.go:13:23: error: reference to undefined identifier ‘syscall.X’ fixedbugs/issue6403.go:14:15: error: reference to undefined name ‘voidpkg’ fixedbugs/issue7746.go:24:20: error: constant multiplication overflow fixedbugs/issue7760.go:15:7: error: invalid constant type fixedbugs/issue7760.go:16:7: error: invalid constant type fixedbugs/issue7760.go:18:7: error: invalid constant type fixedbugs/issue7760.go:19:7: error: invalid constant type fixedbugs/issue7760.go:21:11: error: expression is not constant fixedbugs/issue7760.go:22:11: error: expression is not constant fixedbugs/issue7760.go:24:7: error: invalid constant type fixedbugs/issue7760.go:25:7: error: invalid constant type fixedbugs/issue7129.go:18:11: error: argument 1 has incompatible type (cannot use type bool as type int) fixedbugs/issue7129.go:19:11: error: argument 1 has incompatible type (cannot use type bool as type int) fixedbugs/issue7129.go:20:11: error: argument 1 has incompatible type (cannot use type bool as type int) fixedbugs/issue7129.go:20:17: error: argument 2 has incompatible type (cannot use type bool as type int) fixedbugs/issue7150.go:12:20: error: index expression is negative fixedbugs/issue7150.go:13:13: error: some element keys in composite literal are out of range fixedbugs/issue7150.go:14:13: error: some element keys in composite literal are out of range fixedbugs/issue7150.go:15:13: error: some element keys in composite literal are out of range fixedbugs/issue7150.go:16:13: error: some element keys in composite literal are out of range fixedbugs/issue7675.go:16:11: error: argument 1 has incompatible type (cannot use type int as type string) fixedbugs/issue7675.go:16:24: error: argument 3 has incompatible type (cannot use type string as type float64) fixedbugs/issue7675.go:16:9: error: not enough arguments fixedbugs/issue7675.go:16:14: error: floating-point constant truncated to integer fixedbugs/issue7675.go:18:11: error: argument 1 has incompatible type (cannot use type int as type string) fixedbugs/issue7675.go:18:24: error: argument 3 has incompatible type (cannot use type string as type float64) fixedbugs/issue7675.go:18:28: error: argument 4 has incompatible type (cannot use type int as type string) fixedbugs/issue7675.go:18:9: error: too many arguments fixedbugs/issue7675.go:18:14: error: floating-point constant truncated to integer fixedbugs/issue7675.go:19:11: error: argument 1 has incompatible type (cannot use type int as type string) fixedbugs/issue7675.go:19:9: error: not enough arguments fixedbugs/issue7675.go:19:14: error: floating-point constant truncated to integer fixedbugs/issue7675.go:21:11: error: argument 1 has incompatible type (cannot use type int as type string) fixedbugs/issue7675.go:21:19: error: argument 3 has incompatible type fixedbugs/issue7675.go:21:14: error: floating-point constant truncated to integer fixedbugs/issue7675.go:23:14: error: floating-point constant truncated to integer fixedbugs/issue7153.go:11:15: error: reference to undefined name ‘a’ fixedbugs/issue7153.go:11:18: error: incompatible type for element 1 in composite literal fixedbugs/issue7153.go:11:24: error: incompatible type for element 2 in composite literal fixedbugs/issue7310.go:12:13: error: left argument must be a slice fixedbugs/issue7310.go:13:13: error: second argument must be slice or string fixedbugs/issue7310.go:14:15: error: incompatible types in binary expression fixedbugs/issue6964.go:10:13: error: invalid type conversion (cannot use type complex128 as type string) fixedbugs/issue7538a.go:14:9: error: reference to undefined label ‘_’ fixedbugs/issue8311.go:14:9: error: increment or decrement of non-numeric type fixedbugs/issue8507.go:12:6: error: invalid recursive type ‘T’ fixedbugs/issue9521.go:16:20: error: argument 2 has incompatible type fixedbugs/issue9521.go:17:20: error: argument 2 has incompatible type (cannot use type float64 as type int) fixedbugs/issue8385.go:30:19: error: argument 1 has incompatible type (type has no methods) fixedbugs/issue8385.go:30:14: error: not enough arguments fixedbugs/issue8385.go:35:9: error: not enough arguments fixedbugs/issue8385.go:36:9: error: not enough arguments fixedbugs/issue8385.go:37:10: error: not enough arguments fixedbugs/issue8385.go:38:10: error: not enough arguments fixedbugs/issue8385.go:39:10: error: not enough arguments fixedbugs/issue8385.go:40:10: error: not enough arguments fixedbugs/issue8385.go:41:13: error: not enough arguments fixedbugs/issue8438.go:13:23: error: incompatible type for element 1 in composite literal fixedbugs/issue8438.go:14:22: error: incompatible type for element 1 in composite literal fixedbugs/issue8438.go:15:23: error: incompatible type for element 1 in composite literal fixedbugs/issue8440.go:10:9: error: reference to undefined name ‘n’ Change-Id: I5707aec7d3c9178c4f4d794d4827fc907b52efb3 Reviewed-on: https://go-review.googlesource.com/c/go/+/278032 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-14test: match gofrontend error messagesIan Lance Taylor
fixedbugs/issue20602.go:13:9: error: argument must have complex type fixedbugs/issue20602.go:14:9: error: argument must have complex type fixedbugs/issue19323.go:12:12: error: attempt to slice object that is not array, slice, or string fixedbugs/issue19323.go:18:13: error: attempt to slice object that is not array, slice, or string fixedbugs/issue20749.go:12:11: error: array index out of bounds fixedbugs/issue20749.go:15:11: error: array index out of bounds fixedbugs/issue20415.go:14:5: error: redefinition of ‘f’ fixedbugs/issue20415.go:12:5: note: previous definition of ‘f’ was here fixedbugs/issue20415.go:25:5: error: redefinition of ‘g’ fixedbugs/issue20415.go:20:5: note: previous definition of ‘g’ was here fixedbugs/issue20415.go:33:5: error: redefinition of ‘h’ fixedbugs/issue20415.go:31:5: note: previous definition of ‘h’ was here fixedbugs/issue19977.go:12:21: error: reference to undefined name ‘a’ fixedbugs/issue20812.go:10:13: error: invalid type conversion (cannot use type string as type int) fixedbugs/issue20812.go:11:13: error: invalid type conversion (cannot use type int as type bool) fixedbugs/issue20812.go:12:13: error: invalid type conversion (cannot use type string as type bool) fixedbugs/issue20812.go:13:13: error: invalid type conversion (cannot use type bool as type int) fixedbugs/issue20812.go:14:13: error: invalid type conversion (cannot use type bool as type string) fixedbugs/issue21256.go:9:5: error: redefinition of ‘main’ fixedbugs/issue20813.go:10:11: error: invalid left hand side of assignment fixedbugs/issue20185.go:22:16: error: ‘t’ declared but not used fixedbugs/issue20185.go:13:9: error: cannot type switch on non-interface value fixedbugs/issue20185.go:22:9: error: cannot type switch on non-interface value fixedbugs/issue20227.go:11:11: error: division by zero fixedbugs/issue20227.go:12:12: error: division by zero fixedbugs/issue20227.go:13:12: error: division by zero fixedbugs/issue20227.go:15:11: error: division by zero fixedbugs/issue20227.go:16:12: error: division by zero fixedbugs/issue19880.go:14:13: error: invalid use of type fixedbugs/issue23093.go:9:5: error: initialization expression for ‘f’ depends upon itself fixedbugs/issue21979.go:29:13: error: integer constant overflow fixedbugs/issue21979.go:39:13: error: complex constant truncated to floating-point fixedbugs/issue21979.go:10:13: error: invalid type conversion (cannot use type string as type bool) fixedbugs/issue21979.go:11:13: error: invalid type conversion (cannot use type int as type bool) fixedbugs/issue21979.go:12:13: error: invalid type conversion (cannot use type float64 as type bool) fixedbugs/issue21979.go:13:13: error: invalid type conversion (cannot use type complex128 as type bool) fixedbugs/issue21979.go:15:13: error: invalid type conversion (cannot use type bool as type string) fixedbugs/issue21979.go:17:13: error: invalid type conversion (cannot use type float64 as type string) fixedbugs/issue21979.go:18:13: error: invalid type conversion (cannot use type complex128 as type string) fixedbugs/issue21979.go:20:13: error: invalid type conversion (cannot use type string as type int) fixedbugs/issue21979.go:21:13: error: invalid type conversion (cannot use type bool as type int) fixedbugs/issue21979.go:27:13: error: invalid type conversion (cannot use type string as type uint) fixedbugs/issue21979.go:28:13: error: invalid type conversion (cannot use type bool as type uint) fixedbugs/issue21979.go:34:13: error: invalid type conversion (cannot use type string as type float64) fixedbugs/issue21979.go:35:13: error: invalid type conversion (cannot use type bool as type float64) fixedbugs/issue21979.go:41:13: error: invalid type conversion (cannot use type string as type complex128) fixedbugs/issue21979.go:42:13: error: invalid type conversion (cannot use type bool as type complex128) fixedbugs/issue21988.go:11:11: error: reference to undefined name ‘Wrong’ fixedbugs/issue22063.go:11:11: error: reference to undefined name ‘Wrong’ fixedbugs/issue22904.go:12:6: error: invalid recursive type ‘a’ fixedbugs/issue22904.go:13:6: error: invalid recursive type ‘b’ fixedbugs/issue22921.go:11:16: error: reference to undefined identifier ‘bytes.nonexist’ fixedbugs/issue22921.go:13:19: error: reference to undefined identifier ‘bytes.nonexist’ fixedbugs/issue22921.go:13:19: error: expected signature or type name fixedbugs/issue22921.go:17:15: error: reference to undefined identifier ‘bytes.buffer’ fixedbugs/issue23823.go:15:9: error: invalid recursive interface fixedbugs/issue23823.go:10:9: error: invalid recursive interface fixedbugs/issue23732.go:24:13: error: too few expressions for struct fixedbugs/issue23732.go:34:17: error: too many expressions for struct fixedbugs/issue23732.go:37:13: error: too few expressions for struct fixedbugs/issue23732.go:40:17: error: too many expressions for struct fixedbugs/issue22794.go:16:14: error: reference to undefined field or method ‘floats’ fixedbugs/issue22794.go:18:19: error: unknown field ‘floats’ in ‘it’ fixedbugs/issue22794.go:19:17: error: unknown field ‘InneR’ in ‘it’ fixedbugs/issue22794.go:18:9: error: ‘i2’ declared but not used fixedbugs/issue22822.go:15:17: error: expected function fixedbugs/issue25727.go:12:10: error: reference to unexported field or method ‘doneChan’ fixedbugs/issue25727.go:13:10: error: reference to undefined field or method ‘DoneChan’ fixedbugs/issue25727.go:14:21: error: unknown field ‘tlsConfig’ in ‘http.Server’ fixedbugs/issue25727.go:15:21: error: unknown field ‘DoneChan’ in ‘http.Server’ fixedbugs/issue25727.go:21:14: error: unknown field ‘bAr’ in ‘foo’ Change-Id: I32ce0b7d80017b2367b8fb479a881632240d4161 Reviewed-on: https://go-review.googlesource.com/c/go/+/277455 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-12-14test: match gofrontend error messagesIan Lance Taylor
fixedbugs/issue14136.go:17:16: error: unknown field ‘X’ in ‘T’ fixedbugs/issue14136.go:18:13: error: incompatible type in initialization (cannot use type int as type string) fixedbugs/issue14520.go:9:37: error: import path contains control character fixedbugs/issue14520.go:14:2: error: expected ‘)’ fixedbugs/issue14520.go:14:3: error: expected declaration fixedbugs/issue14652.go:9:7: error: use of undefined type ‘any’ fixedbugs/issue14729.go:13:17: error: embedded type may not be a pointer fixedbugs/issue15514.dir/c.go:10: error: incompatible type in initialization fixedbugs/issue15898.go:11:9: error: duplicate type in switch fixedbugs/issue15898.go:16:9: error: duplicate type in switch fixedbugs/issue16439.go:10:21: error: index expression is negative fixedbugs/issue16439.go:13:21: error: index expression is negative fixedbugs/issue16439.go:16:21: error: index expression is not integer constant fixedbugs/issue16439.go:18:22: error: index expression is not integer constant fixedbugs/issue17328.go:11:20: error: expected ‘{’ fixedbugs/issue17328.go:11:20: error: expected ‘;’ or ‘}’ or newline fixedbugs/issue17328.go:13:1: error: expected declaration fixedbugs/issue17588.go:14:15: error: expected type fixedbugs/issue17631.go:20:17: error: unknown field ‘updates’ in ‘unnamed struct’ fixedbugs/issue17645.go:15:13: error: incompatible type in initialization fixedbugs/issue17758.go:13:1: error: redefinition of ‘foo’ fixedbugs/issue17758.go:9:1: note: previous definition of ‘foo’ was here fixedbugs/issue18092.go:13:19: error: expected colon fixedbugs/issue18231.go:17:12: error: may only omit types within composite literals of slice, array, or map type fixedbugs/issue18393.go:24:38: error: expected type fixedbugs/issue18419.dir/test.go:12: error: reference to unexported field or method 'member' fixedbugs/issue18655.go:14:1: error: redefinition of ‘m’ fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here fixedbugs/issue18655.go:15:1: error: redefinition of ‘m’ fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here fixedbugs/issue18655.go:16:1: error: redefinition of ‘m’ fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here fixedbugs/issue18655.go:17:1: error: redefinition of ‘m’ fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here fixedbugs/issue18655.go:18:1: error: redefinition of ‘m’ fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here fixedbugs/issue18655.go:20:1: error: redefinition of ‘m’ fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here fixedbugs/issue18655.go:21:1: error: redefinition of ‘m’ fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here fixedbugs/issue18655.go:22:1: error: redefinition of ‘m’ fixedbugs/issue18655.go:13:1: note: previous definition of ‘m’ was here fixedbugs/issue18915.go:13:20: error: expected ‘;’ after statement in if expression fixedbugs/issue18915.go:16:21: error: parse error in for statement fixedbugs/issue18915.go:19:24: error: expected ‘;’ after statement in switch expression fixedbugs/issue18915.go:13:12: error: ‘a’ declared but not used fixedbugs/issue18915.go:16:13: error: ‘b’ declared but not used fixedbugs/issue18915.go:19:16: error: ‘c’ declared but not used fixedbugs/issue19012.go:16:17: error: return with value in function with no return type fixedbugs/issue19012.go:18:9: error: return with value in function with no return type fixedbugs/issue19012.go:22:16: error: argument 2 has incompatible type (cannot use type bool as type uint) fixedbugs/issue19012.go:22:9: error: too many arguments fixedbugs/issue19012.go:22:16: error: incompatible types in binary expression fixedbugs/issue19012.go:24:9: error: too many arguments fixedbugs/issue19056.go:9:9: error: expected operand fixedbugs/issue19056.go:9:9: error: expected ‘;’ or newline after top level declaration fixedbugs/issue19482.go:25:15: error: expected struct field name fixedbugs/issue19482.go:27:15: error: expected struct field name fixedbugs/issue19482.go:31:19: error: expected struct field name fixedbugs/issue19482.go:33:15: error: expected struct field name fixedbugs/issue19667.go:13:1: error: expected operand fixedbugs/issue19667.go:13:1: error: missing ‘)’ fixedbugs/issue19667.go:13:105: error: expected ‘;’ after statement in if expression fixedbugs/issue19667.go:13:105: error: expected ‘{’ fixedbugs/issue19667.go:12:19: error: reference to undefined name ‘http’ Change-Id: Ia9c75b9c78671f354f0a0623dbc075157ef8f181 Reviewed-on: https://go-review.googlesource.com/c/go/+/277433 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-14cmd/compile: set correct type for OpIDataCuong Manh Le
Since CL 270057, there're many attempts to fix the expand_calls pass with interface{}-typed. But all of them did not fix the root cause. The main issue is during SSA conversion in gc/ssa.go, for empty interface case, we make its type as n.Type, instead of BytePtr. To fix these, we can just use BytePtr for now, since when itab fields are treated as scalar. No significal changes on compiler speed, size. cmd/compile/internal/ssa expandCalls.func6 9488 -> 9232 (-2.70%) file before after Δ % cmd/compile/internal/ssa.s 3992893 3992637 -256 -0.006% total 20500447 20500191 -256 -0.001% Fixes #43112 Updates #42784 Updates #42727 Updates #42568 Change-Id: I0b15d9434e0be5448453e61f98ef9c2d6cd93792 Reviewed-on: https://go-review.googlesource.com/c/go/+/276952 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: Keith Randall <khr@golang.org>
2020-12-11cmd/compile: fix select statement evaluation order corner caseMatthew Dempsky
The Go spec requires that select case clauses be evaluated in order, which is stricter than normal ordering semantics. cmd/compile handled this correctly for send clauses, but was not correctly handling receive clauses that involved bare variable references. Discovered with @cuonglm. Fixes #43111. Change-Id: Iec93b6514dd771875b084ba49c15d7f4531b4a6f Reviewed-on: https://go-review.googlesource.com/c/go/+/277132 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: 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>
2020-12-10test: match gofrontend error messagesIan Lance Taylor
fixedbugs/bug13343.go:10:12: error: initialization expressions for ‘b’ and ‘c’ depend upon each other fixedbugs/bug13343.go:11:9: note: ‘c’ defined here fixedbugs/bug13343.go:11:9: error: initialization expression for ‘c’ depends upon itself fixedbugs/bug13343.go:11:9: error: initialization expressions for ‘c’ and ‘b’ depend upon each other fixedbugs/bug13343.go:10:12: note: ‘b’ defined here fixedbugs/issue10700.dir/test.go:24:10: error: reference to method ‘Do’ in type that is pointer to interface, not interface fixedbugs/issue10700.dir/test.go:25:10: error: reference to method ‘do’ in type that is pointer to interface, not interface fixedbugs/issue10700.dir/test.go:27:10: error: reference to method ‘Dont’ in type that is pointer to interface, not interface fixedbugs/issue10700.dir/test.go:28:13: error: reference to undefined field or method ‘Dont’ fixedbugs/issue10700.dir/test.go:31:10: error: reference to undefined field or method ‘do’ fixedbugs/issue10700.dir/test.go:33:13: error: reference to undefined field or method ‘do’ fixedbugs/issue10700.dir/test.go:34:10: error: reference to undefined field or method ‘Dont’ fixedbugs/issue10700.dir/test.go:35:13: error: reference to undefined field or method ‘Dont’ fixedbugs/issue10700.dir/test.go:37:10: error: reference to method ‘Do’ in type that is pointer to interface, not interface fixedbugs/issue10700.dir/test.go:38:10: error: reference to method ‘do’ in type that is pointer to interface, not interface fixedbugs/issue10700.dir/test.go:40:13: error: reference to undefined field or method ‘do’ fixedbugs/issue10700.dir/test.go:41:10: error: reference to method ‘Dont’ in type that is pointer to interface, not interface fixedbugs/issue10700.dir/test.go:42:13: error: reference to undefined field or method ‘Dont’ fixedbugs/issue10700.dir/test.go:43:10: error: reference to method ‘secret’ in type that is pointer to interface, not interface fixedbugs/issue10700.dir/test.go:44:13: error: reference to unexported field or method ‘secret’ fixedbugs/issue10975.go:13:9: error: interface contains embedded non-interface fixedbugs/issue11326.go:26:17: error: floating-point constant overflow fixedbugs/issue11326.go:27:17: error: floating-point constant overflow fixedbugs/issue11326.go:28:17: error: floating-point constant overflow fixedbugs/issue11361.go:9:11: error: import file ‘fmt’ not found fixedbugs/issue11361.go:11:11: error: reference to undefined name ‘fmt’ fixedbugs/issue11371.go:12:15: error: floating-point constant truncated to integer fixedbugs/issue11371.go:13:15: error: integer constant overflow fixedbugs/issue11371.go:17:15: error: floating-point constant truncated to integer fixedbugs/issue11590.go:9:17: error: integer constant overflow fixedbugs/issue11590.go:9:17: error: integer constant overflow fixedbugs/issue11590.go:10:22: error: complex real part overflow fixedbugs/issue11590.go:10:22: error: complex real part overflow fixedbugs/issue11590.go:11:23: error: complex real part overflow fixedbugs/issue11590.go:11:23: error: complex real part overflow fixedbugs/issue11590.go:9:19: error: integer constant overflow fixedbugs/issue11590.go:10:24: error: complex real part overflow fixedbugs/issue11590.go:11:25: error: complex real part overflow fixedbugs/issue11610.go:11:7: error: import path is empty fixedbugs/issue11610.go:12:4: error: invalid character 0x3f in input file fixedbugs/issue11610.go:14:1: error: expected identifier fixedbugs/issue11610.go:14:1: error: expected type fixedbugs/issue11614.go:14:9: error: interface contains embedded non-interface fixedbugs/issue13248.go:13:1: error: expected operand fixedbugs/issue13248.go:13:1: error: missing ‘)’ fixedbugs/issue13248.go:12:5: error: reference to undefined name ‘foo’ fixedbugs/issue13266.go:10:8: error: package name must be an identifier fixedbugs/issue13266.go:10:8: error: expected ‘;’ or newline after package clause fixedbugs/issue13266.go:10:8: error: expected declaration fixedbugs/issue13273.go:50:18: error: expected ‘chan’ fixedbugs/issue13273.go:53:24: error: expected ‘chan’ fixedbugs/issue13274.go:11:58: error: expected ‘}’ fixedbugs/issue13365.go:14:19: error: index expression is negative fixedbugs/issue13365.go:15:21: error: index expression is negative fixedbugs/issue13365.go:16:22: error: index expression is negative fixedbugs/issue13365.go:19:13: error: some element keys in composite literal are out of range fixedbugs/issue13365.go:22:19: error: incompatible type for element 1 in composite literal fixedbugs/issue13365.go:23:21: error: incompatible type for element 1 in composite literal fixedbugs/issue13365.go:24:22: error: incompatible type for element 1 in composite literal fixedbugs/issue13415.go:14:5: error: redefinition of ‘x’ fixedbugs/issue13415.go:14:5: note: previous definition of ‘x’ was here fixedbugs/issue13415.go:14:5: error: ‘x’ declared but not used fixedbugs/issue13471.go:12:25: error: floating-point constant truncated to integer fixedbugs/issue13471.go:13:25: error: floating-point constant truncated to integer fixedbugs/issue13471.go:14:25: error: floating-point constant truncated to integer fixedbugs/issue13471.go:15:24: error: floating-point constant truncated to integer fixedbugs/issue13471.go:16:23: error: floating-point constant truncated to integer fixedbugs/issue13471.go:18:26: error: floating-point constant truncated to integer fixedbugs/issue13471.go:19:26: error: floating-point constant truncated to integer fixedbugs/issue13471.go:20:26: error: floating-point constant truncated to integer fixedbugs/issue13471.go:21:25: error: floating-point constant truncated to integer fixedbugs/issue13471.go:22:24: error: floating-point constant truncated to integer fixedbugs/issue13471.go:24:24: error: floating-point constant truncated to integer fixedbugs/issue13821b.go:18:12: error: incompatible types in binary expression fixedbugs/issue13821b.go:19:13: error: incompatible types in binary expression fixedbugs/issue13821b.go:20:13: error: incompatible types in binary expression fixedbugs/issue13821b.go:21:13: error: incompatible types in binary expression fixedbugs/issue13821b.go:22:13: error: incompatible types in binary expression fixedbugs/issue13821b.go:24:12: error: incompatible types in binary expression fixedbugs/issue14006.go:24:18: error: expected ‘;’ or ‘}’ or newline fixedbugs/issue14006.go:30:18: error: expected ‘;’ or ‘}’ or newline fixedbugs/issue14006.go:37:22: error: expected ‘;’ or ‘}’ or newline fixedbugs/issue14006.go:43:22: error: expected ‘;’ or ‘}’ or newline fixedbugs/issue14006.go:59:17: note: previous definition of ‘labelname’ was here fixedbugs/issue14006.go:64:17: error: label ‘labelname’ already defined fixedbugs/issue14006.go:24:17: error: value computed is not used fixedbugs/issue14006.go:30:17: error: value computed is not used fixedbugs/issue14006.go:37:20: error: value computed is not used fixedbugs/issue14006.go:43:20: error: value computed is not used fixedbugs/issue14006.go:59:17: error: label ‘labelname’ defined and not used fixedbugs/issue14010.go:13:14: error: invalid left hand side of assignment fixedbugs/issue14010.go:14:14: error: invalid left hand side of assignment fixedbugs/issue14010.go:14:9: error: invalid use of type fixedbugs/issue14321.go:30:10: error: method ‘F’ is ambiguous in type ‘C’ fixedbugs/issue14321.go:31:10: error: ‘G’ is ambiguous via ‘A’ and ‘B’ fixedbugs/issue14321.go:33:10: error: type ‘C’ has no method ‘I’ fixedbugs/issue8183.go:12:14: error: integer constant overflow fixedbugs/issue9036.go:21:12: error: invalid prefix for floating constant fixedbugs/issue9036.go:22:12: error: invalid prefix for floating constant fixedbugs/issue9076.go:14:5: error: incompatible type in initialization (cannot use type uintptr as type int32) fixedbugs/issue9076.go:15:5: error: incompatible type in initialization (cannot use type uintptr as type int32) For issue9083.go avoid an error about a variable that is set but not used. fixedbugs/issue9370.go:105:13: error: cannot use ‘_’ as value fixedbugs/issue9370.go:106:13: error: cannot use ‘_’ as value fixedbugs/issue9370.go:107:13: error: cannot use ‘_’ as value fixedbugs/issue9370.go:108:13: error: cannot use ‘_’ as value fixedbugs/issue9370.go:109:13: error: cannot use ‘_’ as value fixedbugs/issue9370.go:110:13: error: cannot use ‘_’ as value fixedbugs/issue9370.go:112:18: error: cannot use ‘_’ as value fixedbugs/issue9370.go:113:18: error: cannot use ‘_’ as value fixedbugs/issue9370.go:114:18: error: cannot use ‘_’ as value fixedbugs/issue9370.go:115:18: error: cannot use ‘_’ as value fixedbugs/issue9370.go:116:18: error: cannot use ‘_’ as value fixedbugs/issue9370.go:117:18: error: cannot use ‘_’ as value fixedbugs/issue9370.go:119:13: error: cannot use ‘_’ as value fixedbugs/issue9370.go:119:18: error: cannot use ‘_’ as value fixedbugs/issue9370.go:36:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:39:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:43:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:46:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:50:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:53:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:56:15: error: incompatible types in binary expression fixedbugs/issue9370.go:57:15: error: incompatible types in binary expression fixedbugs/issue9370.go:58:15: error: incompatible types in binary expression fixedbugs/issue9370.go:59:15: error: incompatible types in binary expression fixedbugs/issue9370.go:60:15: error: incompatible types in binary expression fixedbugs/issue9370.go:61:15: error: incompatible types in binary expression fixedbugs/issue9370.go:65:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:68:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:70:15: error: incompatible types in binary expression fixedbugs/issue9370.go:71:15: error: incompatible types in binary expression fixedbugs/issue9370.go:72:15: error: incompatible types in binary expression fixedbugs/issue9370.go:73:15: error: incompatible types in binary expression fixedbugs/issue9370.go:74:15: error: incompatible types in binary expression fixedbugs/issue9370.go:75:15: error: incompatible types in binary expression fixedbugs/issue9370.go:77:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:78:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:79:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:80:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:81:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:82:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:84:15: error: incompatible types in binary expression fixedbugs/issue9370.go:85:15: error: incompatible types in binary expression fixedbugs/issue9370.go:86:15: error: incompatible types in binary expression fixedbugs/issue9370.go:87:15: error: incompatible types in binary expression fixedbugs/issue9370.go:88:15: error: incompatible types in binary expression fixedbugs/issue9370.go:89:15: error: incompatible types in binary expression fixedbugs/issue9370.go:91:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:92:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:93:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:94:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:95:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:96:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:98:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:99:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:100:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:101:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:102:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:103:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:121:15: error: incompatible types in binary expression fixedbugs/issue9370.go:122:15: error: incompatible types in binary expression fixedbugs/issue9370.go:123:15: error: incompatible types in binary expression fixedbugs/issue9370.go:124:15: error: incompatible types in binary expression Change-Id: I4089de4919112b08f5f2bbec20f84fcc7dbe3955 Reviewed-on: https://go-review.googlesource.com/c/go/+/276832 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-12-10cmd/compile: don't constant fold divide by zeroKeith Randall
It just makes the compiler crash. Oops. Fixes #43099 Change-Id: Id996c14799c1a5d0063ecae3b8770568161c2440 Reviewed-on: https://go-review.googlesource.com/c/go/+/276652 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-07test: add new test that gofrontend failed to handleIan Lance Taylor
The gofrontend code would in some circumstances incorrectly generate a type descriptor for an alias type, causing the type to fail to be equal to the unaliased type. Change-Id: I47d33b0bfde3c72a9a186049539732bdd5a6a96e Reviewed-on: https://go-review.googlesource.com/c/go/+/275632 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-03cmd/compile: make sure address of offset(SP) is rematerializeableCherry Zhang
An address of offset(SP) may point to the callee args area, and may be used to move things into/out of the args/results. If an address like that is spilled and picked up by the GC, it may hold an arg/result live in the callee, which may not actually be live (e.g. a result not initialized at function entry). Make sure they are rematerializeable, so they are always short-lived and never picked up by the GC. This CL changes 386, PPC64, and Wasm. On AMD64 we already have the rule (line 2159). On other architectures, we already have similar rules like (OffPtr [off] ptr:(SP)) => (MOVDaddr [int32(off)] ptr) to avoid this problem. (Probably me in the past had run into this...) Fixes #42944. Change-Id: Id2ec73ac08f8df1829a9a7ceb8f749d67fe86d1e Reviewed-on: https://go-review.googlesource.com/c/go/+/275174 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2020-12-03test: match gofrontend error messagesIan Lance Taylor
fixedbugs/bug487.go:17:17: error: function result count mismatch fixedbugs/bug487.go:18:16: error: function result count mismatch fixedbugs/issue6977.go:37:26: error: duplicate method ‘m’ fixedbugs/issue6977.go:38:21: error: duplicate method ‘m’ fixedbugs/issue6977.go:39:26: error: duplicate method ‘m’ fixedbugs/issue6977.go:40:21: error: duplicate method ‘m’ Change-Id: Ie3c8a4650cd8f4c239bdceac25dc188a6a50ca34 Reviewed-on: https://go-review.googlesource.com/c/go/+/275178 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2020-12-03test: match gccgo error messagesIan Lance Taylor
assign.go:59:28: error: ‘x’ repeated on left side of := assign.go:65:20: error: ‘a’ repeated on left side of := method2.go:36:11: error: reference to method ‘val’ in type that is pointer to interface, not interface method2.go:37:11: error: reference to method ‘val’ in type that is pointer to interface, not interface Change-Id: I8f385c75a82fae4eacf4618df8f9f65932826494 Reviewed-on: https://go-review.googlesource.com/c/go/+/274447 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-12-02all: update to use filepath.WalkDir instead of filepath.WalkRuss Cox
Now that filepath.WalkDir is available, it is more efficient and should be used in place of filepath.Walk. Update the tree to reflect best practices. As usual, the code compiled with Go 1.4 during bootstrap is excluded. (In this CL, that's only cmd/dist.) For #42027. Change-Id: Ib0f7b1e43e50b789052f9835a63ced701d8c411c Reviewed-on: https://go-review.googlesource.com/c/go/+/267719 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2020-12-02test: match gofrontend error messagesIan Lance Taylor
The gofrontend code doesn't distinguish semicolon and newline, and it doesn't have special treatment for EOF. syntax/semi6.go:9:47: error: unexpected semicolon or newline in type declaration syntax/semi6.go:11:62: error: unexpected semicolon or newline in type declaration Change-Id: I9996b59a4fc78ad1935e779f354ddf75c0fb44e0 Reviewed-on: https://go-review.googlesource.com/c/go/+/274692 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2020-12-01cmd/compile: do not assume TST and TEQ set V on armJason A. Donenfeld
These replacement rules assume that TST and TEQ set V. But TST and TEQ do not set V. This is a problem because instructions like LT are actually checking for N!=V. But with TST and TEQ not setting V, LT doesn't do anything meaningful. It's possible to construct trivial miscompilations from this, such as: package main var x = [4]int32{-0x7fffffff, 0x7fffffff, 2, 4} func main() { if x[0] > x[1] { panic("fail 1") } if x[2]&x[3] < 0 { panic("fail 2") // Fails here } } That first comparison sets V, via the CMP that subtracts the values causing the overflow. Then the second comparison operation thinks that it uses the result of TST, when it actually uses the V from CMP. Before this fix: TST R0, R1 BLT loc_6C164 After this fix: TST R0, R1 BMI loc_6C164 The BMI instruction checks the N flag, which TST sets. This commit fixes the issue by using [LG][TE]noov instead of vanilla [LG][TE], and also adds a test case for the direct issue. Fixes #42876. Change-Id: I13c62c88d18574247ad002b671b38d2d0b0fc6fa Reviewed-on: https://go-review.googlesource.com/c/go/+/274026 Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: Jason A. Donenfeld <Jason@zx2c4.com>
2020-11-30test: update gofrontend expected errorsIan Lance Taylor
This matches the error messages after CL 273890. syntax/semi4.go:11:9: error: unexpected semicolon or newline, expecting ‘{’ after for clause syntax/semi4.go:10:13: error: reference to undefined name ‘x’ syntax/semi4.go:12:17: error: reference to undefined name ‘z’ Change-Id: Ic88ff6e27d50bf70f5b2114383b84c42c0682f39 Reviewed-on: https://go-review.googlesource.com/c/go/+/273891 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-11-30test: recognize gofrontend error messagesIan Lance Taylor
shift1.go:76:16: error: shift of non-integer operand shift1.go:77:16: error: shift of non-integer operand Change-Id: I48584c0b01f9f6912a93b5f9bba55b5803fbeced Reviewed-on: https://go-review.googlesource.com/c/go/+/273888 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-11-30test: recognize new gofrontend error messageIan Lance Taylor
As of https://golang.org/cl/273886: fixedbugs/bug340.go:15:18: error: reference to method ‘x’ in interface with no methods For golang/go#10700 Change-Id: Id29eb0e34bbb524117614229c4c27cfd17dae286 Reviewed-on: https://go-review.googlesource.com/c/go/+/273887 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>