1
0
mirror of https://github.com/golang/go synced 2024-10-05 16:51:21 -06:00
Commit Graph

6973 Commits

Author SHA1 Message Date
Michael Hudson-Doyle
b0344e9fd5 cmd/internal/obj, cmd/link, runtime: a saner model for TLS on arm
this leaves lots of cruft behind, will delete that soon

Change-Id: I12d6b6192f89bcdd89b2b0873774bd3458373b8a
Reviewed-on: https://go-review.googlesource.com/14196
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-10 19:49:13 +00:00
Yao Zhang
b456aac388 cmd/objdump: skip TestDisasm* for mips64{,le}
Disassembler for mips64 is not supported yet.

Change-Id: Ie923dd1e37fed47fc395b9d1cd9194e55020bee5
Reviewed-on: https://go-review.googlesource.com/14459
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-10 18:27:09 +00:00
Yao Zhang
1153737e86 cmd/go: skip part of TestNoteReading for mips64{,le}
Because external linking is not supported for now.

Change-Id: Icdd8f3cb3bfb781a990e529fce9129d91e98a9ec
Reviewed-on: https://go-review.googlesource.com/14457
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-10 18:26:30 +00:00
Russ Cox
d8384e9a8f cmd/vet: diagnose plain assignment in copylock detector
It went out of its way to look for implicit assignments
but never checked explicit assignments.

This detects the root bug for #12099.

Change-Id: I6a6e774cc38749ea8be7cfd58ba6421247b67000
Reviewed-on: https://go-review.googlesource.com/13646
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
2015-09-10 16:55:51 +00:00
Dave Cheney
81a4bbffbf cmd/go: use RawToken to parse remote package metadata
CL 14315 broke the tests for parsing loosely formed remote package
metadata. Switch the parsing to use RawToken to recover the previous
behaviour that Token provided.

It could be argued that the parser should be stricter, but as remote
metadata has been readable with the parser for several years, it is
safer to change the parser to continue to accept the samples provided
in the test cases.

Change-Id: I2a3ba1757d3cff53b1a1c4386276955bb46cf8cd
Reviewed-on: https://go-review.googlesource.com/14482
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-10 07:30:43 +00:00
Dave Cheney
bab01a0b4b cmd/compile: convert typecheckdefstack to []*Node
This one of a set of changes to make the transition away from NodeList
easier by removing cases in which NodeList doesn't act semi-trivially like a
[]*Node.

This CL was originally prepared by Josh Bleecher Snyder <josharian@gmail.com>.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: Ie02d2cf35f1e8438c6e9dc1d5fba51e8adde1bc0
Reviewed-on: https://go-review.googlesource.com/14480
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-10 05:37:22 +00:00
Todd Neal
def7c65b70 [dev.ssa] cmd/compile/internal/ssa: implement OCFUNC
Change-Id: Ieb9cddf8876bf8cd5ee1705d9210d22c3959e8cc
Reviewed-on: https://go-review.googlesource.com/14329
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Todd Neal <todd@tneal.org>
2015-09-10 00:25:31 +00:00
Todd Neal
adba6c4fdf [dev.ssa] cmd/compile/internal/ssa: treat -0.0 literal as 0.0
This matches existing behavior, see issue #2196

Change-Id: Ifa9359b7c821115389f337a57de355c5ec23be8f
Reviewed-on: https://go-review.googlesource.com/14261
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-10 00:25:18 +00:00
David Chase
2a29576562 [dev.ssa] cmd/compile: fix N^2 dominator queries in CSE
Added tree numbering data structure.
Changed dominator query in CSE.
Removed skip-for-too-big patch in CSE.
Passes all.bash.

Change-Id: I98d7c61b6015c81f5edab553615db17bc7a58d68
Reviewed-on: https://go-review.googlesource.com/14326
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-09 23:31:42 +00:00
Keith Randall
00c638d243 runtime: on map update, don't overwrite key if we don't need to.
Keep track of which types of keys need an update and which don't.

Strings need an update because the new key might pin a smaller backing store.
Floats need an update because it might be +0/-0.
Interfaces need an update because they may contain strings or floats.

Fixes #11088

Change-Id: I9ade53c1dfb3c1a2870d68d07201bc8128e9f217
Reviewed-on: https://go-review.googlesource.com/10843
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-09 21:06:49 +00:00
Keith Randall
8a1f6217c5 [dev.ssa] cmd/compile/internal/ssa: implement ORETJMP
Change-Id: I352c7b9aab053959bc74c15861339e1dbe545ddc
Reviewed-on: https://go-review.googlesource.com/14404
Reviewed-by: David Chase <drchase@google.com>
2015-09-09 20:33:35 +00:00
Rob Pike
cf3134a017 cmd/doc: the builtin package should always show unexported symbols
Trivial fix: set unexported=true for builtin.
Godoc itself has a similar hack.

Fixes #12541

Change-Id: Ib701f867d117931eb6ec6de223941b52eb6cd4a7
Reviewed-on: https://go-review.googlesource.com/14441
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-09 19:46:08 +00:00
Keith Randall
fd8c71be86 [dev.ssa] cmd/compile/internal/ssa: eval defer args before setting argsize and func
Evaluating args can overwrite arg area, so we can't write argsize and func
until args are evaluated.

Fixes test/recover.go, test/recover1.go, and test/fixedbugs/issue4066.go

Change-Id: I862e4934ccdb8661431bcc3e1e93817ea834ea3f
Reviewed-on: https://go-review.googlesource.com/14405
Reviewed-by: David Chase <drchase@google.com>
2015-09-09 18:16:53 +00:00
Keith Randall
1ca7a64a0d cmd/compile/internal/gc: handle weird map literals in key dedup
We compute whether two keys k1 and k2 in a map literal are duplicates by
constructing the expression OEQ(k1, k2) and calling the constant
expression evaluator on that expression, then extracting the boolean
result.

Unfortunately, the constant expression evaluator can fail for various
reasons.  I'm not really sure why it is dying in the case of 12536, but
to be safe we should use the result only if we get a constant back (if
we get a constant back, it must be boolean).  This probably isn't a
permanent fix, but it should be good enough for 1.5.2.

A permanent fix would be to ensure that the constant expression
evaluator can always work for map literal keys, and if not the compiler
should generate an error saying that the key isn't a constant (or isn't
comparable to some specific other key).

This patch has the effect of allowing the map literal to compile when
constant eval of the OEQ fails.  If the keys are really equal (which the
map impl will notice at runtime), one will overwrite the other in the
resulting map.  Not great, but better than a compiler crash.

Fixes #12536

Change-Id: Ic151a5e3f131c2e8efa0c25c9218b431c55c1b30
Reviewed-on: https://go-review.googlesource.com/14400
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-09 17:50:52 +00:00
Marvin Stenger
05c35ac5d1 cmd/compile/internal/gc: convert fields of TempVar to bool
Convert two fields of struct TempVar in popt.go from uint8 to bool.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I1aa14313e0241a4e9cadd63c6c681ed4e965a9a3
Reviewed-on: https://go-review.googlesource.com/14377
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-09 17:03:02 +00:00
Marvin Stenger
a20fbe8e18 cmd/compile/internal/gc: convert fields of Symlink to bool
Convert two fields of struct Symlink in subr.go from uint8 to bool.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I913006f41605b17b0d82fe358ee773f6ecaa681c
Reviewed-on: https://go-review.googlesource.com/14378
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-09 16:07:51 +00:00
Keith Randall
a7cfc759f2 [dev.ssa] cmd/compile/internal/ssa: handle returns correctly
Make sure that return blocks take a store as their control.  Without
this, code was getting inserted between the return and exit blocks.

Use AEND to mark the end of code.  The live variable analysis gets
confused when routines end like:
    JMP earlier
    RET
because the RET is unreachable.  The RET was incorrectly added to the
last basic block, rendering the JMP invisible to the CFG builder.

Change-Id: I91b32c8b37075347243ff039b4e4385856fba7cd
Reviewed-on: https://go-review.googlesource.com/14398
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-09-09 04:19:14 +00:00
Keith Randall
1c2975c305 [dev.ssa] cmd/compile/internal/gc: avoid generating test binary file
Using the main package causes a binary to be generated.  That binary
clutters up git listings.

Use a non-main package instead, so the results of a successful
compilation are thrown away.

Change-Id: I3ac91fd69ad297a5c0fe035c22fdef290b7dfbc4
Reviewed-on: https://go-review.googlesource.com/14399
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-09 04:05:09 +00:00
Michael Hudson-Doyle
f7b66fffc5 cmd/dist, cmd/link: force external linking for shared libs on arm
Also run testcshared.

Fixes #12425

Change-Id: I5baea8d772d3462f945aab96260b4197dbb20c0a
Reviewed-on: https://go-review.googlesource.com/14143
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-09 01:42:22 +00:00
Dave Cheney
fd50db2a66 cmd/internal/obj: remove unused code
Following on from CL 14350, remove the remaining dead code from data.go.

Also leave a TODO to be addressed later (with a unit test) to reduce
the overhead of SymGrow.

Change-Id: Iebad775b1280b54b89e87a3a073ca8af19a8bfba
Reviewed-on: https://go-review.googlesource.com/14359
Run-TryBot: Dave Cheney <dave@cheney.net>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-09 00:39:36 +00:00
Michael Hudson-Doyle
5cbca8d84b cmd/internal/ld: put read-only relocated data into .data.rel.ro when making a shared object
Currently Go produces shared libraries that cannot be shared between processes
because they have relocations against the text segment (not text section). This
fixes this by moving some data to sections with magic names recognized by the
static linker.

The change in genasmsym to add STYPELINK to the switch should fix things on
darwin/arm64.

Fixes #10914
Updates #9210

