summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* [release-branch.go1.14] cmd/compile: fix live variable computation for ↵Keith Randall2020-10-051-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | deferreturn Taking the live variable set from the last return point is problematic. See #40629 for details, but there may not be a return point, or it may be before the final defer. Additionally, keeping track of the last call as a *Value doesn't quite work. If it is dead-code eliminated, the storage for the Value is reused for some other random instruction. Its live variable information, if it is available at all, is wrong. Instead, just mark all the open-defer argument slots as live throughout the function. (They are already zero-initialized.) Fixes #40647 Change-Id: Ie456c7db3082d0de57eaa5234a0f32525a1cce13 Reviewed-on: https://go-review.googlesource.com/c/go/+/247522 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> (cherry picked from commit 32a84c99e136ed5af0686dbedd31fd7dff40fb38) Reviewed-on: https://go-review.googlesource.com/c/go/+/248622 TryBot-Result: Go Bot <gobot@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org>
* [release-branch.go1.14] cmd/compile: mark s390x int <-> float conversions as ↵Michael Munday2020-08-211-0/+26
| | | | | | | | | | | | | | | | clobbering flags These conversion instructions set the condition code and so should be marked as clobbering flags. Updates #39651. Fixes #39690. Change-Id: I1e3f2cf33337128d321b52ac72f46d1b8798ebd9 Reviewed-on: https://go-review.googlesource.com/c/go/+/242237 Run-TryBot: Michael Munday <mike.munday@ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* [release-branch.go1.14] cmd/compile: fix checkptr handling of &^Matthew Dempsky2020-08-211-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | checkptr has code to recognize &^ expressions, but it didn't take into account that "p &^ x" gets rewritten to "p & ^x" during walk, which resulted in false positive diagnostics. This CL changes walkexpr to mark OANDNOT expressions with Implicit when they're rewritten to OAND, so that walkCheckPtrArithmetic can still recognize them later. It would be slightly more idiomatic to instead mark the OBITNOT expression as Implicit (as it's a compiler-generated Node), but the OBITNOT expression might get constant folded. It's not worth the extra complexity/subtlety of relying on n.Right.Orig, so we set Implicit on the OAND node instead. To atone for this transgression, I add documentation for nodeImplicit. Updates #40917. Fixes #40968. Change-Id: I386304171ad299c530e151e5924f179e9a5fd5b8 Reviewed-on: https://go-review.googlesource.com/c/go/+/249477 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/249838 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
* [release-branch.go1.14] cmd/compile: don't addLocalInductiveFacts if there ↵Keith Randall2020-08-032-2/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | is no direct edge from if block to phi block Currently in addLocalInductiveFacts, we only check whether direct edge from if block to phi block exists. If not, the following logic will treat the phi block as the first successor, which is wrong. This patch makes prove pass more conservative, so we disable some cases in test/prove.go. We will do some optimization in the following CL and enable these cases then. Fixes #40501. Change-Id: I27cf0248f3a82312a6f7dabe11c79a1a34cf5412 Reviewed-on: https://go-review.googlesource.com/c/go/+/244579 Reviewed-by: Zach Jones <zachj1@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-on: https://go-review.googlesource.com/c/go/+/245958 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
* [release-branch.go1.14] reflect: zero stack slots before writing to them ↵Keith Randall2020-07-111-0/+33
| | | | | | | | | | | | | | | | | | with write barriers reflect.assignTo writes to the target using write barriers. Make sure that the memory it is writing to is zeroed, so the write barrier does not read pointers from uninitialized memory. Fixes #39698 Change-Id: Ia64b2cacc193bffd0c1396bbce1dfb8182d4905b Reviewed-on: https://go-review.googlesource.com/c/go/+/238760 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> (cherry picked from commit 3dec253783e1211989102ac6abd34cddbf8ba0e6) Reviewed-on: https://go-review.googlesource.com/c/go/+/238861
* [release-branch.go1.14] cmd/compile: remove check that Zero's arg has the ↵Keith Randall2020-07-101-0/+22
| | | | | | | | | | | | | | | | | | | | | | correct base type It doesn't have to. The type in the aux field is authoritative. There are cases involving casting from interface{} where pointers have a placeholder pointer type (because the type is not known when the IData op is generated). The check was introduced in CL 13447. Fixes #39849 Change-Id: Id77a57577806a271aeebd20bea5d92d08ee7aa6b Reviewed-on: https://go-review.googlesource.com/c/go/+/239817 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> (cherry picked from commit 3b2f67a59702e4881625cb967f853ef56b0c4828) Reviewed-on: https://go-review.googlesource.com/c/go/+/239997 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
* [release-branch.go1.14] cmd/compile: fix constant conversion involving ↵Matthew Dempsky2020-05-081-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | complex types In CL 187657, I refactored constant conversion logic without realizing that conversions between int/float and complex types are allowed for constants (assuming the constant values are representable by the destination type), but are never allowed for non-constant expressions. This CL expands convertop to take an extra srcConstant parameter to indicate whether the source expression is a constant; and if so, to allow any numeric-to-numeric conversion. (Conversions of values that cannot be represented in the destination type are rejected by evconst.) Fixes #38123. For #38117. Change-Id: Id7077d749a14c8fd910be38da170fa5254819f2b Reviewed-on: https://go-review.googlesource.com/c/go/+/226197 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> (cherry picked from commit 34314280e46da1558bc7f9cd7e8a9ed610cf417b) Reviewed-on: https://go-review.googlesource.com/c/go/+/232719 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* [release-branch.go1.14] runtime: make typehash match compiler generated ↵Keith Randall2020-03-101-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | hashes exactly If typehash (used by reflect) does not match the built-in map's hash, then problems occur. If a map is built using reflect, and then assigned to a variable of map type, the hash function can change. That causes very bad things. This issue is rare. MapOf consults a cache of all types that occur in the binary before making a new one. To make a true new map type (with a hash function derived from typehash) that map type must not occur in the binary anywhere. But to cause the bug, we need a variable of that type in order to assign to it. The only way to make that work is to use a named map type for the variable, so it is distinct from the unnamed version that MapOf looks for. Fixes #37721 Change-Id: I3537bfceca8cbfa1af84202f432f3c06953fe0ed Reviewed-on: https://go-review.googlesource.com/c/go/+/222357 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> (cherry picked from commit 2b8e60d464515634462ca472ca09c791e2cbf6ae) Reviewed-on: https://go-review.googlesource.com/c/go/+/222778
* cmd/compile,cmd/link: fix and re-enable open-coded defers on riscv64Joel Sing2020-01-291-5/+1
| | | | | | | | | | | | | | The R_CALLRISCV relocation marker is on the JALR instruction, however the actual relocation is currently two instructions previous for the AUIPC+ADDI sequence. Adjust the platform dependent offset accordingly and re-enable open-coded defers. Fixes #36786. Change-Id: I71597c193c447930fbe94ce44b7355e89ae877bb Reviewed-on: https://go-review.googlesource.com/c/go/+/216797 Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* test: disable the live test on riscv64Joel Sing2020-01-291-1/+6
| | | | | | | | | | | | | This test expects that open-coded defers are enabled, which is not currently the case on riscv64. Updates issue #27532 and #36786. Change-Id: I94bb558c5b0734b4cfe5ae12873be81026009bcf Reviewed-on: https://go-review.googlesource.com/c/go/+/216777 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* cmd/compile: disable open-coded defers on riscv64Joel Sing2020-01-281-0/+4
| | | | | | | | | | | | | | Open-coded defers are currently broken on riscv64 - disable them for the time being. All of the standard package tests now pass on linux/riscv64. Updates issue #27532 and #36786 Change-Id: I20fc25ce91dfad48be32409ba5c64ca9a6acef1d Reviewed-on: https://go-review.googlesource.com/c/go/+/216517 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* cmd/compile: on PPC64, fold offset into some loads/stores only when offset ↵Cherry Zhang2020-01-271-0/+26
| | | | | | | | | | | | | | | | | is 4-aligned On PPC64, MOVWload, MOVDload, and MOVDstore are assembled to a "DS from" instruction which requiers the offset is a multiple of 4. Only fold offset to such instructions if it is a multiple of 4. Fixes #36723. "GOARCH=ppc64 GOOS=linux go build -gcflags=all=-d=ssa/check/on std cmd" passes now. Change-Id: I67f2a6ac02f0d33d470f68ff54936c289a4c765b Reviewed-on: https://go-review.googlesource.com/c/go/+/216379 Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
* test: adjust tests for riscv64Joel Sing2020-01-253-2/+11
| | | | | | | | | | | This disables some tests that are unsupported on riscv64 and adds support for risc64 to test/nosplit. Updates #27532, #36739 and #36765 Change-Id: I0a57797a05bc80236709fc240c0a0efb0ee0d16b Reviewed-on: https://go-review.googlesource.com/c/go/+/216263 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* test: disable test for #36516 when cgo is not enabledTobias Klauser2020-01-191-1/+1
| | | | | | | | | | | | | | CL 214679 added a -race test which shouldn't be run when cgo is not enabled. Fixes the nocgo builder. Change-Id: Iceddf802c4ef6c0de2c3a968e86342303d2d27d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/215477 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* cmd/compile: mark ... argument to checkptrArithmetic as not escapingKeith Randall2020-01-171-0/+27
| | | | | | | | Fixes #36516 Change-Id: Ibf4f86fb3a25fa30e0cd54e2dd2e12c60ee75ddb Reviewed-on: https://go-review.googlesource.com/c/go/+/214679 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* cmd/compile: give every really deep type a unique nameKeith Randall2020-01-081-0/+70
| | | | | | | | | | | | | | | | | | | This avoids the security problem in #29312 where two very deep, but distinct, types are given the same name. They both make it to the linker which chooses one, and the use of the other is now type unsafe. Instead, give every very deep type its own name. This errs on the other side, in that very deep types that should be convertible to each other might now not be. But at least that's not a security hole. Update #29312. Change-Id: Iac0ebe73fdc50594fd6fbf7432eef65f9a053126 Reviewed-on: https://go-review.googlesource.com/c/go/+/213517 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Robert Griesemer <gri@golang.org>
* test: add a test for gccgo compiler bug of missing type descriptorCherry Zhang2019-12-113-0/+22
| | | | | | | | | | | | | The gccgo compiler did not generate type descriptor for a pointer to a type alias defined in another package, causing linking error. The fix is CL 210787. This CL adds a test. Updates #36085. Change-Id: I3237c7fedb4d92fb2dc610ee2b88087f96dc2a1a Reviewed-on: https://go-review.googlesource.com/c/go/+/210858 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os: skip a new failing test on WindowsBrad Fitzpatrick2019-12-061-51/+0
| | | | | | | | | | | | | | | | | This test was recently added in CL 209961. Apparently Windows can't seek a directory filehandle? And move the test from test/fixedbugs (which is mostly for compiler bugs) to an os package test. Updates #36019 Change-Id: I626b69b0294471014901d0ccfeefe5e2c7651788 Reviewed-on: https://go-review.googlesource.com/c/go/+/210283 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
* os: reset dirinfo when seeking on DarwinKeith Randall2019-12-051-0/+51
| | | | | | | | | | | | | | | | | | | | | The first Readdirnames calls opendir and caches the result. The behavior of that cached opendir result isn't specified on a seek of the underlying fd. Free the opendir result on a seek so that we'll allocate a new one the next time around. Also fix wasm behavior in this regard, so that a seek to the file start resets the Readdirnames position, regardless of platform. p.s. I hate the Readdirnames API. Fixes #35767. Change-Id: Ieffb61b3c5cdd42591f69ab13f932003966f2297 Reviewed-on: https://go-review.googlesource.com/c/go/+/209961 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* cmd/compile: try harder to not use an empty src.XPos for a bogus lineDavid Chase2019-11-221-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fix for #35652 did not guarantee that it was using a non-empty src position to replace an empty one. The new code checks again and falls back to a more certain position. (The input in question compiles to a single empty infinite loop, and none of the actual instructions had any source position at all. That is a bug, but given the pathology of this input, not one worth dealing with this late in the release cycle, if ever.) Literally: 00000 (5) TEXT "".f(SB), ABIInternal 00001 (5) PCDATA $0, $-2 00002 (5) PCDATA $1, $-2 00003 (5) FUNCDATA $0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB) 00004 (5) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB) 00005 (5) FUNCDATA $2, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB) b2 00006 (?) XCHGL AX, AX b6 00007 (+1048575) JMP 6 00008 (?) END TODO: Add runtime.InfiniteLoop(), replace infinite loops with a call to that, and use an eco-friendly runtime.gopark instead. (This was Cherry's excellent idea.) Updates #35652 Fixes #35695 Change-Id: I4b9a841142ee4df0f6b10863cfa0721a7e13b437 Reviewed-on: https://go-review.googlesource.com/c/go/+/207964 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* cmd/compile: make a better bogus line for empty infinite loopsDavid Chase2019-11-191-0/+15
| | | | | | | | | | | | | | | | | | | The old recipe for making an infinite loop not be infinite in the debugger could create an instruction (Prog) with a line number not tied to any file (index == 0). This caused downstream failures in DWARF processing. So don't do that. Also adds a test, also adds a check+panic to ensure that the next time this happens the error is less mystifying. Fixes #35652 Change-Id: I04f30bc94fdc4aef20dd9130561303ff84fd945e Reviewed-on: https://go-review.googlesource.com/c/go/+/207613 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* test: new test for gollvm compiler crash bugThan McIntosh2019-11-183-0/+31
| | | | | | | | | | | | Reduced test case for gollvm compiler crash building docker-ce. Updates #35586. Change-Id: Ib805dc9ab7b63cc61f207f1f000bef9809cfd428 Reviewed-on: https://go-review.googlesource.com/c/go/+/207258 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* test: avoid writing temporary files to GOROOTBryan C. Mills2019-11-185-36/+82
| | | | | | | | | | | | | | | | | | This reverts CL 207477, restoring CL 207352 with a fix for the regression observed in the Windows builders. cmd/compile evidently does not fully support NUL as an output on Windows, so this time we write ignored 'compile' outputs to temporary files (instead of os.DevNull as in CL 207352). Updates #28387 Fixes #35619 Change-Id: I2edc5727c3738fa1bccb4b74e50d114cf2a7fcff Reviewed-on: https://go-review.googlesource.com/c/go/+/207602 Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* hash/maphash: mark call into runtime hash function as not escapingKeith Randall2019-11-161-0/+19
| | | | | | | | | | | | This allows maphash.Hash to be allocated on the stack for typical uses. Fixes #35636 Change-Id: I8366507d26ea717f47a9fb46d3bd69ba799845ac Reviewed-on: https://go-review.googlesource.com/c/go/+/207444 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* Revert "test: avoid writing temporary files to GOROOT"Bryan C. Mills2019-11-155-64/+36
| | | | | | | | | | | | This reverts CL 207352 Reason for revert: broke more builders than it fixed. 😞 Change-Id: Ic5adefe92edfa2230b9c7d750c922473a6a5ded4 Reviewed-on: https://go-review.googlesource.com/c/go/+/207477 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* test: avoid writing temporary files to GOROOTBryan C. Mills2019-11-155-36/+64
| | | | | | | | | | | Updates #28387 Fixes #35619 Change-Id: I162f3427b7901c117e3f3e403df7edec7c529bd1 Reviewed-on: https://go-review.googlesource.com/c/go/+/207352 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* test: add another test case for #35518Matthew Dempsky2019-11-121-0/+8
| | | | | | | | | | Updates #35518. Change-Id: Icd052c8c68aae32696b5831a29e04cc4cb224b06 Reviewed-on: https://go-review.googlesource.com/c/go/+/206820 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* cmd/compile: fix -m=2 infinite loop in escape.goMatthew Dempsky2019-11-121-0/+36
| | | | | | | | | | | | | | | | | This CL detects infinite loops due to negative dereference cycles during escape analysis, and terminates the loop gracefully. We still fail to print a complete explanation of the escape path, but esc.go didn't print *any* explanation for these test cases, so the release blocking issue here is simply that we don't infinite loop. Updates #35518. Change-Id: I39beed036e5a685706248852f1fa619af3b7abbc Reviewed-on: https://go-review.googlesource.com/c/go/+/206619 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* runtime: fix line number for faulting instructionsKeith Randall2019-11-081-0/+43
| | | | | | | | | | | | | | | | | Unlike function calls, when processing instructions that directly fault we must not subtract 1 from the pc before looking up the file/line information. Since the file/line lookup unconditionally subtracts 1, add 1 to the faulting instruction PCs to compensate. Fixes #34123 Change-Id: Ie7361e3d2f84a0d4f48d97e5a9e74f6291ba7a8b Reviewed-on: https://go-review.googlesource.com/c/go/+/196962 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
* Merge "cmd: merge branch 'dev.link' into master"Gerrit Code Review2019-11-081-0/+6
|\
| * cmd: merge branch 'dev.link' into masterCherry Zhang2019-11-051-0/+6
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the dev.link branch we implemented the new object file format and (part of) the linker improvements described in https://golang.org/s/better-linker The new object file is index-based and provides random access. The linker maps the object files into read-only memory, and access symbols on-demand using indices, as opposed to reading all object files sequentially into the heap with the old format. The linker carries symbol informations using indices (as opposed to Symbol data structure). Symbols are created after the reachability analysis, and only created for reachable symbols. This reduces the linker's memory usage. Linking cmd/compile, it creates ~25% fewer Symbols, and reduces memory usage (inuse_space) by ~15%. (More results from Than.) Currently, both the old and new object file formats are supported. The old format is used by default. The new format can be turned on by using the compiler/assembler/linker's -newobj flag. Note that the flag needs to be specified consistently to all compilations, i.e. go build -gcflags=all=-newobj -asmflags=all=-newobj -ldflags=-newobj Change-Id: Ia0e35306b5b9b5b19fdc7fa7c602d4ce36fa6abd
| | * [dev.link] all: clean up some TODOsCherry Zhang2019-11-011-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | Change-Id: Iae1ca888729014b6fec97d7bd7ae082dbceb9fe5 Reviewed-on: https://go-review.googlesource.com/c/go/+/204837 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
| | * [dev.link] all: merge branch 'master' into dev.linkThan McIntosh2019-11-019-11/+45
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | Fixed a couple of minor conflicts in lib.go and deadcode.go relating to debug logging. Change-Id: I58335fc42ab1f1f3409fd8354da4f26419e8fb22
| | * \ [dev.link] all: merge branch 'master' into dev.linkCherry Zhang2019-10-255-10/+133
| | |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The only conflict is in cmd/internal/obj/link.go and the resolution is trivial. Change-Id: Ic79b760865a972a0ab68291d06386531d012de86
| | * \ \ [dev.link] all: merge branch 'master' into dev.linkCherry Zhang2019-10-1810-5/+153
| | |\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clean merge. Change-Id: I94d5e621b98cd5b3e1f2007db83d52293edbd9ec
| | * | | | [dev.link] cmd: default to new object filesCherry Zhang2019-10-161-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Switch the default to new object files. Internal linking cgo is disabled for now, as it does not work yet in newobj mode. Shared libraries are also broken. Disable some tests that are known broken for now. Change-Id: I8ca74793423861d607a2aa7b0d89a4f4d4ca7671 Reviewed-on: https://go-review.googlesource.com/c/go/+/200161 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
* | | | | | cmd/compile: add signed indivisibility by power of 2 rulesBrian Kessler2019-11-071-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 44343c777c (CL 173557) added rules for handling divisibility checks for powers of 2 for signed integers, x%c ==0. This change adds the complementary indivisibility rules, x%c != 0. Fixes #34166 Change-Id: I87379e30af7aff633371acca82db2397da9b2c07 Reviewed-on: https://go-review.googlesource.com/c/go/+/194219 Run-TryBot: Brian Kessler <brian.m.kessler@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
* | | | | | math, cmd/compile: rename Fma to FMARuss Cox2019-11-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This API was added for #25819, where it was discussed as math.FMA. The commit adding it used math.Fma, presumably for consistency with the rest of the unusual names in package math (Sincos, Acosh, Erfcinv, Float32bits, etc). I believe that using an idiomatic Go name is more important here than consistency with these other names, most of which are historical baggage from C's standard library. Early additions like Float32frombits happened before "uppercase for export" (so they were originally like "float32frombits") and they were not properly reconsidered when we uppercased the symbols to export them. That's a mistake we live with. The names of functions we have added since then, and even a few that were legacy, are more properly Go-cased, such as IsNaN, IsInf, and RoundToEven, rather than Isnan, Isinf, and Roundtoeven. And also constants like MaxFloat32. For new API, we should keep using proper Go-cased symbols instead of minimally-upper-cased-C symbols. So math.FMA, not math.Fma. This API has not yet been released, so this change does not break the compatibility promise. This CL also modifies cmd/compile, since the compiler knows the name of the function. I could have stopped at changing the string constants, but it seemed to make more sense to use a consistent casing everywhere. Change-Id: I0f6f3407f41e99bfa8239467345c33945088896e Reviewed-on: https://go-review.googlesource.com/c/go/+/205317 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* | | | | | test: add tests for runtime.itab.initDmitry Vyukov2019-11-063-0/+106
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We seem to lack any tests for some corner cases of itab.init (multiple methods with the same name, breaking itab.init doesn't seem to fail any tests). We also lack tests that fix text of panics. Add more tests for itab.init. Change-Id: Id6b536179ba6b0d45c3cb9dc1c66b9311d0ab85e Reviewed-on: https://go-review.googlesource.com/c/go/+/202451 Run-TryBot: Dmitry Vyukov <dvyukov@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* | | | | cmd/compile: fix //go:uintptrescapes for basic method callsMatthew Dempsky2019-11-052-9/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The logic for keeping arguments alive for calls to //go:uintptrescapes functions was only applying to direct function calls. This CL changes it to also apply to direct method calls, which should address most uses of Proc.Call and LazyProc.Call. It's still an open question (#34684) whether other call forms (e.g., method expressions, or indirect calls via function values, method values, or interfaces). Fixes #34474. Change-Id: I874f97145972b0e237a4c9e8926156298f4d6ce0 Reviewed-on: https://go-review.googlesource.com/c/go/+/198043 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
* | | | | cmd/compile: add test for skipping empty init functionsCuong Manh Le2019-11-041-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CL 200958 adds skipping empty init function feature without any tests for it. A codegen test sounds ideal, but it's unlikely that we can make one for now, so use a program to manipulate runtime/proc.go:initTask directly. Updates #34869 Change-Id: I2683b9a1ace36af6861af02a3a9fb18b3110b282 Reviewed-on: https://go-review.googlesource.com/c/go/+/204217 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* | | | | runtime: ensure that Goexit cannot be aborted by a recursive panic/recoverDan Scales2019-11-041-0/+4
| |_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we do a successful recover of a panic, we resume normal execution by returning from the frame that had the deferred call that did the recover (after executing any remaining deferred calls in that frame). However, suppose we have called runtime.Goexit and there is a panic during one of the deferred calls run by the Goexit. Further assume that there is a deferred call in the frame of the Goexit or a parent frame that does a recover. Then the recovery process will actually resume normal execution above the Goexit frame and hence abort the Goexit. We will not terminate the thread as expected, but continue running in the frame above the Goexit. To fix this, we explicitly create a _panic object for a Goexit call. We then change the "abort" behavior for Goexits, but not panics. After a recovery, if the top-level panic is actually a Goexit that is marked to be aborted, then we return to the Goexit defer-processing loop, so that the Goexit is not actually aborted. Actual code changes are just panic.go, runtime2.go, and funcid.go. Adjusted the test related to the new Goexit behavior (TestRecoverBeforePanicAfterGoexit) and added several new tests of aborted panics (whose behavior has not changed). Fixes #29226 Change-Id: Ib13cb0074f5acc2567a28db7ca6912cfc47eecb5 Reviewed-on: https://go-review.googlesource.com/c/go/+/200081 Run-TryBot: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
* | | | cmd/compile: make duplicate index error distinguish arrays and slicesCuong Manh Le2019-11-013-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #35291 Change-Id: I11ae367b6e972cd9e7a22bbc2cb23d32f4d72b98 Reviewed-on: https://go-review.googlesource.com/c/go/+/204617 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* | | | cmd/compile/internal/gc: reword "declared and not used" error messageShenghou Ma2019-10-285-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "declared and not used" is technically correct, but might confuse the user. Switching "and" to "but" will hopefully create the contrast for the users: they did one thing (declaration), but not the other --- actually using the variable. This new message is still not ideal (specifically, declared is not entirely precise here), but at least it matches the other parsers and is one step in the right direction. Change-Id: I725c7c663535f9ab9725c4b0bf35b4fa74b0eb20 Reviewed-on: https://go-review.googlesource.com/c/go/+/203282 Run-TryBot: Minux Ma <minux@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* | | | test: add test for fixed internal compiler errorGiovanni Bajo2019-10-261-0/+20
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | Updates #35157 (the bug there was fixed by CL200861) Change-Id: I67069207b4cdc2ad4a475dd0bbc8555ecc5f534f Reviewed-on: https://go-review.googlesource.com/c/go/+/203598 Run-TryBot: Giovanni Bajo <rasky@develer.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
* | | cmd/compile, cmd/link, runtime: make defers low-cost through inline code and ↵Dan Scales2019-10-243-10/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | extra funcdata Generate inline code at defer time to save the args of defer calls to unique (autotmp) stack slots, and generate inline code at exit time to check which defer calls were made and make the associated function/method/interface calls. We remember that a particular defer statement was reached by storing in the deferBits variable (always stored on the stack). At exit time, we check the bits of the deferBits variable to determine which defer function calls to make (in reverse order). These low-cost defers are only used for functions where no defers appear in loops. In addition, we don't do these low-cost defers if there are too many defer statements or too many exits in a function (to limit code increase). When a function uses open-coded defers, we produce extra FUNCDATA_OpenCodedDeferInfo information that specifies the number of defers, and for each defer, the stack slots where the closure and associated args have been stored. The funcdata also includes the location of the deferBits variable. Therefore, for panics, we can use this funcdata to determine exactly which defers are active, and call the appropriate functions/methods/closures with the correct arguments for each active defer. In order to unwind the stack correctly after a recover(), we need to add an extra code segment to functions with open-coded defers that simply calls deferreturn() and returns. This segment is not reachable by the normal function, but is returned to by the runtime during recovery. We set the liveness information of this deferreturn() to be the same as the liveness at the first function call during the last defer exit code (so all return values and all stack slots needed by the defer calls will be live). I needed to increase the stackguard constant from 880 to 896, because of a small amount of new code in deferreturn(). The -N flag disables open-coded defers. '-d defer' prints out the kind of defer being used at each defer statement (heap-allocated, stack-allocated, or open-coded). Cost of defer statement [ go test -run NONE -bench BenchmarkDefer$ runtime ] With normal (stack-allocated) defers only: 35.4 ns/op With open-coded defers: 5.6 ns/op Cost of function call alone (remove defer keyword): 4.4 ns/op Text size increase (including funcdata) for go binary without/with open-coded defers: 0.09% The average size increase (including funcdata) for only the functions that use open-coded defers is 1.1%. The cost of a panic followed by a recover got noticeably slower, since panic processing now requires a scan of the stack for open-coded defer frames. This scan is required, even if no frames are using open-coded defers: Cost of panic and recover [ go test -run NONE -bench BenchmarkPanicRecover runtime ] Without open-coded defers: 62.0 ns/op With open-coded defers: 255 ns/op A CGO Go-to-C-to-Go benchmark got noticeably faster because of open-coded defers: CGO Go-to-C-to-Go benchmark [cd misc/cgo/test; go test -run NONE -bench BenchmarkCGoCallback ] Without open-coded defers: 443 ns/op With open-coded defers: 347 ns/op Updates #14939 (defer performance) Updates #34481 (design doc) Change-Id: I63b1a60d1ebf28126f55ee9fd7ecffe9cb23d1ff Reviewed-on: https://go-review.googlesource.com/c/go/+/202340 Reviewed-by: Austin Clements <austin@google.com>
* | | cmd/compile: recognize reflect.{Slice,String}Header for -d=checkptrMatthew Dempsky2019-10-211-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoids false positive pointer arithmetic panic. Fixes #35027. Change-Id: Idd008caaab25fcf739327ac50a021b835ef13def Reviewed-on: https://go-review.googlesource.com/c/go/+/202560 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* | | cmd/compile: add fma intrinsic for armsmasher1642019-10-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change introduces an arm intrinsic that generates the FMULAD instruction for the fused-multiply-add operation on systems that support it. System support is detected via cpu.ARM.HasVFPv4. A rewrite rule translates the generic intrinsic to FMULAD. Updates #25819. Change-Id: I8459e5dd1cdbdca35f88a78dbeb7d387f1e20efa Reviewed-on: https://go-review.googlesource.com/c/go/+/142117 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
* | | cmd/compile: add fma intrinsic for amd64smasher1642019-10-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To permit ssa-level optimization, this change introduces an amd64 intrinsic that generates the VFMADD231SD instruction for the fused-multiply-add operation on systems that support it. System support is detected via cpu.X86.HasFMA. A rewrite rule can then translate the generic ssa intrinsic ("Fma") to VFMADD231SD. The benchmark compares the software implementation (old) with the intrinsic (new). name old time/op new time/op delta Fma-4 27.2ns ± 1% 1.0ns ± 9% -96.48% (p=0.008 n=5+5) Updates #25819. Change-Id: I966655e5f96817a5d06dff5942418a3915b09584 Reviewed-on: https://go-review.googlesource.com/c/go/+/137156 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
* | | cmd/compile: introduce generic ssa intrinsic for fused-multiply-addsmasher1642019-10-211-0/+8
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to make math.FMA a compiler intrinsic for ISAs like ARM64, PPC64[le], and S390X, a generic 3-argument opcode "Fma" is provided and rewritten as ARM64: (Fma x y z) -> (FMADDD z x y) PPC64: (Fma x y z) -> (FMADD x y z) S390X: (Fma x y z) -> (FMADD z x y) Updates #25819. Change-Id: Ie5bc628311e6feeb28ddf9adaa6e702c8c291efa Reviewed-on: https://go-review.googlesource.com/c/go/+/131959 Run-TryBot: Akhil Indurti <aindurti@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>