aboutsummaryrefslogtreecommitdiff
path: root/test/nilptr3.go
AgeCommit message (Collapse)Author
2018-11-26cmd/compile: fix nilcheck for AIXClément Chigot
This commit adapts compile tool to create correct nilchecks for AIX. AIX allows to load a nil pointer. Therefore, the default nilcheck which issues a load must be replaced by a CMP instruction followed by a store at 0x0 if the value is nil. The store will trigger a SIGSEGV as on others OS. The nilcheck algorithm must be adapted to do not remove nilcheck if it's only a read. Stores are detected with v.Type.IsMemory(). Tests related to nilptr must be adapted to the previous changements. nilptr.go cannot be used as it's because the AIX address space starts at 1<<32. Change-Id: I9f5aaf0b7e185d736a9b119c0ed2fe4e5bd1e7af Reviewed-on: https://go-review.googlesource.com/c/144538 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2018-09-04cmd/compile: remove unnecessary nil-checkAlexey Naidonov
Removes unnecessary nil-check when referencing offset from an address. Suggested by Keith Randall in golang/go#27180. Updates golang/go#27180 Change-Id: I326ed7fda7cfa98b7e4354c811900707fee26021 Reviewed-on: https://go-review.googlesource.com/131735 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-30all: skip unsupported tests for js/wasmRichard Musiol
The general policy for the current state of js/wasm is that it only has to support tests that are also supported by nacl. The test nilptr3.go makes assumptions about which nil checks can be removed. Since WebAssembly does not signal on reading a null pointer, all nil checks have to be explicit. Updates #18892 Change-Id: I06a687860b8d22ae26b1c391499c0f5183e4c485 Reviewed-on: https://go-review.googlesource.com/110096 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-25cmd/compile: remove more nil ptr checks after newobjectKeith Randall
For code like the following (where x escapes): x := []int{1} We're currently generating a nil check. The line above is really 3 operations: t := new([1]int) t[0] = 1 x := t[:] We remove the nil check for t[0] = 1, but not for t[:]. Our current nil check removal rule is too strict about the possible memory arguments of the nil check. Unlike zeroing or storing to the result of runtime.newobject, the nilness of runtime.newobject is always false, even after other stores have happened in the meantime. Change-Id: I95fad4e3a59c27effdb37c43ea215e18f30b1e5f Reviewed-on: https://go-review.googlesource.com/58711 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-02-17cmd/compile: re-enable nilcheck removal in same blockCherry Zhang
Nil check removal in the same block is disabled due to issue 18725: because the values are not ordered, a nilcheck may influence a value that is logically before it. This CL re-enables same-block nilcheck removal by ordering values in store order first. Updates #18725. Change-Id: I287a38525230c14c5412cbcdbc422547dabd54f6 Reviewed-on: https://go-review.googlesource.com/35496 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2017-02-02cmd/compile: remove nil check for Zero/Move on 386, AMD64, S390XCherry Zhang
Fixes #18003. Change-Id: Iadcc5c424c64badecfb5fdbd4dbd9197df56182c Reviewed-on: https://go-review.googlesource.com/33421 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2017-01-20cmd/compile: don't use nilcheck information until the next blockKeith Randall
When nilcheck runs, the values in a block are not in any particular order. So any facts derived from examining the blocks shouldn't be used until we reach the next block. This is suboptimal as it won't eliminate nil checks within a block. But it's probably a better fix for now as it is a much smaller change than other strategies for fixing this bug. nilptr3.go changes are mostly because for this pattern: _ = *p _ = *p either nil check is fine to keep, and this CL changes which one the compiler tends to keep. There are a few regressions from code like this: _ = *p f() _ = *p For this pattern, after this CL we issue 2 nil checks instead of one. (For the curious, this happens because intra-block nil check elimination now falls to CSE, not nilcheck proper. The former pattern has two nil checks with the same store argument. The latter pattern has two nil checks with different store arguments.) Fixes #18725 Change-Id: I3721b494c8bc9ba1142dc5c4361ea55c66920ac8 Reviewed-on: https://go-review.googlesource.com/35485 Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-09-28cmd/compile: re-enable nilcheck removal for newobjectCherry Zhang
Also add compiler debug ouput and add a test. Fixes #15390. Change-Id: Iceba1414c29bcc213b87837387bf8ded1f3157f1 Reviewed-on: https://go-review.googlesource.com/30011 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2016-09-27cmd/compile: remove duplicate nilchecksKeith Randall
Mark nil check operations as faulting if their arg is zero. This lets the late nilcheck pass remove duplicates. Fixes #17242. Change-Id: I4c9938d8a5a1e43edd85b4a66f0b34004860bcd9 Reviewed-on: https://go-review.googlesource.com/29952 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-09-15test,cmd/compile: remove _ssa file suffixKeith Randall
Everything is SSA now. Update #16357 Change-Id: I436dbe367b863ee81a3695a7d653ba4bfc5b0f6c Reviewed-on: https://go-review.googlesource.com/29232 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-15test: make SSA tests unconditionalKeith Randall
Delete legacy backend tests, make SSA tests unconditional. Next CL will remove _ssa from the file names. Update #16357 Change-Id: I2a7f5dcbc69455f63b5e6e6b2725df26ab86c8dd Reviewed-on: https://go-review.googlesource.com/29231 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-17test: add test for CL 26831Cherry Zhang
Test nil check removal for access of PAUTOHEAP. Change-Id: Id739a9cda7cd3ff173bdcccfedcad93ee90711ef Reviewed-on: https://go-review.googlesource.com/27232 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-15[dev.ssa] cmd/compile, etc.: more ARM64 optimizations, and enable SSA by defaultCherry Zhang
Add more ARM64 optimizations: - use hardware zero register when it is possible. - use shifted ops. The assembler supports shifted ops but not documented, nor knows how to print it. This CL adds them. - enable fast division. This was disabled because it makes the old backend generate slower code. But with SSA it generates faster code. Turn on SSA by default, also adjust tests. Change-Id: I7794479954c83bb65008dcb457bc1e21d7496da6 Reviewed-on: https://go-review.googlesource.com/26950 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2016-08-10[dev.ssa] cmd/compile: implement GO386=387Keith Randall
Last part of the 386 SSA port. Modify the x86 backend to simulate SSE registers and instructions with 387 registers and instructions. The simulation isn't terribly performant, but it works, and the old implementation wasn't very performant either. Leaving to people who care about 387 to optimize if they want. Turn on SSA backend for 386 by default. Fixes #16358 Change-Id: I678fb59132620b2c47e993c1c10c4c21135f70c0 Reviewed-on: https://go-review.googlesource.com/25271 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2016-08-09[dev.ssa] cmd/compile: port SSA backend to amd64p32Keith Randall
It's not a new backend, just a PtrSize==4 modification of the existing AMD64 backend. Change-Id: Icc63521a5cf4ebb379f7430ef3f070894c09afda Reviewed-on: https://go-review.googlesource.com/25586 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2016-07-16[dev.ssa] cmd/compile: support NaCl in SSA for ARMCherry Zhang
NaCl code runs in sandbox and there are restrictions for its instruction uses (https://developer.chrome.com/native-client/reference/sandbox_internals/arm-32-bit-sandbox). Like the legacy backend, on NaCl, - don't use R9, which is used as NaCl's "thread pointer". - don't use Duff's device. - don't use indexed load/stores. - the assembler rewrites DIV/MOD to runtime calls, which on NaCl clobbers R12, so R12 is marked as clobbered for DIV/MOD. - other restrictions are satisfied by the assembler. Enable SSA specific tests on nacl/arm, and disable non-SSA ones. Updates #15365. Change-Id: I9262693ec6756b89ca29d3ae4e52a96fe5403b02 Reviewed-on: https://go-review.googlesource.com/24859 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-07-06[dev.ssa] cmd/compile: enable SSA on ARM by defaultCherry Zhang
As Josh mentioned in CL 24716, there has been requests for using SSA for ARM. SSA can still be disabled by setting -ssa=0 for cmd/compile, or partially enabled with GOSSAFUNC, GOSSAPKG, and GOSSAHASH. Not enable SSA by default on NaCl, which is not supported yet. Enable SSA-specific tests on ARM: live_ssa.go and nilptr3_ssa.go; disable non-SSA tests: live.go, nilptr3.go, and slicepot.go. Updates #15365. Change-Id: Ic2ca8d166aeca8517b9d262a55e92f2130683a16 Reviewed-on: https://go-review.googlesource.com/23953 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: David Chase <drchase@google.com>
2016-05-02all: make copyright headers consistent with one space after periodEmmanuel Odeke
Follows suit with https://go-review.googlesource.com/#/c/20111. Generated by running $ grep -R 'Go Authors. All' * | cut -d":" -f1 | while read F;do perl -pi -e 's/Go Authors. All/Go Authors. All/g' $F;done The code in cmd/internal/unvendor wasn't changed. Fixes #15213 Change-Id: I4f235cee0a62ec435f9e8540a1ec08ae03b1a75f Reviewed-on: https://go-review.googlesource.com/21819 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-22cmd/compile: don't nilcheck newobject and return values from mapaccess{1,2}Keith Randall
They are guaranteed to be non-nil, no point in inserting nil checks for them. Fixes #15390 Change-Id: I3b9a0f2319affc2139dcc446d0a56c6785ae5a86 Reviewed-on: https://go-review.googlesource.com/22291 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-04-08test: skip nilptr3 test on s390xMichael Munday
Fails for the same reason as ppc64 and mips64 (incomplete optimization). Change-Id: Ieb4d997fc27d4f2b756e63dd7f588abe10c0213a Reviewed-on: https://go-review.googlesource.com/20963 Reviewed-by: Bill O'Farrell <billotosyr@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-26[dev.ssa] test: remove extra tests from non-SSA buildsKeith Randall
non-SSA backends are all over the map as to whether nil checks get removed or not. amd64, 386, 386/387, arm are all subtly different. Remove these extra checks for now, they are in nilptr3_ssa.go so they won't get lost. Change-Id: I2e0051f488fb2cb7278c6fdd44cb9d68b5778345 Reviewed-on: https://go-review.googlesource.com/19961 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-26[dev.ssa] cmd/compile: get rid of nil checks before float loads/storesKeith Randall
Just like we do for integer loads/stores. Update #14511 Change-Id: Ic6ca6b54301438a5701ea5fb0be755451cb24d45 Reviewed-on: https://go-review.googlesource.com/19923 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Keith Randall <khr@golang.org>
2015-11-16[dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranchKeith Randall
Conflicts: src/cmd/compile/internal/gc/racewalk.go src/cmd/internal/obj/stack.go src/cmd/internal/obj/x86/obj6.go src/runtime/stack.go test/nilptr3.go test/nosplit.go Change-Id: Ie6053eb1577fd73e8243651f25c0f1fc765ae660
2015-11-12test: fix nosplit.go, fixedbugs/issue11656.go and skip two tests for mips64{,le}Yao Zhang
Skip fixedbugs/issue10607.go because external linking is not supported yet. Skip nilptr3.go because of issue #9058 (same as ppc64). Change-Id: Ib3dfbd9a03ee4052871cf57c74b3cc5e745e1f80 Reviewed-on: https://go-review.googlesource.com/14461 Reviewed-by: Minux Ma <minux@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Minux Ma <minux@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-30[dev.ssa] cmd/compile: default compile+test with SSADavid Chase
Some tests disabled, some bifurcated into _ssa and not, with appropriate logging added to compiler. "tests/live.go" in particular needs attention. SSA-specific testing removed, since it's all SSA now. Added "-run_skips" option to tests/run.go to simplify checking whether a test still fails (or how it fails) on a skipped platform. The compiler now compiles with SSA by default. If you don't want SSA, specify GOSSAHASH=n (or N) as an environment variable. Function names ending in "_ssa" are always SSA-compiled. GOSSAFUNC=fname retains its "SSA for fname, log to ssa.html" GOSSAPKG=pkg only has an effect when GOSSAHASH=n GOSSAHASH=10101 etc retains its name-hash-matching behavior for purposes of debugging. See #13068 Change-Id: I8217bfeb34173533eaeb391b5f6935483c7d6b43 Reviewed-on: https://go-review.googlesource.com/16299 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: David Chase <drchase@google.com>
2015-04-08cmd/7g: enable peephole optimizerShenghou Ma
Based on cmd/9g/peep.go. Go 1 benchmark comparison: benchmark old ns/op new ns/op delta BenchmarkBinaryTree17 24328574000 18351639000 -24.57% BenchmarkFannkuch11 17029365000 10817758000 -36.48% BenchmarkFmtFprintfEmpty 291 223 -23.37% BenchmarkFmtFprintfString 1073 799 -25.54% BenchmarkFmtFprintfInt 1024 778 -24.02% BenchmarkFmtFprintfIntInt 1654 1277 -22.79% BenchmarkFmtFprintfPrefixedInt 1360 1083 -20.37% BenchmarkFmtFprintfFloat 2272 1415 -37.72% BenchmarkFmtManyArgs 5933 4742 -20.07% BenchmarkGobDecode 53166003 38584736 -27.43% BenchmarkGobEncode 37930156 30074874 -20.71% BenchmarkGzip 1880638900 1286832100 -31.57% BenchmarkGunzip 386343633 292194480 -24.37% BenchmarkHTTPClientServer 237077 179776 -24.17% BenchmarkJSONEncode 101731690 73116925 -28.13% BenchmarkJSONDecode 344655360 241277600 -29.99% BenchmarkMandelbrot200 28329778 12950809 -54.29% BenchmarkGoParse 21670755 16554244 -23.61% BenchmarkRegexpMatchEasy0_32 557 484 -13.11% BenchmarkRegexpMatchEasy0_1K 4687 4832 +3.09% BenchmarkRegexpMatchEasy1_32 539 483 -10.39% BenchmarkRegexpMatchEasy1_1K 5100 5080 -0.39% BenchmarkRegexpMatchMedium_32 796 651 -18.22% BenchmarkRegexpMatchMedium_1K 233099 182047 -21.90% BenchmarkRegexpMatchHard_32 13202 9897 -25.03% BenchmarkRegexpMatchHard_1K 401027 303602 -24.29% BenchmarkRevcomp 3837679666 2816546600 -26.61% BenchmarkTemplate 440608300 324831040 -26.28% BenchmarkTimeParse 1460 1019 -30.21% BenchmarkTimeFormat 1609 1174 -27.04% benchmark old MB/s new MB/s speedup BenchmarkGobDecode 14.44 19.89 1.38x BenchmarkGobEncode 20.24 25.52 1.26x BenchmarkGzip 10.32 15.08 1.46x BenchmarkGunzip 50.23 66.41 1.32x BenchmarkJSONEncode 19.07 26.54 1.39x BenchmarkJSONDecode 5.63 8.04 1.43x BenchmarkGoParse 2.67 3.50 1.31x BenchmarkRegexpMatchEasy0_32 57.38 66.05 1.15x BenchmarkRegexpMatchEasy0_1K 218.47 211.91 0.97x BenchmarkRegexpMatchEasy1_32 59.29 66.21 1.12x BenchmarkRegexpMatchEasy1_1K 200.76 201.54 1.00x BenchmarkRegexpMatchMedium_32 1.26 1.53 1.21x BenchmarkRegexpMatchMedium_1K 4.39 5.62 1.28x BenchmarkRegexpMatchHard_32 2.42 3.23 1.33x BenchmarkRegexpMatchHard_1K 2.55 3.37 1.32x BenchmarkRevcomp 66.23 90.24 1.36x BenchmarkTemplate 4.40 5.97 1.36x Fixes #10105. Change-Id: I353cc9fdf922e431821508c9dbbe4d9a85d64bd4 Signed-off-by: Shenghou Ma <minux@golang.org> Reviewed-on: https://go-review.googlesource.com/8471 Reviewed-by: Dave Cheney <dave@cheney.net>
2015-03-16test: fix nosplit test, and disable nilptr3 test on arm64Aram Hăvărneanu
Change-Id: I5d40e04395de743a8fdcfa8bdc0e580729bc66a3 Reviewed-on: https://go-review.googlesource.com/7147 Reviewed-by: Minux Ma <minux@golang.org> Reviewed-by: Dave Cheney <dave@cheney.net> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-05all: power64 is now ppc64Russ Cox
Fixes #8654. LGTM=austin R=austin CC=golang-codereviews https://golang.org/cl/180600043
2014-11-03[dev.power64] test: disable nilptr3 test on power64xAustin Clements
The remaining failures in this test are because of incomplete optimization support on power64x. Tracked in issue 9058. LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/168130043
2014-05-15cmd/gc: correct handling of globals, func args, resultsRuss Cox
Globals, function arguments, and results are special cases in registerization. Globals must be flushed aggressively, because nearly any operation can cause a panic, and the recovery code must see the latest values. Globals also must be loaded aggressively, because nearly any store through a pointer might be updating a global: the compiler cannot see all the "address of" operations on globals, especially exported globals. To accomplish this, mark all globals as having their address taken, which effectively disables registerization. If a function contains a defer statement, the function results must be flushed aggressively, because nearly any operation can cause a panic, and the deferred code may call recover, causing the original function to return the current values of its function results. To accomplish this, mark all function results as having their address taken if the function contains any defer statements. This causes not just aggressive flushing but also aggressive loading. The aggressive loading is overkill but the best we can do in the current code. Function arguments must be considered live at all safe points in a function, because garbage collection always preserves them: they must be up-to-date in order to be preserved correctly. Accomplish this by marking them live at all call sites. An earlier attempt at this marked function arguments as having their address taken, which disabled registerization completely, making programs slower. This CL's solution allows registerization while preserving safety. The benchmark speedup is caused by being able to registerize again (the earlier CL lost the same amount). benchmark old ns/op new ns/op delta BenchmarkEqualPort32 61.4 56.0 -8.79% benchmark old MB/s new MB/s speedup BenchmarkEqualPort32 521.56 570.97 1.09x Fixes #1304. (again) Fixes #7944. (again) Fixes #7984. Fixes #7995. LGTM=khr R=golang-codereviews, khr CC=golang-codereviews, iant, r https://golang.org/cl/97500044
2013-09-17cmd/gc: eliminate redundant &x.Field nil checksRuss Cox
This eliminates ~75% of the nil checks being emitted, on all architectures. We can do better, but we need a bit more general support from the compiler, and I don't want to do that so close to Go 1.2. What's here is simple but effective and safe. A few small code generation cleanups were required to make the analysis consistent on all systems about which nil checks are omitted, at least in the test. Fixes #6019. R=ken2 CC=golang-dev https://golang.org/cl/13334052