Change-Id: Iab4a6678dd04cec6114e683caac5cf31b1063309
Reviewed-on: https://go-review.googlesource.com/14306
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-08 23:34:16 +00:00
Keith Randall
0ec72b6b9d [dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Semi-regular merge of master into dev.ssa.

Change-Id: I48aa17700096a14f2a20ad07491ebfcd7529f6d5
2015-09-08 15:59:09 -07:00
Shenghou Ma
14f919578d cmd/compile/internal/mips64: copy cmd/compile/internal/ppc64
Just a mechanical copy, no code changes.
This is to reduce code difference when adding the mips64 port.

Change-Id: Id06e975f414a7b09f4827167b30813b228a3bfaf
Reviewed-on: https://go-review.googlesource.com/14324
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-08 22:40:16 +00:00
Shenghou Ma
5cc86c6f55 cmd/internal/obj/mips: copy cmd/internal/obj/ppc64
Just a mechanical copy with filename renames, no code changes.
This is to reduce code difference when adding the mips64 port.

Change-Id: Id06e975f414a7b09f4827167b30813b228a3bfae
Reviewed-on: https://go-review.googlesource.com/14323
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-08 22:39:56 +00:00
Michael Hudson-Doyle
69a143e388 cmd/internal/obj: remove dead code and small cleanups
Change-Id: I88fa0cc245a2141af04acced8716e08b1133abd1
Reviewed-on: https://go-review.googlesource.com/14350
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-08 21:04:43 +00:00
Alexandru Moșoi
c684d4d26c [dev.ssa] cmd/compile/internal/ssa: fix string slice types.
Change-Id: I28bc6373bb42d9abf4f179664dbaab8d514a6ab9
Reviewed-on: https://go-review.googlesource.com/14376
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-08 19:13:22 +00:00
Keith Randall
ca9e450bed [dev.ssa] cmd/compile/internal/ssa: fix defer in functions with no return
The after-defer test jumps to a deferreturn site.  Some functions
(those with infinite loops) have no deferreturn site.  Add one
so we have one to jump to.

Change-Id: I505e7f3f888f5e7d03ca49a3477b41cf1f78eb8a
Reviewed-on: https://go-review.googlesource.com/14349
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-09-08 17:57:10 +00:00
Marvin Stenger
9ac0fff70a cmd/compile/internal/gc: convert fields of Type to bool
Convert some fields of struct Type in go.go from uint8 to bool.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I0a6c53f8ee686839b5234010ee2de7ae3940d499
Reviewed-on: https://go-review.googlesource.com/14370
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-08 17:15:08 +00:00
Marvin Stenger
e03c7896a7 cmd/compile/internal/gc: convert fields of Pkg to bool
Convert Pkg.Imported, Pkg.Exported, Pkg.Direct from uint8/int8/int8 to bool.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I67a71f1186ff9737c03eca413f7d35d8a79ebc9b
Reviewed-on: https://go-review.googlesource.com/14371
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-08 15:53:06 +00:00
Todd Neal
8d081679d5 [dev.ssa] test: ensure that all current tests run
Some of the test files were missing, so add them.

Change-Id: Ifac248edf33e1e4ccd82355f596d74eab4ff01a2
Reviewed-on: https://go-review.googlesource.com/14328
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-09-08 09:27:31 +00:00
Håvard Haugen
259466452d cmd/compile/internal/gc: unexport and make Hasdefer a bool
Passes go build -a -toolexec 'toolstash -cmp' std cmd.

Change-Id: I804ee4252fa9be78cb277faf7f467e6c9cfdd4a6
Reviewed-on: https://go-review.googlesource.com/14319
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-08 05:45:29 +00:00
Marvin Stenger
704e05c6ec cmd/compile/internal/gc: remove unused field Type.Siggen
Remove unused field Type.Siggen in go.go.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: Ia61fe65a226c913fbf4a11a71d7453c56aa46c0e
Reviewed-on: https://go-review.googlesource.com/14372
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-08 05:28:37 +00:00
Håvard Haugen
391cc54da8 cmd/compile: make importlist a []*Node instead of *NodeList
Passes go build -a -toolexec 'toolstash -cmp' std.

Change-Id: Ica62765d3c1ef052afed34da1b3ac3f80646cc55
Reviewed-on: https://go-review.googlesource.com/14318
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-08 03:41:24 +00:00
Dave Cheney
8937780c8a cmd/compile/internal/gc: convert Type.Broke into a bool
Convert Type.Broke from a uint8 to a boolean

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I44e7548c71b00467e36576bdf62933c42555a21a
Reviewed-on: https://go-review.googlesource.com/14307
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Håvard Haugen <havard.haugen@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-08 03:17:10 +00:00
Dave Cheney
8712e1867b cmd/compile/internal/gc: convert Label.Used to bool
Convert Label.Used to a boolean. Also move the field to the
bottom of the struct to avoid padding.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: If09ee92f9d54dce807e7b862cf771005daed810d
Reviewed-on: https://go-review.googlesource.com/14308
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-07 21:35:06 +00:00
Keith Randall
3fa0a75a02 [dev.ssa] cmd/compile/internal/ssa: large object load/store vs. vardef
VarDef declarations are getting in the way of rewriting load/store
pairs into moves.  This change fixes that, albeit in a really hacky way.
Better options would be appreciated.

Increases coverage during make.bash from 67% to 71%.

Change-Id: I336e967687e2238c7d0d64e3b37132a731ad15c3
Reviewed-on: https://go-review.googlesource.com/14347
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-09-07 21:05:22 +00:00
Todd Neal
6bf383c7b3 [dev.ssa] cmd/compile: clean up nilcheck logic
Be more clear about the two conditions that we care about:
1) a block that performs a nil check (OpIsNonNil), which may be removed
2) a block that is the non-nil sucessor for an OpIsNonNil block

Now we only care about removing nilchecks for two scenarios:
- a type 1 block is dominated by a type 2 block for the same value
- a block is both type 1 and type 2 for the same value

Fixes math/big.

Change-Id: I50018a4014830461ddfe2a2daf588468e4a8f0b4
Reviewed-on: https://go-review.googlesource.com/14325
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-07 20:04:59 +00:00
Josh Bleecher Snyder
ad5ceafa2c [dev.ssa] cmd/compile: update SSA todos
Change-Id: I1271c015e602cd7ec92bf24f019dd8839b3180fc
Reviewed-on: https://go-review.googlesource.com/14346
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-07 18:06:37 +00:00
Marvin Stenger
932c1e3dd3 cmd/compile/internal: some janitoring
Nicer swaps, loops (removed tmp variables). Use of bool instead of int.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I541904c74b57297848decc51a8a4913a8eca4af3
Reviewed-on: https://go-review.googlesource.com/14316
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-07 17:42:48 +00:00
Josh Bleecher Snyder
fa5fe19137 [dev.ssa] cmd/compile: implement OIMAG and OREAL
Change-Id: I17c83f6552367d42d48c1ec62fbb494f010fd866
Reviewed-on: https://go-review.googlesource.com/14343
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-07 16:05:25 +00:00
Dave Cheney
60f0345667 cmd/dist: fix mkzversion to produce gofmt'd output
Fix mkzversion to produce correctly formatted runtime/zversion.go.

Change-Id: Ie6bcd361a2f2e390b7f6c4980fcae2c41bb7e52f
Reviewed-on: https://go-review.googlesource.com/14355
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-07 06:12:21 +00:00
Josh Bleecher Snyder
1792b36310 [dev.ssa] cmd/compile: implement OEFACE
Change-Id: I32953c4e1d82795bacba9eb94d65cd2e26bfeb87
Reviewed-on: https://go-review.googlesource.com/14339
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-09-07 01:54:38 +00:00
Josh Bleecher Snyder
e22ae879d3 [dev.ssa] cmd/compile: implement OCHECKNIL
Change-Id: Ifb6b2ad6078ad084b73c0e785e748e92139684e2
Reviewed-on: https://go-review.googlesource.com/14338
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-07 01:54:16 +00:00
Dave Cheney
dab0dac01a cmd/compile: convert typecheck_stack to []*Node
This one of a set of changes to make the transition away from NodeList
easier by removing cases in which NodeList doesn't act semi-trivially like a
[]*Node.

This CL was originally prepared by Josh Bleecher Snyder <josharian@gmail.com>.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I4d041b343952f4a31f3150fd70669e08fcaa74f8
Reviewed-on: https://go-review.googlesource.com/14305
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-06 23:50:51 +00:00
Keith Randall
c3eb1a7e8a [dev.ssa] cmd/compile/internal/gc: handle local function declarations
They are already handled by the frontend, we just need to
skip them when we see them in ssa.

Change-Id: I309d91552f96a761f8d429a2cab3a47d200ca9e5
Reviewed-on: https://go-review.googlesource.com/14341
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-06 23:41:10 +00:00
Josh Bleecher Snyder
95bb89f6dd [dev.ssa] cmd/compile: fix build
CL 14337 made SSA support fixedbugs/issue9604b.go.
That test contains > 40k blocks.
This made the O(n^2) dom algorithm fail to terminate
in a reasonable length of time, breaking the build.

For the moment, cap the number of blocks
to fix the build.

This will be reverted when a more efficient
dom algorithm is put in place,
which will be soon.

Change-Id: Ia66c2629481d29d06655ec54d1deff076b0422c6
Reviewed-on: https://go-review.googlesource.com/14342
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-09-06 22:08:14 +00:00
Josh Bleecher Snyder
4178f20776 [dev.ssa] cmd/compile: implement OPLUS
Change-Id: Iaf282211a717e38b05e5d2661d400d465decad50
Reviewed-on: https://go-review.googlesource.com/14337
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-06 03:46:51 +00:00
Keith Randall
9569b957cb [dev.ssa] cmd/compile/internal/gc: implement go and defer
TODO: for now, just function calls.  Do method and interface calls.

Change-Id: Ib262dfa31cb753996cde899beaad4dc2e66705ac
Reviewed-on: https://go-review.googlesource.com/14035
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-09-06 02:42:24 +00:00
Josh Bleecher Snyder
6b9b618787 [dev.ssa] cmd/compile: run std tests with SSA codegen as part of all.bash
Todd Neal has made all the stdlib tests pass.
Now the trybots and build dashboard can
help us keep them passing.

All of this code will be unwound bit by bit
as SSA matures and then becomes the default.

Change-Id: I52ac7e72a87d329ccce974d6671c054374828d11
Reviewed-on: https://go-review.googlesource.com/14294
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-05 20:12:23 +00:00
Didier Spezia
63e2bed0ab cmd/asm: fix another infinite loop in register list parser
The code parsing register lists involves an inner loop on
each range defined by the lo,hi bounds. The condition on
this loop (for lo<=hi) is fragile, because the bounds
are unsigned 16 bits numbers.

In some corner cases, the calculated upper bound is 2^16-1
leading to an infinite loop.

Parsing operand `[):[o-FP` results in:
- an infinite loop for non ARM architectures
- the generation of almost 2^16 errors for the ARM architecture
  (which are then ignored)

This CL improves the code in 3 ways:
- bail out early when parsing non R prefixed registers
- make sure the register index is never negative
- make sure the number of iterations is limited by the
  maximum size of the range (as a defensive measure).

Fixes #12469

Change-Id: Ib1e7e36fb8ad5a3a52c50fc6219d3cfe2b39cc34
Reviewed-on: https://go-review.googlesource.com/14314
Reviewed-by: Rob Pike <r@golang.org>
2015-09-05 18:57:11 +00:00
Keith Randall
d2107fc987 [dev.ssa] cmd/runtime: generate gc bitmaps for SSA-compiled code
This change is all about leveraging the gc bitmap generation
that is already done by the current compiler.  We rearrange how
stack allocation is done so that we generate a variable declaration
for each spill.  We also reorganize how args/locals are recorded
during SSA.  Then we can use the existing allocauto/defframe to
allocate the stack frame and liveness to make the gc bitmaps.

With this change, stack copying works correctly and we no longer
need hacks in runtime/stack*.go to make tests work.  GC is close
to working, it just needs write barriers.

Change-Id: I990fb4e3fbe98850c6be35c3185a1c85d9e1a6ba
Reviewed-on: https://go-review.googlesource.com/13894
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-09-05 06:41:05 +00:00
Dave Cheney
22452ac592 cmd/compile: use []*Node instead of NodeList in bottomUpVisitor
This one of a set of changes to make the transition away from NodeList
easier by removing cases in which NodeList doesn't act semi-trivially like a
[]*Node.

This CL was originally prepared by Josh Bleecher Snyder <josharian@gmail.com>.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I582ff8b077eb384b84721a1edb0c1efbc0c40059
Reviewed-on: https://go-review.googlesource.com/14304
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-05 04:34:55 +00:00
David Chase
d052bbd051 [dev.ssa] cmd/compile: cleanup fp conversions in ssa.go
Change to table-driven instead of branchy code; leads to
net reduction in lines, easier to understand what happens,
easier to modify code if we want option to exclude generation
of branchy cases.

Doesn't appear to scale for 8x8 case of integer types.

Change-Id: Ib40104b149d30bb329c5782f6cac45c75743e768
Reviewed-on: https://go-review.googlesource.com/14163
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-05 02:39:32 +00:00
Josh Bleecher Snyder
a3f72956f1 [dev.ssa] cmd/compile: add allocs to pass stats
Also, improve HTML formatting.

Change-Id: I07e2482a30862e2091707f260a2c43d6e9a85d97
Reviewed-on: https://go-review.googlesource.com/14333
Reviewed-by: Todd Neal <todd@tneal.org>
2015-09-05 02:25:42 +00:00
Josh Bleecher Snyder
1b5ffda01e [dev.ssa] cmd/compile: minor code cleanup
Change-Id: I9c84f5ca18745fb2358494c6944bf7ddd05cf8f0
Reviewed-on: https://go-review.googlesource.com/14332
Reviewed-by: Todd Neal <todd@tneal.org>
2015-09-05 02:25:25 +00:00
Dave Cheney
703bd83623 cmd/compile: use []*Node instead of NodeList in sinit
This is a first of a set of changes to make the transition away from NodeList
easier by removing cases in which NodeList doesn't act semi-trivially like a
[]*Node.

This CL was originally prepared by Josh Bleecher Snyder <josharian@gmail.com>.

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: Iad10b75e42b5b24e1694407841282fa3bab2dc9f
Reviewed-on: https://go-review.googlesource.com/14232
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-05 02:25:01 +00:00
Todd Neal
ec8a597cd2 [dev.ssa] cmd/compile: rewrite user nil check as OpIsNonNil
Rewite user nil checks as OpIsNonNil so our nil check elimination pass
can take advantage and remove redundant checks.

With make.bash this removes 10% more nilchecks (34110 vs 31088).

Change-Id: Ifb01d1b6d2d759f5e2a5aaa0470e1d5a2a680212
Reviewed-on: https://go-review.googlesource.com/14321
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-09-05 01:06:30 +00:00
Robert Griesemer
ace303297f cmd/compile/internal/gc: fix go.y (rename of Fatal -> Fatalf)
Also go generate to update generated files.

Change-Id: I049708db93455f0030ba5afc6f218fde6220958d
Reviewed-on: https://go-review.googlesource.com/14331
Reviewed-by: Damien Neil <dneil@google.com>
2015-09-05 00:01:33 +00:00
Keith Randall
617e892b87 [dev.ssa] cmd/compile: teach live variable analysis about LEAW
SSA uses this opcode, the old compiler doesn't.

Change-Id: Ic3dde6216496b4b89d570584d34cb0971fdf379d
Reviewed-on: https://go-review.googlesource.com/14330
Reviewed-by: Minux Ma <minux@golang.org>
2015-09-04 20:28:02 +00:00
Shawn Walker-Salas
4f74de1e4d cmd/go: fix Go buildid reading on Solaris
TestNoteReading fails on Solaris with linkmode=external due to some
assumptions made about how ELF .note sections are written by some
linkers.

On current versions of Solaris and older derivatives, SHF_ALLOC is
intentionally ignored for .note sections unless the .note section is
assigned to the text segment via a mapfile.  Also, if .note sections
are assigned to the text segment, no PT_NOTE program header will be
created thwarting Go's attempts at attempting to quickly find the
.note.

Furthermore, Go assumes that the relevant note segment will be placed
early in the file while the Solaris linker currently places the note
segment last in the file, additionally thwarting Go's optimisation
attempts that read only the first 16KB of the file to find the
buildid.

The fix is to detect when the note section is outside of the first
16KB of the file and then fallback to additionally reading that
section of the file.  This way, in future versions of Solaris when
this linking behaviour is changed, the fast path will always succeed
and we'll only be slower if it fails; likewise, any other linker that
does this will also just work.

Fixes #12178

Change-Id: I61c1dc3f744ae3ad63938386d2ace8a432c0efe1
Reviewed-on: https://go-review.googlesource.com/14210
Run-TryBot: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
2015-09-04 20:01:09 +00:00
Dave Cheney
e49b2460a4 Revert "cmd/internal/ld: put read-only relocated data into .data.rel.ro when making a shared object"
This reverts commit 2c2cbb69c8.

Broke darwin/arm64

Change-Id: Ibd2dea475d6ce6a8b4b40e2da19a83fc0514025d
Reviewed-on: https://go-review.googlesource.com/14301
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-04 19:47:36 +00:00
Didier Spezia
3c37a61455 cmd/compile/internal: slice/map literals janitoring
Simplify slice/map literal expressions.
Caught with gofmt -d -s, fixed with gofmt -w -s
Checked that the result can still be compiled with Go 1.4.

Change-Id: I5c58801c20919618d2ad52b8e2380d53df2783f1
Reviewed-on: https://go-review.googlesource.com/13831
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-04 15:27:59 +00:00
Todd Neal
24dcede1c0 [dev.ssa] cmd/compile/ssa: add timing to compiler passes
Add timing/allocation information to each compiler pass for both the
console and html output.

Change-Id: I75833003b806a09b4fb1bbf63983258612cdb7b0
Reviewed-on: https://go-review.googlesource.com/14277
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-04 15:19:12 +00:00
Todd Neal
19447a66d6 [dev.ssa] cmd/compile: store floats in AuxInt
Store floats in AuxInt to reduce allocations.

Change-Id: I101e6322530b4a0b2ea3591593ad022c992e8df8
Reviewed-on: https://go-review.googlesource.com/14320
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-04 15:15:21 +00:00
Todd Neal
991036aef3 [dev.ssa] cmd/compile: store bools in AuxInt
Store bools in AuxInt to reduce allocations.

Change-Id: Ibd26db67fca5e1e2803f53d7ef094897968b704b
Reviewed-on: https://go-review.googlesource.com/14276
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-04 14:53:44 +00:00
Michael Hudson-Doyle
876b7cc227 cmd/compile, cmd/go: generate position independent code with -buildmode=c-shared on arm
All the code was there to do this, it just wasn't hooked up.

Fixes #10914

Change-Id: Ide8f9bbe50fecb5d11cd579915ee98d4c7efe403
Reviewed-on: https://go-review.googlesource.com/14142
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-04 07:08:09 +00:00
Shenghou Ma
821e124c24 cmd/link/internal/ld: align PE .text section to 32-byte when external linking
Some symbols, for example, masks requires 16-byte alignment, and
they are placed in the text section. Before this change, the text
section is only aligned to 4-byte, and it's making masks unaligned.

Fixes #12415.

Change-Id: I7767778d1b4f7d3e74c2719a02848350782a4160
Reviewed-on: https://go-review.googlesource.com/14166
Run-TryBot: Minux Ma <minux@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-04 05:27:02 +00:00
Michael Hudson-Doyle
2c2cbb69c8 cmd/internal/ld: put read-only relocated data into .data.rel.ro when making a shared object
Currently Go produces shared libraries that cannot be shared between processes
because they have relocations against the text segment (not text section). This
fixes this by moving some data to sections with magic names recognized by the
static linker.

Fixes #10914
Updates #9210

Change-Id: I7178daadc0ae87953d5a084aa3d580f4e3b46d47
Reviewed-on: https://go-review.googlesource.com/10300
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-04 05:25:10 +00:00
Michael Hudson-Doyle
eaea5ade2b cmd/asm: fix handling of nested #if[n]defs
The lexer needs to process all #if[n]defs, even those found when processing is
disabled by a preceding failed conditional, or the first #endif in something
like:

    #ifdef <undefined>
    #ifdef whatever
    #endif
    #endif

terminates the first #ifdef and the second causes an error. And then the
processing of the inner #ifdefs needs to ignore their argument when they are
disabled by an outer failed condition.

Change-Id: Iba259498f1e16042f5b7580b9c000bb0599733d0
Reviewed-on: https://go-review.googlesource.com/14253
Reviewed-by: Rob Pike <r@golang.org>
2015-09-04 05:23:28 +00:00
Andrew Gerrand
b8efc006f2 all: remove executable bit from several files
Change-Id: Iab669b2a9dd0510c0e54f9ec1cbe2b83b991bceb
Reviewed-on: https://go-review.googlesource.com/14283
Reviewed-by: Minux Ma <minux@golang.org>
2015-09-04 02:59:49 +00:00
Michael Hudson-Doyle
06da8fd84a cmd/link: only embed runtime.goarm in the module that contains the runtime package
And do it properly so freebsd and nacl still work.

Change-Id: I6f9f30e93ceae6dee59215ed608c6a158bdbdbb0
Reviewed-on: https://go-review.googlesource.com/14280
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-04 02:20:47 +00:00
Shenghou Ma
dac87e9ed3 cmd/compile/internal/gc: allow //go:systemstack only in runtime
Fixes #12454.

Change-Id: I6406b0119bc4d6c3d1e6f1896b588b7d101448a3
Reviewed-on: https://go-review.googlesource.com/14274
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-04 02:16:50 +00:00
Keith Randall
d9f2cafb50 [dev.ssa] cmd/compile/internal/ssa: fix fallthrough return
Fallthrough return needs to be a return block before jumping
to the exit block.

Change-Id: I994de2064da5c326c9cade2c33cbb15bdbce5acb
Reviewed-on: https://go-review.googlesource.com/14256
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-09-03 22:04:07 +00:00
Michael Hudson-Doyle
c788a8e05d Revert "cmd/link: only embed runtime.goarm in the module that contains the runtime package"
This reverts commit bf99d8f843.

Change-Id: Id4374ed35802cfbfe11e015ccd9526d3497dc8cc
Reviewed-on: https://go-review.googlesource.com/14239
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-03 21:20:53 +00:00
Rob Pike
36af087aef cmd/asm: handle CMPF and CMPD on ARM
These instructions are special cases that were missed in the translation.
The second argument must go into the Reg field not the To field.

Fixes #12458

For Go 1.5.1

Change-Id: Iad57c60c7e38e3bcfafda483ed5037ce670e8816
Reviewed-on: https://go-review.googlesource.com/14183
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-09-03 19:40:11 +00:00
Keith Randall
10f38f51ef [dev.ssa] cmd/compile/internal/ssa: distinguish exit and return blocks
It is confusing to have exceptional edges jump back into
real code.  Distinguish return blocks, which execute acutal
code, and the exit block, which is a merge point for the regular
and exceptional return flow.

Prevent critical edge insertion from adding blocks on edges
into the exit block.  These added blocks serve no purpose and
add a bunch of dead jumps to the assembly output.  Furthermore,
live variable analysis is confused by these jumps.

Change-Id: Ifd69e6c00e90338ed147e7cb351b5100dc0364df
Reviewed-on: https://go-review.googlesource.com/14254
Reviewed-by: David Chase <drchase@google.com>
2015-09-03 17:42:38 +00:00
Michael Hudson-Doyle
bf99d8f843 cmd/link: only embed runtime.goarm in the module that contains the runtime package
Change-Id: Ia18984343ca4ced3671d967ff9a5b0e32874430c
Reviewed-on: https://go-review.googlesource.com/14220
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-03 16:22:21 +00:00
Keith Randall
73024083b0 [dev.ssa] cmd/compile: add pxor to list of instructions analyzeable by liveness analysis
Change-Id: I6ea0a3482d8813b8555b16fe6c377cad33554619
Reviewed-on: https://go-review.googlesource.com/14247
Reviewed-by: David Chase <drchase@google.com>
2015-09-03 14:15:21 +00:00
Michael Hudson-Doyle
9e6ba37b86 cmd/internal/obj: some platform independent bits of proper toolchain support for thread local storage
Also simplifies some silliness around making the .tbss section wrt internal
vs external linking. The "make TLS make sense" project has quite a few more
steps to go.

Issue #11270

Change-Id: Ia4fa135cb22d916728ead95bdbc0ebc1ae06f05c
Reviewed-on: https://go-review.googlesource.com/13990
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-03 14:06:07 +00:00
Todd Neal
ce4317266c [dev.ssa] cmd/compile: cse should treat -0.0 and 0.0 as different
cse was incorrectly classifying -0.0 and 0.0 as equivalent. This lead
to invalid code as ssa uses PXOR -0.0, reg to negate a floating point.

Fixes math.

Change-Id: Id7eb10c71749eaed897f29b02c33891cf5820acf
Reviewed-on: https://go-review.googlesource.com/14205
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-03 03:05:02 +00:00
Todd Neal
19285efaed [dev.ssa] cmd/compile: fix complex128
complex128 was being treated as a complex64

Fixes math/cmplx.

Change-Id: I2996915b4cb6b94198d41cf08a30bd8531b9fec5
Reviewed-on: https://go-review.googlesource.com/14206
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-03 03:04:36 +00:00
Michael Hudson-Doyle
7bf959c67a cmd/internal/obj: remove Link.Tlsoffset
Nothing uses it any more.

Change-Id: I42ee7222b06b1a79b8b44894f3071752f9166d7a
Reviewed-on: https://go-review.googlesource.com/14193
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-03 02:16:22 +00:00
Didier Spezia
df37c4b987 cmd/asm: fix several panics with erroneous input
The parser tries to read as much information as possible,
issuing some errors when needed. Errors generally do not
stop the parsing.

With some pathological input, it may result in various
panics when the error message itself is built, or when the
next operand is parsed. It happens while parsing
pseudo-instructions.

For instance, the following lines all generate a panic:

	TEXT
	TEXT%
	TEXT 1,1
	TEXT $"toto", 0, $1
	FUNCDATA
	DATA 0
	DATA(0),1
	FUNCDATA(SB
	GLOBL 0, 1
	PCDATA 1

Added corresponding tests.

Introduced a writer in the parser to capture error messages
for testing purpose. It defaults to os.Stderr.

Added an explicit check when symbol names cannot be displayed.

Interrupted parsing early when the number of operands is wrong for
pseudo-instructions.

Note that the last point is a change of behavior, because some
operands will not get parsed anymore in case of early error.

IMO, it is acceptable, because only the first error of the line
is considered anyway. If it is not acceptable, it can probably
be improved at the price of a more verbose CL.

Fixes #11765
Fixes #11760
Fixes #11759

Change-Id: I9602a848132e358a1bccad794d7555e0823970dd
Reviewed-on: https://go-review.googlesource.com/13925
Reviewed-by: Rob Pike <r@golang.org>
2015-09-02 20:24:40 +00:00
Håvard Haugen
dc3540d982 compile/internal/gc: make typecheckok a bool
Change-Id: Ib3960321a4c8164f6b221bfd15977d2f34dbc65b
Reviewed-on: https://go-review.googlesource.com/14175
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-02 19:08:19 +00:00
Rob Pike
45537d893d cmd/doc: document that json.Decode documents encoding/json.Decoder.Decode
Refine the documentation in cmd/doc and go help doc.

Fixes #12377.

Change-Id: I670c0a5cf18c9c9d5bb9bb222d8a3dd3722a3934
Reviewed-on: https://go-review.googlesource.com/14121
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-02 17:58:17 +00:00
Rob Pike
43a7a9cf43 cmd/vet: diagnose using Printf on a function value
Printing a function value is nearly useless outside of debugging, but
can occur by mistake when one forgets to call it. Diagnose this.

I did this myself just the other day and it arose in cl/14031.
Easy to fix and seems worthwhile.

Fixes #12295.

Change-Id: Ice125a84559f0394f7fa7272b5d31ae602b07f83
Reviewed-on: https://go-review.googlesource.com/14122
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-09-02 17:58:04 +00:00
Todd Neal
5cb352edeb [dev.ssa] cmd/compile: fix liblink rewrite of -0.0
liblink was rewriting xor by a negative zero (used by SSA
for negation) as XORPS reg,reg.

Fixes strconv.

Change-Id: I627a0a7366618e6b07ba8f0ad0db0e102340c5e3
Reviewed-on: https://go-review.googlesource.com/14200
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-02 10:41:55 +00:00
Todd Neal
634b50c6e1 [dev.ssa] cmd/compile: truncate when converting floats to ints
Modified to use the truncating conversion.

Fixes reflect.

Change-Id: I47bf3200abc2d2c662939a2a2351e2ff84168f4a
Reviewed-on: https://go-review.googlesource.com/14167
Reviewed-by: David Chase <drchase@google.com>
2015-09-02 01:11:29 +00:00
Todd Neal
4219aba5db [dev.ssa] cmd/compile: make REPSTOSQ clobber flags
It does a XOR internally and clobbers flags.

Change-Id: Id6ef9219c4e6c3a2b5fc79c8d52bcfa30c148617
Reviewed-on: https://go-review.googlesource.com/14165
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-02 00:35:25 +00:00
Keith Randall
2511cf03b9 [dev.ssa] cmd/compile/internal/ssa: make SETEQF and SETNEF clobber flags
They do an AND or an OR internally, so they clobber flags.

Fixes #12441

Change-Id: I6c843bd268496bc13fc7e3c561d76619e961e8ad
Reviewed-on: https://go-review.googlesource.com/14180
Reviewed-by: Todd Neal <todd@tneal.org>
2015-09-01 22:21:45 +00:00
Todd Neal
6411533ebf [dev.ssa] cmd/compile: fix rare issue caused by liblink rewrite
liblink rewrites MOV $0, reg into XOR reg, reg. Make MOVxconst clobber
flags so we don't generate invalid code in the unlikely case that it
matters.  In testing, this change leads to no additional regenerated
flags due to a scheduling fix in CL14042.

Change-Id: I7bc1cfee94ef83beb2f97c31ec6a97e19872fb89
Reviewed-on: https://go-review.googlesource.com/14043
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-01 22:19:49 +00:00
Håvard Haugen
dd42eff8fe cmd/compile/internal/gc: use slice instead of NodeList for Label.Use
Change-Id: I021c95df24edbff24ff2922769ef2b2acd47016a
Reviewed-on: https://go-review.googlesource.com/14081
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-09-01 22:13:16 +00:00
Håvard Haugen
e8da46f6db cmd/compile/internal/gc: remove dead code found by vet
See report in commit 3c9fa388df.

Change-Id: I74a5995a1c1ca62b8d01857e89b084502e7da928
Reviewed-on: https://go-review.googlesource.com/14170
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-01 21:21:15 +00:00
David Chase
3a9d0ac3c8 [dev.ssa] cmd/compile: add complex arithmetic
Still to do:
details, more testing corner cases. (e.g. negative zero)
Includes small cleanups for previous CL.

Note: complex division is currently done in the runtime,
so the division code here is apparently not yet necessary
and also not tested.  Seems likely better to open code
division and expose the widening/narrowing to optimization.

Complex64 multiplication and division is done in wide
format to avoid cancellation errors; for division, this
also happens to be compatible with pre-SSA practice
(which uses a single complex128 division function).

It would-be-nice to widen for complex128 multiplication
intermediates as well, but that is trickier to implement
without a handy wider-precision format.

Change-Id: I595a4300f68868fb7641852a54674c6b2b78855e
Reviewed-on: https://go-review.googlesource.com/14028
Reviewed-by: Keith Randall <khr@golang.org>
2015-09-01 17:47:58 +00:00
Keith Randall
65677cabfd [dev.ssa] cmd/compile/internal/ssa: allow ops to have a default type
Specifying types in rewrites for all subexpressions gets verbose
quickly.  Allow opcodes to specify a default type which is used when
none is supplied explicitly.

Provide default types for a few easy opcodes.  There are probably more
we can do, but this is a good start.

Change-Id: Iedc2a1a423cc3e2d4472640433982f9aa76a9f18
Reviewed-on: https://go-review.googlesource.com/14128
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-09-01 16:40:28 +00:00
Michael Hudson-Doyle
e92d0d82e0 cmd/link: remove some dead code
Change-Id: I125a12a2cb7e792f357e4d841f55c0bed2971dce
Reviewed-on: https://go-review.googlesource.com/14140
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-09-01 16:28:49 +00:00
Todd Neal
a0022d9b8c [dev.ssa] cmd/compile: add more specific regalloc logging
Change-Id: Ib0ea4b9c245f3d551e0f703826caa6b444b56a2d
Reviewed-on: https://go-review.googlesource.com/14136
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-09-01 02:37:42 +00:00
Todd Neal
21e6a055c1 [dev.ssa] cmd/compile: schedule values dependent on the control later
To reduce the number of spills, give any non-phi values whose argument
is the control the same priority as the control.

With mask.bash, this reduces regenerated flags from 603 to 240.

Change-Id: I26883d69e80357c56b343428fb528102b3f26e7a
Reviewed-on: https://go-review.googlesource.com/14042
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-31 22:17:23 +00:00
Dave Cheney
8d478e845c cmd/internal/obj/arm: remove CASE and BCASE
Update #10994

CASE and BCASE were used by 5c in switch statements, cmd/compile
does not use them.

Change-Id: I7a578c461b52b94690e35460926849b28971b770
Reviewed-on: https://go-review.googlesource.com/14009
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-31 21:03:57 +00:00
Dave Cheney
3578bdf3c3 internal/obj/arm64: remove CASE and BCASE
Fixes #10994

CASE and BCASE were used by 7c in switch statements, cmd/compile
does not use them, cmd/assemble couldn't assemble them, and the arm64
peephole optimiser didn't know about them.

Change-Id: Id04835fcb37e207f76d211ce54a4db9c057d6112
Reviewed-on: https://go-review.googlesource.com/14100
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Run-TryBot: Aram Hăvărneanu <aram@mgk.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-31 13:22:55 +00:00
Todd Neal
3b7f0c9cba [dev.ssa] cmd/compile: fix typo in log
Change-Id: Ic7be8fa3a89e46a93df181df3163ec1bf7e96a23
Reviewed-on: https://go-review.googlesource.com/14076
Reviewed-by: Minux Ma <minux@golang.org>
2015-08-31 03:07:43 +00:00
Todd Neal
cff0c6ad0f [dev.ssa] cmd/compile: add instrumentation to regalloc
Change-Id: Ice206f7e94af4a148d9dd9a7570f5ed21722bedc
Reviewed-on: https://go-review.googlesource.com/14075
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-31 02:53:07 +00:00
Todd Neal
451eca2293 [dev.ssa] cmd/compile: make test panic on failure
Change-Id: Ia5483d23fe0b5dd0b6cfe2099e9b475184742716
Reviewed-on: https://go-review.googlesource.com/14074
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-31 02:29:50 +00:00
Todd Neal
5fdd4fea90 [dev.ssa] cmd/compile: map EQ/NE intptr to OpEqPtr/OpNeqPtr
Change-Id: I8fd3727763c812297967c8069847833fc8516ff2
Reviewed-on: https://go-review.googlesource.com/14073
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-31 02:29:43 +00:00
Håvard Haugen
3c9fa388df cmd/compile/internal/gc: rename Fatal to Fatalf
This helps vet see a real issue:

    cmd/internal/gc$ go vet
    gen.go:1223: unreachable code

Fixes #12106.

Change-Id: I720868b07ae6b6d5a4dc6b238baa8c9c889da6d8
Reviewed-on: https://go-review.googlesource.com/14083
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-31 01:35:23 +00:00
Michael Hudson-Doyle
af799d94f9 cmd/link: pass value being relocated to archreloc
And clean up the mess on arm64 (the mess on arm is too confusing).

See issue #10050

Change-Id: I2ce813fe8646d4e818eb660612a7e4b2bb04de4c
Reviewed-on: https://go-review.googlesource.com/13884
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-31 00:07:59 +00:00
Keith Randall
186cf1b9ba [dev.ssa] cmd/compile/internal/ssa: handle dead code a different way
Instead of trying to delete dead code as soon as we find it, just
mark it as dead using a PlainAndDead block kind.  The deadcode pass
will do the real removal.

This way is somewhat more efficient because we don't need to mess
with successor and predecessor lists of all the dead blocks.

Fixes #12347

Change-Id: Ia42d6b5f9cdb3215a51737b3eb117c00bd439b13
Reviewed-on: https://go-review.googlesource.com/14033
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-29 17:21:02 +00:00
Josh Bleecher Snyder
9654873a76 [dev.ssa] cmd/compile: implement PPARAMREF
This also fixes the encoding/gob TestTopLevelNilPointer failure.

Change-Id: I9b29a6fddffd51af305c685f3a8e2a0594bfeeab
Reviewed-on: https://go-review.googlesource.com/14032
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-29 16:33:14 +00:00
Todd Neal
47d6799b0f [dev.ssa] cmd/compile: move addEdge function to ssa
addEdge had two identical implementations so make it an exported method
on Block.

Change-Id: I8c21655a9dc5074fefd7f63b2f5b51897571e608
Reviewed-on: https://go-review.googlesource.com/14040
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-29 13:10:49 +00:00
Todd Neal
67e43c1e3b [dev.ssa] cmd/compile: implement OFALL
Frontend has already rewriten fallthrough statements, we just need to
ignore them.

Change-Id: Iadf89b06a9f8f9e6e2e1e87c934f31add77a19a1
Reviewed-on: https://go-review.googlesource.com/14029
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-29 02:30:17 +00:00
Robert Griesemer
3d3bc88bb5 cmd/compile/internal/gc: use slice instead of linked list for nodes to export
Change-Id: Ib79ab787fdc90a5a29b25474d91afa9bfaf51276
Reviewed-on: https://go-review.googlesource.com/13589
Reviewed-by: Minux Ma <minux@golang.org>
2015-08-28 22:49:15 +00:00
Robert Griesemer
68f4f96c1e cmd/compiler/internal/gc: fix argument for Sprintf
Val.Ctype used to be struct field, it's now a method.

Change-Id: I08f0b32b66dba15b2a392e84a557efb905b530cb
Reviewed-on: https://go-review.googlesource.com/14031
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-28 22:46:53 +00:00
Todd Neal
707af252d9 [dev.ssa] cmd/compile: implement len/cap(chan)
Change-Id: I1453ba226376ccd4d79780fc0686876d6dde01ee
Reviewed-on: https://go-review.googlesource.com/14027
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-28 21:55:21 +00:00
David Chase
73151067bc [dev.ssa] cmd/compile: added floating point to [u]int conversions
Change-Id: I8dee400aef07165f911750de2615b8757f826000
Reviewed-on: https://go-review.googlesource.com/13945
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-28 21:46:39 +00:00
Keith Randall
a5cffb6182 [dev.ssa] cmd/compile/internal/ssa: allocate complex zero in the entry block
Fixes build.  There may be no current block.

Change-Id: I0da8bab133dc207124556927698e7cd682e64ef5
Reviewed-on: https://go-review.googlesource.com/13989
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-28 20:53:56 +00:00
Todd Neal
67ac8a3b22 [dev.ssa] cmd/compile: fix type of nil ptr in check
Change-Id: If7a6ab6b1336dbacb006f562be7f153eb93e7253
Reviewed-on: https://go-review.googlesource.com/14025
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-28 20:48:23 +00:00
Keith Randall
f8093b8f24 [dev.ssa] cmd/compile/internal/ssa: add arg-dominating check, fix phielim
Add a check to make sure value arguments dominate the value.

Phi elim output used to fail this test.  When eliminating
redundant phis, phi elim was using one of the args and not
the ultimate source.  For example:

          b1: x = ...
          -> b2 b3

b2: y = Copy x        b3: z = Copy x
-> b4                 -> b4

          b4: w = phi y z

Phi elim eliminates w, but it used to replace w with (Copy y).
That's bad as b2 does not dominate b4.  Instead we should
replace w with (Copy x).

Fixes #12347

Change-Id: I9f340cdabcda8e2e90359fb4f9250877b1fffe98
Reviewed-on: https://go-review.googlesource.com/13986
Reviewed-by: David Chase <drchase@google.com>
2015-08-28 20:40:06 +00:00
David Chase
525785885e [dev.ssa] cmd/compile: add compose/decompose for complex, phi, constants
Still to do: arithmetic

Change-Id: I31fd23b34980c9ed4b4e304b8597134b2ba6ca5c
Reviewed-on: https://go-review.googlesource.com/14024
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-28 20:20:43 +00:00
Todd Neal
e0e4068c6e [dev.ssa] cmd/compile: implement len(map)
Implement len(map) values.

Change-Id: If92be96ec9a7a86aeb3ce566d6758aab01c2fa7d
Reviewed-on: https://go-review.googlesource.com/13961
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-28 20:12:47 +00:00
Russ Cox
63862afb27 cmd/internal/rsc.io: delete
The code is now in cmd/vendor/golang.org/x/arch.

Change-Id: I518d48c21b0d7fed914552b89ee41411f088456b
Reviewed-on: https://go-review.googlesource.com/14021
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-28 16:34:52 +00:00
Russ Cox
90dbd975fd cmd/internal/objfile: use golang.org/x/arch instead of rsc.io
Change-Id: I5348774ff01a5f0f706a1dba4aa9500661841f47
Reviewed-on: https://go-review.googlesource.com/14020
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-28 16:34:39 +00:00
Russ Cox
10efac8782 cmd/vendor/golang.org/x/arch: import arm/armasm and x86/x86asm
For use by cmd/objdump in place of the current cmd/internal/rsc.io/... tree.

Change-Id: I7d765ddf43ab4118a3221fd755ff0a2a02daa5de
Reviewed-on: https://go-review.googlesource.com/13979
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-28 16:34:30 +00:00
Ian Lance Taylor
499845bfe0 cmd/go: -a does apply to the standard library
This changed in https://golang.org/cl/10761.

Update #12203.

Change-Id: Ia37ebb7ecba689ad3cb2559213d675f21cf03a95
Reviewed-on: https://go-review.googlesource.com/13799
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-27 18:34:19 +00:00
Russ Cox
a82ed3bc81 cmd/go: enable vendoring experiment by default
If we're going to do this for Go 1.6 we might as well do it now
and find out what breaks.

Change-Id: I8306b7829d8d13b564a1466c902ec6ba1a5a58c1
Reviewed-on: https://go-review.googlesource.com/13967
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-27 17:33:03 +00:00
Josh Bleecher Snyder
44d87035b6 [dev.ssa] cmd/compile: make block kinds clickable in html
Change-Id: I113c07caf504cee66a81730da8830de6de098e49
Reviewed-on: https://go-review.googlesource.com/13981
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-27 17:30:50 +00:00
Josh Bleecher Snyder
35ad1fcb11 [dev.ssa] cmd/compile: fix OANDAND and OOROR type
The old backend doesn't like ideal types,
and we want to reuse its stackmap generation.

OOROR and OANDAND expressions have ideal type.
The old backend didn't care,
because those expressions got rewritten away into
jumps before stackmap generation.

Fix the type during conversion.

Change-Id: I488e7499298d9aec71da39c202f6a7235935bc8d
Reviewed-on: https://go-review.googlesource.com/13980
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-27 17:26:52 +00:00
Vincent Vanackere
b55c4a0c54 cmd/go: properly ignore import comments for vendored packages rooted at GOPATH
Fixes #12232.

Change-Id: Ide3fb7f5fc5ae377ae8683fbb94fd0dc01480549
Reviewed-on: https://go-review.googlesource.com/13924
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-27 15:30:30 +00:00
Didier Spezia
7437e3f02e cmd/asm: fix potential infinite loop in parser
For ARM machines, the assembler supports list of registers
operands such as [R1,R2].

A list missing a ']' results in the parser issuing many errors
and consuming all the tokens. At EOF (i.e. end of the line),
it still loops.

Normally, a counter is maintained to make sure the parser
stops after 10 errors. However, multiple errors occuring on the
same line are simply ignored. Only the first one is reported.
At most one error per line is accounted.

Missing ']' in a register list therefore results in an
infinite loop.

Fixed the parser by explicitly checking for ']' to interrupt
this loops

In the operand tests, also fixed a wrong entry which I think was
not set on purpose (but still led to a successful result).

Fixes #11764

Change-Id: Ie87773388ee0d21b3a2a4cb941d4d911d0230ba4
Reviewed-on: https://go-review.googlesource.com/13920
Reviewed-by: Rob Pike <r@golang.org>
2015-08-27 10:26:40 +00:00
Todd Neal
7cadf23afb [dev.ssa] cmd/compile: fix phi floats
The code previously always used AX causing errors.  For now, just
switch off the type in order to at least generate valid code.

Change-Id: Iaf13120a24b62456b9b33c04ab31f2d5104b381b
Reviewed-on: https://go-review.googlesource.com/13943
Reviewed-by: David Chase <drchase@google.com>
2015-08-26 14:40:34 +00:00
Todd Neal
752fe4dcb5 [dev.ssa] cmd/compile: support float zeroing
Change-Id: Iacd302350cf0a8a8164d937e5c4ac55e6a07d380
Reviewed-on: https://go-review.googlesource.com/13942
Reviewed-by: David Chase <drchase@google.com>
2015-08-26 02:19:02 +00:00
Michael Hudson-Doyle
af78482d6b cmd/compile, cmd/link, reflect, runtime: remove type.zero field
No longer used after previous hashmap change.

Change-Id: I558470f872281e84a78406132df4e391d077b833
Reviewed-on: https://go-review.googlesource.com/13785
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-26 00:28:17 +00:00
Andy Maloney
dc110f245d cmd/cgo: annotate named return struct members in comments
If an exported function has named return variables, then show the names
as comments in the return struct we create in the header file.

Example here:

 https://groups.google.com/forum/#!topic/golang-nuts/r393ne4zIfY

Change-Id: I21fb4ca2673f6977bec35ccab0cef7d42b311f96
Reviewed-on: https://go-review.googlesource.com/13061
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-26 00:24:34 +00:00
Michael Hudson-Doyle
38519e69d0 cmd/compile, runtime: stop returning t.zero on hashmap miss
Previously t.zero always pointed to runtime.zerovalue. Change the hashmap code
to always return a runtime pointer directly, and change that pointer to point
to a larger buffer if one is needed.

(It might be better to only copy from the pointer returned by the mapaccess
functions when the value type is small enough and have the compiler insert
explicit zeroing for larger value types, but I tried and failed to do this).

This removes all uses of the zero field of the type data; the field itself can
be removed in a separate change.

Fixes #11491

Change-Id: I5b81752ff4067d74a5a281c41e88f151bae0171e
Reviewed-on: https://go-review.googlesource.com/13784
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-26 00:03:21 +00:00
Andy Maloney
79a3d239e9 cmd/cgo: change comments in generated C code to be C-style
Change-Id: I3889eda72ae0f57117f1d4299e3574f8bf68be67
Reviewed-on: https://go-review.googlesource.com/13310
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-26 00:01:08 +00:00
Michael Hudson-Doyle
7f9e443d9c cmd/link: call moduledata symbols "local.moduledata" if they are created by the linker
This was always a bit confusing, but it also fixes a problem: runtime.firstmoduledata
was always overridden in the linker to be a local symbol but cmd/internal/obj had
already rewritten code accessing it to access it via the GOT. This works on amd64, but
causes link failures on other platforms (e.g. arm64).

Change-Id: I9b8153af74b4d0f092211d63a000d15818f39773
Reviewed-on: https://go-review.googlesource.com/13786
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-25 23:48:12 +00:00
Keith Randall
ee50cb2061 [dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Semi-regular merge of master into dev.ssa.

Change-Id: Ia7f2e29dfdea7618141efcfcf6f6c7c8b5553dfa
2015-08-25 14:46:34 -07:00
Keith Randall
a2f8b0d0e4 [dev.ssa] cmd/compile/internal/ssa: add more critical edges
Add blocks to remove critical edges, even when it looks like
there's no phi that requires it.  Regalloc still likes to have
critical-edge-free graphs for other reasons.

Change-Id: I69f8eaecbc5d79ab9f2a257c2e289d60b18e43c8
Reviewed-on: https://go-review.googlesource.com/13933
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-25 21:20:18 +00:00
Ulrich Kunitz
6ec1809b83 cmd/compile: fix register allocation for == operator
The issue 12226 has been caused by the allocation of the same register
for the equality check of two byte values. The code in cgen.go freed the
register for the second operand before the allocation of the register
for the first operand.

Fixes #12226

Change-Id: Ie4dc33a488bd48a17f8ae9b497fd63c1ae390555
Reviewed-on: https://go-review.googlesource.com/13771
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-25 18:10:14 +00:00
Keith Randall
ec39d78ddd [dev.ssa] cmd/compile/internal/ssa: update TODO and comments
Change-Id: I3c598faff8af18530ae863b9e72f0cef379b4a1f
Reviewed-on: https://go-review.googlesource.com/13909
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-25 17:45:06 +00:00
Keith Randall
3526cf586b [dev.ssa] cmd/compile: implement OSLICESTR
Add a new function and generic operation to handle
bounds checking for slices. Unlike the index
bounds checking the index can be equal to the upper
bound.

Do gc-friendly slicing that generates proper code for
0-length result slices.

This is a takeover of Alexandru's original change,
(https://go-review.googlesource.com/#/c/12764/)
submittable now that the decompose phase is in.

Change-Id: I17d164cf42ed7839f84ca949c6ad3289269c9160
Reviewed-on: https://go-review.googlesource.com/13903
Reviewed-by: David Chase <drchase@google.com>
2015-08-25 17:14:57 +00:00
David Chase
8e601b23cd [dev.ssa] cmd/compile: add FP comparison ops
Basic ops, no particular optimization in the pattern
matching yet (e.g. x!=x for Nan detection, x cmp constant,
etc.)

Change-Id: I0043564081d6dc0eede876c4a9eb3c33cbd1521c
Reviewed-on: https://go-review.googlesource.com/13704
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-25 15:29:22 +00:00
Austin Clements
05a3b1fce5 cmd/compile: fix uninitialized memory in compare of interface value
A comparison of the form l == r where l is an interface and r is
concrete performs a type assertion on l to convert it to r's type.
However, the compiler fails to zero the temporary where the result of
the type assertion is written, so if the type is a pointer type and a
stack scan occurs while in the type assertion, it may see an invalid
pointer on the stack.

Fix this by zeroing the temporary. This is equivalent to the fix for
type switches from c4092ac.

Fixes #12253.

Change-Id: Iaf205d456b856c056b317b4e888ce892f0c555b9
Reviewed-on: https://go-review.googlesource.com/13872
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-25 14:37:08 +00:00
David Chase
4282588694 [dev.ssa] cmd/compile: add [u]int and FP to FP conversions
Change-Id: I8c17f706a3e0f1fa2d754bfb4ccd1f7a027cb3db
Reviewed-on: https://go-review.googlesource.com/13744
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-25 14:26:14 +00:00
Keith Randall
01490eb96c [dev.ssa] cmd/compile: make sure to keep offset and sym of MOV opcodes.
MOVXload and MOVXstore opcodes have both an auxint offset
and an aux offset (a symbol name, like a local or arg or global).
Make sure we keep those values during rewrites.

Change-Id: Ic9fd61bf295b5d1457784c281079a4fb38f7ad3b
Reviewed-on: https://go-review.googlesource.com/13849
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-25 04:33:49 +00:00
Shenghou Ma
b11c8b9370 cmd/go: skip test using external linking on linux/ppc64 too
While we're at it, also fix a typo.

Change-Id: Id436f33cffa5683e2a8450cce5b545960cf2877e
Reviewed-on: https://go-review.googlesource.com/13878
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-25 01:33:25 +00:00
Josh Bleecher Snyder
5844603f14 [dev.ssa] cmd/compile: streamline unimplemented strings
This aids in making sense of the aggregate set of work outstanding.
Interest in the details of any particular implementation failure
is better handled locally anyway.

In my local tree, running make.bash after this CL yields:

 14.85%  1811 SSA unimplemented: unhandled expr SLICEARR
 13.84%  1687 SSA unimplemented: unhandled expr CALLINTER
 11.84%  1444 SSA unimplemented: unhandled stmt RETJMP
 10.24%  1249 SSA unimplemented: unhandled expr EFACE
  8.52%  1039 SSA unimplemented: unhandled expr SLICE
  4.92%   600 SSA unimplemented: local variable with class PAUTO,heap unimplemented
  4.90%   598 SSA unimplemented: unhandled expr SLICESTR
  3.91%   477 SSA unimplemented: local variable with class PFUNC unimplemented
  3.45%   421 SSA unimplemented: not lowered: IMake INTER PTR64 PTR64
  3.42%   417 SSA unimplemented: unhandled expr APPEND
  3.21%   391 SSA unimplemented: unhandled expr CLOSUREVAR
  3.06%   373 SSA unimplemented: unhandled stmt DEFER
  3.04%   371 SSA unimplemented: unhandled stmt AS2DOTTYPE
  1.61%   196 SSA unimplemented: unhandled expr DOTTYPE
  1.56%   190 SSA unimplemented: not lowered: Load STRUCT PTR64 mem
  0.79%    96 SSA unimplemented: not lowered: StringMake STRING PTR64 UINTPTR
  0.69%    84 SSA unimplemented: unhandled binary op NE FLOAT64
  0.53%    65 SSA unimplemented: unhandled expr STRUCTLIT
  0.50%    61 SSA unimplemented: not lowered: SliceMake ARRAY PTR64 UINTPTR UINTPTR
  0.45%    55 SSA unimplemented: zero for type float64 not implemented
  0.44%    54 SSA unimplemented: unhandled addr CLOSUREVAR
  0.38%    46 SSA unimplemented: unhandled binary op EQ FLOAT64
  0.35%    43 SSA unimplemented: unhandled binary op LT FLOAT64
  0.34%    42 SSA unimplemented: unhandled len(map)
  0.33%    40 SSA unimplemented: unhandled stmt FALL
  0.23%    28 SSA unimplemented: CONVNOP closure
  0.21%    25 SSA unimplemented: local variable with class PPARAM,heap unimplemented
  0.21%    25 SSA unimplemented: unhandled binary op GT FLOAT64
  0.18%    22 SSA unimplemented: unhandled OCONV FLOAT32 -> FLOAT64
  0.18%    22 SSA unimplemented: unhandled expr REAL
  0.16%    20 SSA unimplemented: unhandled stmt PROC
  0.16%    19 SSA unimplemented: unhandled closure arg
  0.15%    18 SSA unimplemented: unhandled OCONV INT64 -> FLOAT64
  0.12%    15 SSA unimplemented: unhandled expr CFUNC
  0.10%    12 SSA unimplemented: unhandled OCONV UINT64 -> FLOAT64
  0.09%    11 SSA unimplemented: unhandled OLITERAL 4
  0.09%    11 SSA unimplemented: unhandled expr IMAG
  0.07%     9 SSA unimplemented: unhandled binary op GE FLOAT64
  0.07%     9 SSA unimplemented: unhandled binary op MINUS FLOAT64
  0.06%     7 SSA unimplemented: unhandled OCONV FLOAT64 -> FLOAT32
  0.06%     7 SSA unimplemented: unhandled binary op NE FLOAT32
  0.06%     7 SSA unimplemented: variable address class 5 not implemented
  0.05%     6 SSA unimplemented: not lowered: Load COMPLEX128 PTR64 mem
  0.05%     6 SSA unimplemented: unhandled expr SLICE3ARR
  0.04%     5 SSA unimplemented: unhandled binary op LE FLOAT64
  0.03%     4 SSA unimplemented: unhandled OCONV UINTPTR -> FLOAT64
  0.03%     4 SSA unimplemented: unhandled binary op EQ COMPLEX128
  0.03%     4 SSA unimplemented: unhandled binary op EQ FLOAT32
  0.03%     4 SSA unimplemented: unhandled expr COMPLEX
  0.02%     3 SSA unimplemented: local variable with class PPARAMOUT,heap unimplemented
  0.02%     3 SSA unimplemented: not lowered: Load ARRAY PTR64 mem
  0.02%     3 SSA unimplemented: unhandled OCONV INT32 -> FLOAT64
  0.02%     3 SSA unimplemented: unhandled OCONV INT64 -> FLOAT32
  0.02%     3 SSA unimplemented: unhandled expr SLICE3
  0.02%     2 SSA unimplemented: unhandled OCONV COMPLEX64 -> COMPLEX128
  0.02%     2 SSA unimplemented: unhandled OCONV FLOAT64 -> INT64
  0.02%     2 SSA unimplemented: unhandled OCONV FLOAT64 -> UINT64
  0.02%     2 SSA unimplemented: unhandled OCONV INT -> FLOAT64
  0.02%     2 SSA unimplemented: unhandled OCONV UINT64 -> FLOAT32
  0.02%     2 SSA unimplemented: unhandled binary op EQ COMPLEX64
  0.02%     2 SSA unimplemented: unhandled binary op MINUS FLOAT32
  0.02%     2 SSA unimplemented: zero for type complex128 not implemented
  0.02%     2 SSA unimplemented: zero for type complex64 not implemented
  0.02%     2 SSA unimplemented: zero for type float32 not implemented
  0.01%     1 SSA unimplemented: not lowered: EqFat BOOL INTER INTER
  0.01%     1 SSA unimplemented: not lowered: Store mem UINTPTR COMPLEX128 mem
  0.01%     1 SSA unimplemented: unhandled OCONV UINT32 -> FLOAT64
  0.01%     1 SSA unimplemented: unhandled cap(chan)
  0.01%     1 SSA unimplemented: unhandled expr ARRAYLIT
  0.01%     1 SSA unimplemented: unhandled expr PLUS
  0.01%     1 SSA unimplemented: unhandled stmt CHECKNIL

Change-Id: I43474fe6d6ec22a9f57239090136f6e97eebfdf2
Reviewed-on: https://go-review.googlesource.com/13848
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-24 22:13:53 +00:00
Josh Bleecher Snyder
9f8f8c27dc [dev.ssa] cmd/compile: support spilling and loading flags
This CL takes a simple approach to spilling and loading flags.
We never spill. When a load is needed, we recalculate,
loading the arguments as needed.

This is simple and architecture-independent.
It is not very efficient, but as of this CL,
there are fewer than 200 flag spills during make.bash.

This was tested by manually reverting CLs 13813 and 13843,
causing SETcc, MOV, and LEA instructions to clobber flags,
which dramatically increases the number of flags spills.
With that done, all stdlib tests that used to pass
still pass.

For future reference, here are some other, more efficient
amd64-only schemes that we could adapt in the future if needed.

(1) Spill exactly the flags needed.

For example, if we know that the flags will be needed
by a SETcc or Jcc op later, we could use SETcc to
extract just the relevant flag. When needed,
we could use TESTB and change the op to JNE/SETNE.
(Alternatively, we could leave the op unaltered
and prepare an appropriate CMPB instruction
to produce the desired flag.)

However, this requires separate handling for every
instruction that uses the flags register,
including (say) SBBQcarrymask.

We could enable this on an ad hoc basis for common cases
and fall back to recalculation for other cases.

(2) Spill all flags with PUSHF and POPF

This modifies SP, which the runtime won't like.
It also requires coordination with stackalloc to
make sure that we have a stack slot ready for use.

(3) Spill almost all flags with LAHF, SETO, and SAHF

See http://blog.freearrow.com/archives/396
for details. This would handle all the flags we currently
use. However, LAHF and SAHF are not universally available
and it requires arranging for AX to be free.

Change-Id: Ie36600fd8e807ef2bee83e2e2ae3685112a7f276
Reviewed-on: https://go-review.googlesource.com/13844
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-24 22:13:42 +00:00
Josh Bleecher Snyder
f3171994e9 [dev.ssa] cmd/compile: mark LEA and MOV instructions as not clobbering flags
This further reduces the number of flags spills
during make.bash by about 50%.

Note that GetG is implemented by one or two MOVs,
which is why it does not clobber flags.

Change-Id: I6fede8c027b7dc340e00d1e15df1b87bf2b2d9ec
Reviewed-on: https://go-review.googlesource.com/13843
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-24 22:10:55 +00:00
Josh Bleecher Snyder
220e705404 [dev.ssa] cmd/compile: make "*Value".String more robust
Change-Id: I4ae38440a33574421c9e3e350701e86e8a224b92
Reviewed-on: https://go-review.googlesource.com/13842
Reviewed-by: Todd Neal <todd@tneal.org>
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-24 22:10:36 +00:00
Josh Bleecher Snyder
397b4f6cbf cmd/internal/obj: delete Debugzerostack dead code
Fixes #11060

Change-Id: I4c6647fc2f103015b67e30dc2cdb6f771526c139
Reviewed-on: https://go-review.googlesource.com/13840
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-23 14:07:14 +00:00
Brad Fitzpatrick
b3a508c03e cmd/compile: in usage messages, name the binary "compile" instead of "Xg"
Fixes #12227

Change-Id: I7c1b93e50736185a641fb637000aae2f15bc04ed
Reviewed-on: https://go-review.googlesource.com/13820
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-22 15:39:13 +00:00
Todd Neal
0ffd9c8cad [dev.ssa] cmd/compile/internal: mark len(map), len/cap(chan) unimplemented
Mark these as unimplemented so we don't generate bad code.

Change-Id: I101190c40a753faaa82193ac37e2978b20a96e4e
Reviewed-on: https://go-review.googlesource.com/13748
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-22 13:15:27 +00:00
Brad Fitzpatrick
2468227038 cmd/compile/internal, cmd/internal/obj: used keyed ProgInfo literals
Safer, more readable, shorter.

Change-Id: I5cf1f438e20a3df45fc43cc5c870a533f7c524bf
Reviewed-on: https://go-review.googlesource.com/10517
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-21 22:32:43 +00:00
Alberto Donizetti
85de30e72f cmd/compile: allow huge rsh in constants arithmetic
Currently an expression like

var v = 0 >> 1000

is rejected by gc with a "stupid shift" error, while gotype
compiles it successfully.

As suggested by gri on the issue tracker, allow an rsh right
operand to be any valid uint value.

Fixes #11328

Change-Id: I6ccb3b7f842338d91fd26ae37dd4fa279d7fc440
Reviewed-on: https://go-review.googlesource.com/13777
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-08-21 20:27:22 +00:00
Todd Neal
57d9e7e3c4 [dev.ssa] cmd/compile/internal/ssa: implement OMOD
Change-Id: Iec954c4daefef4ab3fa2c98bfb2c70b2dea8dffb
Reviewed-on: https://go-review.googlesource.com/13743
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-21 20:20:26 +00:00
Robert Griesemer
548041ed08 cmd/compile/internal/big: update vendored math/big
This updates the big package used by the compiler to match the
public big package which contains some updates and bug fixes.
Obtained by running vendor.bash in the internal/big directory.
No manual changes.

Change-Id: I299aecc6599d4a745a721ce48def32449640dbb2
Reviewed-on: https://go-review.googlesource.com/13815
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-21 20:03:16 +00:00
David du Colombier
9538e4e73b cmd/trace: don't fail when no browser is available
When there is no browser available on the system,
we should print the URL instead of failing.

Change-Id: I4a2b099e17609394273eff150062c285d76bbac1
Reviewed-on: https://go-review.googlesource.com/13774
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-08-21 20:02:23 +00:00
Josh Bleecher Snyder
7393c24877 [dev.ssa] cmd/compile: everything is live and reachable after regalloc
This CL makes function printing and HTML generation
accurate after regalloc.

Prior to this CL, text and HTML function outputs
showed live values and blocks as dead.

Change-Id: I70669cd8641af841447fc5d2ecbd754b281356f0
Reviewed-on: https://go-review.googlesource.com/13812
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-21 20:00:51 +00:00
Josh Bleecher Snyder
8f51ae8ba5 [dev.ssa] cmd/compile: SETcc instructions do not clobber flags
This reduces the number of flags spilled during
make.bash by > 90%.

I am working (slowly) on the rest.

Change-Id: I3c08ae228c33e2f726f615962996f0350c8d592b
Reviewed-on: https://go-review.googlesource.com/13813
Reviewed-by: David Chase <drchase@google.com>
2015-08-21 17:49:15 +00:00
Rob Pike
f62b749ae2 all: fix some vet-caught formatting errors, mostly but not only in tests
Could go in 1.5, although not critical.
See also #12107

Change-Id: I7f1608b58581d21df4db58f0db654fef79e33a90
Reviewed-on: https://go-review.googlesource.com/13481
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-08-21 05:37:36 +00:00
Keith Randall
9f954db170 [dev.ssa] cmd/compile: add decompose pass
Decompose breaks compound objects up into pieces that can be
operated on by the target architecture.  The decompose pass only
does phi ops, the rest is done by the rewrite rules in generic.rules.

Compound objects include strings,slices,interfaces,structs,arrays.

Arrays aren't decomposed because of indexing (we could support
constant indexes, but dynamic indexes can't be handled using SSA).
Structs will come in a subsequent CL.

TODO: after this pass we have lost the association between, e.g.,
a string's pointer and its size.  It would be nice if we could keep
that information around for debugging info somehow.

Change-Id: I6379ab962a7beef62297d0f68c421f22aa0a0901
Reviewed-on: https://go-review.googlesource.com/13683
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-20 21:09:24 +00:00
David Glasser
7c154d973b cmd/go: fix vendoredImportPath comment
Change-Id: I1650124dd459dc401ccd73943ff7287b1b8c57e4
Reviewed-on: https://go-review.googlesource.com/13689
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-08-20 08:38:38 +00:00
Keith Randall
8d23681cc8 [dev.ssa] cmd/compile: implement more panic stuff
Implement index check panics (and slice check panics, for when
we need those).

Clean up nil check.  Now that the new regalloc is in we can use
the register we just tested as the address 0 destination.

Remove jumps after panic calls, they are unreachable.

Change-Id: Ifee6e510cdea49cc7c7056887e4f06c67488d491
Reviewed-on: https://go-review.googlesource.com/13687
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-19 23:17:48 +00:00
Keith Randall
46e62f873a [dev.ssa] cmd/compile: used Bounded field to fix empty range loops
for i, v := range a {
    }

Walk converts this to a regular for loop, like this:

    for i := 0, p := &a[0]; i < len(a); i++, p++ {
        v := *p
    }

Unfortunately, &a[0] fails its bounds check when a is
the empty slice (or string).  The old compiler gets around this
by marking &a[0] as Bounded, meaning "don't emit bounds checks
for this index op".  This change makes SSA honor that same mark.

The SSA compiler hasn't implemented bounds check panics yet,
so the failed bounds check just causes the current routine
to return immediately.

Fixes bytes package tests.

Change-Id: Ibe838853ef4046c92f76adbded8cca3b1e449e0b
Reviewed-on: https://go-review.googlesource.com/13685
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-19 21:44:44 +00:00
Todd Neal
67cbd5b51d [dev.ssa] cmd/compile/internal/ssa: implement OHMUL
Adds support for high multiply which is used by the frontend when
rewriting const division.  The frontend currently only does this for 8,
16, and 32 bit integer arithmetic.

Change-Id: I9b6c6018f3be827a50ee6c185454ebc79b3094c8
Reviewed-on: https://go-review.googlesource.com/13696
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-19 02:52:50 +00:00
Todd Neal
a45f2d8f28 [dev.ssa] cmd/compile/internal/ssa: implement ODIV
Implement integer division for non-consts.

Change-Id: If40cbde20e5f0ebb9993064def7be468e4eca076
Reviewed-on: https://go-review.googlesource.com/13644
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-18 22:15:53 +00:00
Keith Randall
d9dc2f2230 [dev.ssa] cmd/compile: fix string store rewrite
Store ops now need their size in the auxint field.  I missed this one.

Change-Id: I050fd6b5b00579883731702c426edafa3a5f7561
Reviewed-on: https://go-review.googlesource.com/13682
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-18 17:41:44 +00:00
Russ Cox
6f0c7df8ed cmd/vet: power64 is now ppc64
This was missed when we did the rename months ago
because cmd/vet did not live in the main tree.
Now vet's asmdecl checks will apply to ppc64 assembly too.

Change-Id: I687cba89fef702f29dd118de76a7ca1041c414f6
Reviewed-on: https://go-review.googlesource.com/13677
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-08-18 17:00:59 +00:00
Russ Cox
5acde2d5aa cmd/go: really skip TestNoteReading on linux/ppc64le
Change-Id: Iaeba7c55bbb9e11ac30f3b61369aa597acc30190
Reviewed-on: https://go-review.googlesource.com/13691
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-18 15:41:54 +00:00
Russ Cox
92c984e064 cmd/go: disable TestNoteReading on solaris, linux/ppc64le
Update #11184 (linux/ppc64).
Filed #12178 (solaris) for Go 1.6.

Change-Id: I9e3a456aaccb49590ad4e14b53ddfefca5b0801c
Reviewed-on: https://go-review.googlesource.com/13679
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-18 15:25:19 +00:00
Russ Cox
f68d1df6b9 cmd/compile: fix interaction between GOEXPERIMENT=fieldtrack and race detector
Tested by hand.
Only lines of code changing are protected by Fieldtrack_enabled > 0,
which is never true in standard Go distributions.

Fixes #12171.

Change-Id: I963b9997dac10829db8ad4bfc97a7d6bf14b55c6
Reviewed-on: https://go-review.googlesource.com/13676
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-18 14:36:01 +00:00
Russ Cox
9e26cde786 cmd/go: fix vendor-related index out of range panic on bad file tree
Fixes #12156.

Change-Id: I2d71163b98bcc770147eb9e78dc551a9d0b5b817
Reviewed-on: https://go-review.googlesource.com/13674
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-18 13:53:28 +00:00
Russ Cox
d2cf46dedf cmd/go: fix spurious rebuild of binaries using cgo on OS X
The text segment starts farther into the binary when using
external linking on the mac. Test and fix.

Fixes #12173.

Change-Id: I1f0c81814bf70cd9decfceac3022784f4608eeef
Reviewed-on: https://go-review.googlesource.com/13672
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-18 13:51:16 +00:00
Russ Cox
3f016215a8 cmd/yacc: fix compile error in empty grammar
Fixes #12154.

Change-Id: I1e6d1a3479a8a6fc8f53aebd18fb142506110809
Reviewed-on: https://go-review.googlesource.com/13673
Reviewed-by: Rob Pike <r@golang.org>
2015-08-18 13:50:36 +00:00
Keith Randall
0b46b42943 [dev.ssa] cmd/compile/internal/ssa: New register allocator
Implement a global (whole function) register allocator.
This replaces the local (per basic block) register allocator.

Clobbering of registers by instructions is handled properly.
A separate change will add the correct clobbers to all the instructions.

Change-Id: I38ce4dc7dccb8303c1c0e0295fe70247b0a3f2ea
Reviewed-on: https://go-review.googlesource.com/13622
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Todd Neal <todd@tneal.org>
2015-08-17 21:06:30 +00:00
Josh Bleecher Snyder
759b9c3b80 [dev.ssa] cmd/compile: add likely annotations to blocks in html
This was missing from CL 13472
due to a badly synced client.

Change-Id: If59fc669125dd1caa335dacfbf0f8dbd7b074312
Reviewed-on: https://go-review.googlesource.com/13639
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-17 18:56:33 +00:00
David Chase
997a9f32b0 [dev.ssa] cmd/compile: first unoptimized cut at adding FP support
Added F32 and F64 load, store, and addition.
Added F32 and F64 multiply.
Added F32 and F64 subtraction and division.
Added X15 to "clobber" for FP sub/div
Added FP constants
Added separate FP test in gc/testdata

Change-Id: Ifa60dbad948a40011b478d9605862c4b0cc9134c
Reviewed-on: https://go-review.googlesource.com/13612
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-17 17:38:28 +00:00
Josh Bleecher Snyder
270e2152c4 [dev.ssa] cmd/compile: fix dev.ssa build
Broken by CL 13472.

Change-Id: Ib65331b291c8fab4238ca91e085779bb954d70e8
Reviewed-on: https://go-review.googlesource.com/13638
Reviewed-by: David Chase <drchase@google.com>
2015-08-17 15:01:55 +00:00
Dave Cheney
467a2cb73c cmd/compile/internal/arm64: remove Reginuse check in clearfat
Fixes golang/go#12133

CL 13630 fixed the use of a stale reg[] array in the various arch
backends which was causing the check in clearfat to pass
unconditionally on arm64.

With this check fixed, arm64 now considers REGRT1 to always be in use
as it is part of the reserved register set, see arm64/gsubr.go.

However, ppc64 does not consider REGRT1 and REGRT2 to be part of its
reserved set, so its identical clearfat check passes.

This CL removes the Reginuse check inside clearfat as REGRT1 is
guarenteed always be free on arm64.

Change-Id: I4719150d3c3378fae155b863c474529df18d4c17
Reviewed-on: https://go-review.googlesource.com/13650
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-16 00:29:39 +00:00
Keith Randall
d4cc51d411 [dev.ssa] cmd/compile/internal/ssa: Use explicit size for store ops
Using the type of the store argument is not safe, it may change
during rewriting, giving us the wrong store width.

(Store ptr (Trunc32to16 val) mem)

This should be a 2-byte store.  But we have the rule:

(Trunc32to16 x) -> x

So if the Trunc rewrite happens before the Store -> MOVW rewrite,
then the Store thinks that the value it is storing is 4 bytes
in size and uses a MOVL.  Bad things ensue.

Fix this by encoding the store width explicitly in the auxint field.

In general, we can't rely on the type of arguments, as they may
change during rewrites.  The type of the op itself (as used by
the Load rules) is still ok to use.

Change-Id: I9e2359e4f657bb0ea0e40038969628bf0f84e584
Reviewed-on: https://go-review.googlesource.com/13636
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-15 23:18:21 +00:00
Dmitry Vyukov
e8c4a5b893 cmd/trace: fix static file reference
Use runtime.GOROOT instead of os.Getenv("GOROOT") to reference
trace-viewer html file. GOROOT env var is not necessary set,
runtime.GOROOT has a default value for such case.

Change-Id: I906a720f6822915bd9575756e6cbf6d622857c2b
Reviewed-on: https://go-review.googlesource.com/13593
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-15 17:38:56 +00:00
Rahul Chaudhry
5bf1369c9b cmd/go: make "go test" recognize -exec flag again.
Fixes #12144.

Change-Id: I112c6517371215c9797db8f1dffca0f3047c39e3
Reviewed-on: https://go-review.googlesource.com/13633
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-15 17:38:41 +00:00
Keith Randall
e97ab0a0ac cmd/compile: remove stale register use array
The reg[] array in .../gc is where truth lies.  The copy in .../ARCH
is incorrect as it is mostly not updated to reflect regalloc decisions.

This bug was introduced in the rewrite
https://go-review.googlesource.com/#/c/7853/.  The new reg[] array was
introduced in .../gc but not all of the uses were removed in the
.../ARCH directories.

Fixes #12133

Change-Id: I6364fc403cdab92d802d17f2913ba1607734037c
Reviewed-on: https://go-review.googlesource.com/13630
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-15 17:37:14 +00:00
Alexandru Moșoi
198fc9a9eb [dev.ssa] cmd/compile/internal/ssa/gen: more simplifications and foldings.
Change-Id: I74d1267dbfced2663072b4f091732c0fb328690f
Reviewed-on: https://go-review.googlesource.com/13641
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-14 23:14:36 +00:00
Alexandru Moșoi
7a6de6d5f2 [dev.ssa] cmd/compile/internal/ssa/gen: fold Mul8 properly.
Mul8 is lowered to MULW, but the rules for constant
folding do not handle the fact that the operands
are int8.

Change-Id: I2c336686d86249393a8079a471c6ff74e6228f3d
Reviewed-on: https://go-review.googlesource.com/13642
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-14 20:47:21 +00:00
Alexandru Moșoi
c55870a541 [dev.ssa] cmd/compile/internal/gc: handle all inputs for shifts.
Disable CX as output for shift operations.

Change-Id: I85e6b22d09009b38847082dc375b6108c2dee80a
Reviewed-on: https://go-review.googlesource.com/13370
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-13 21:58:12 +00:00
Josh Bleecher Snyder
35fb514596 [dev.ssa] cmd/compile: add HTML SSA printer
This is an initial implementation.
There are many rough edges and TODOs,
which will hopefully be polished out
with use.

Fixes #12071.

Change-Id: I1d6fd5a343063b5200623bceef2c2cfcc885794e
Reviewed-on: https://go-review.googlesource.com/13472
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-13 21:56:06 +00:00
Josh Bleecher Snyder
3e7904b648 [dev.ssa] cmd/compile: improve inBounds rewrite rules
Change-Id: Ia238187a89f820cd1620ab5acdbf1c8f003569b1
Reviewed-on: https://go-review.googlesource.com/13587
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-13 21:50:20 +00:00
Keith Randall
bc1f5768ce [dev.ssa] cmd/compile: add register spec to getg
This omission was causing the new regalloc to fail.

Change-Id: If7ba7be38a436dbd0dd443828ddd7ebf6e35be0e
Reviewed-on: https://go-review.googlesource.com/13632
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-13 20:51:56 +00:00
Keith Randall
3b705824ce [dev.ssa] cmd/compile: fix constant subtraction rules
(SUBQconst [x] y) computes y-x, not x-y.

Fixes #12137

Change-Id: Idbd0554eee051102f562240d1756647843666ee6
Reviewed-on: https://go-review.googlesource.com/13631
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-13 19:57:30 +00:00
Josh Bleecher Snyder
f85faefa67 [dev.ssa] cmd/compile: move rewrite logging behind codegen flag
Generating logging code every time causes large
diffs for small changes.

Since the intent is to use this for debugging only,
generate logging code only when requested.
Committed generated code will be logging free.

Change-Id: I9ef9e29c88b76c2557bad4c6b424b9db1255ec8b
Reviewed-on: https://go-review.googlesource.com/13623
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-13 00:10:13 +00:00
Keith Randall
867662da6a [dev.ssa] cmd/compile: make sure entry block has no predecessors
Fix one test that build a violating CFG.

Change-Id: Ie0296ced602984d914a70461c76559c507ce2510
Reviewed-on: https://go-review.googlesource.com/13621
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-12 22:27:15 +00:00
Josh Bleecher Snyder
514ab7c385 [dev.ssa] cmd/compile: log line numbers in generated rewrite rules
This makes it easier to investigate and
understand rewrite behavior.

Change-Id: I790e8964922caf98362ce8a6d6972f52d83eefa8
Reviewed-on: https://go-review.googlesource.com/13588
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-12 22:10:28 +00:00
Josh Bleecher Snyder
3d23afb913 [dev.ssa] cmd/compile: implement OGETG
Change-Id: I7ecf62cf399c710b4a617803c43e83fce09b8a7d
Reviewed-on: https://go-review.googlesource.com/13585
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-12 22:05:42 +00:00
Josh Bleecher Snyder
bbf8c5ce2f [dev.ssa] cmd/compile: initial implementation of likely direction
Change-Id: Id8457b18c07bf717d13c9423d8f314f253eee64f
Reviewed-on: https://go-review.googlesource.com/13580
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-12 22:03:08 +00:00
Josh Bleecher Snyder
212a1763fc [dev.ssa] cmd/compile: update opnames
This claims to be autogenerated from go tool dist,
but I don't see where.

In any case, the update is trivial.

Change-Id: I58daaba755f3d34a0396005046b89411a02ada7e
Reviewed-on: https://go-review.googlesource.com/13584
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-12 20:57:12 +00:00
Josh Bleecher Snyder
a2d1580fdb [dev.ssa] cmd/compile: implement OSPTR
Change-Id: Iaa40f14a1e3e4393af3c446953ffc315e79a3762
Reviewed-on: https://go-review.googlesource.com/13581
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-12 20:56:48 +00:00
Keith Randall
d56d2fa206 [dev.ssa] cmd/compile: fix function call memory
We need to move the memory variable update back to before endBlock
so that all successors use the right memory value.

See https://go-review.googlesource.com/13560

Change-Id: Id72e5526c56e5e070b933d3b28dc503a5a2978dc
Reviewed-on: https://go-review.googlesource.com/13586
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-08-12 20:35:53 +00:00
Dave Cheney
cda1fc0071 cmd/compile/internal/ppc64: disable DUFFZERO
Update #12108

If DUFFZERO is used within a tail call method it will overwrite the
link register.

Change-Id: I6abd2fde0f0ad909ccd55eb119b992673a74f0e2
Reviewed-on: https://go-review.googlesource.com/13570
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-12 20:31:26 +00:00
Todd Neal
ce97788914 [dev.ssa] cmd/compile/ssa: fix test for dse
Fix the test broken with dee1f2 by implementing Elem()

Change-Id: I7a4a487885267c24fdc52d79fb7d450231328812
Reviewed-on: https://go-review.googlesource.com/13551
Reviewed-by: Keith Randall <khr@golang.org>
2015-08-12 00:48:39 +00:00