1
0
mirror of https://github.com/golang/go synced 2024-11-08 12:16:15 -07:00
Commit Graph

10875 Commits

Author SHA1 Message Date
griesemer
c87fb208c5 cmd/compile/internal/syntax: remove some outdated comments (cleanup)
Change-Id: If242bb99d501420827b764c908580f2363e01ac4
Reviewed-on: https://go-review.googlesource.com/69730
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-10-11 00:29:33 +00:00
Carlos Eduardo Seo
3a165bba34 cmd/asm, cmd/internal/obj/ppc64: Fix Data Cache instructions for ppc64x
This change fixes the implementation of Data Cache instructions for
ppc64x, allowing non-zero hint field values.

Change-Id: I454aac9293d069a4817ee574d5809fa1799b3216
Reviewed-on: https://go-review.googlesource.com/68670
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2017-10-10 21:25:33 +00:00
Cherry Zhang
d63de28711 cmd/compile: intrinsify atomics on MIPS64
Change-Id: Ica65b7a52af9558a05d0a0e1dff0f9ec838f4117
Reviewed-on: https://go-review.googlesource.com/68830
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-10-10 19:43:38 +00:00
Matthew Dempsky
b80029ccf4 cmd/compile: simplify mkinlcall1
mkinlcall1 already guards against recursively inlining functions into
themselves, so there's no need to clear and restore fn.Func.Inl during
recursive inlining.

Passes toolstash-check.

Change-Id: I8bf0c8dea8788d94d3ea5670610b4acb1d26d2fb
Reviewed-on: https://go-review.googlesource.com/69310
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-10-10 17:53:27 +00:00
Matthew Dempsky
f58c6c9915 cmd/compile: remove outdated TODO about inlining
We've supported inlining methods called as functions for a while now.

Change-Id: I53fba426e45f91d65a38f00456c2ae1527372b50
Reviewed-on: https://go-review.googlesource.com/69530
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-10-10 17:53:22 +00:00
Daniel Martí
f14f7b3141 cmd/compile: make bad Ctypes be only 0
Before, -1 meant a node being nil or not an OLITERAL, and 0 meant an
OLITERAL missing a Val.

However, the use of this value was confusing and led to some issues,
such as swt.go checking for < 0 instead of <= 0, causing panics.

We never need to differentiate these two cases, so collapse both into 0.
To make it clear that negative values can no longer happen, make Ctype
an uint8.

With this change, we can now get rid of the two n.Type == nil checks
in swt.go added to fix a couple of these panics.

Thanks to Matthew Dempsky for spotting this inconsistency.

Fixes #22001.

Change-Id: I51c65a76f38a3e16788b6a3b57932dad3436dc7e
Reviewed-on: https://go-review.googlesource.com/69510
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-10 17:06:53 +00:00
Cherry Zhang
d5a2925b7d cmd/compile: clean up ADDconst on PPC64
ADDconst op is no longer used for addresses, as we lower Addr to
MOVDaddr. There is no rule that produces ADDconst with a non-nil
sym. So we can remove the sym aux field in ADDconst and limit its
use for adding constant (not offset to symbol).

Passes "toolstash -cmp" on std cmd for GOARCH=ppc64 and ppc64le.

Change-Id: Icee35cdb34d8d121ad7035076dfd07595c7ff809
Reviewed-on: https://go-review.googlesource.com/69450
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2017-10-10 15:54:13 +00:00
Cherry Zhang
6f3e5e637c cmd/compile: intrinsify runtime.getcallersp
Add a compiler intrinsic for getcallersp. So we are able to get
rid of the argument (not done in this CL).

Change-Id: Ic38fda1c694f918328659ab44654198fb116668d
Reviewed-on: https://go-review.googlesource.com/69350
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
2017-10-10 15:15:21 +00:00
Elias Naur
ae175f74cb runtime: fix cgo export of panicmem on ios
CL 68490 reworked the way the panicmem function is exposed to the
C mach expection catcher. However, //go:cgo_export_static isn't enough:
the underlying assembly functions must not start with the middle dot.

Without the middle dot, the panicmem function's exported name is
not prefixed with its package; rename it to xx_cgo_panicmem to decrease
the chance of a symbol name clash.

Finally, mark the overridden C symbol weak to avoid duplicate symbol
errors from the host linker.

For the ios builders.

Change-Id: Ib87789fecec9314e398cf1bd8c04ba0b3a6642af
Reviewed-on: https://go-review.googlesource.com/69113
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2017-10-10 08:49:16 +00:00
Alex Brainman
bb0bfd002a cmd/dist, cmd/link, cmd/go: make c-shared work on windows
Thanks to Christopher Nelson for spearheading the effort.

Fixes #11058

Change-Id: Icafabac8dc697626ff1bd943cc577b0b1cc6b349
Reviewed-on: https://go-review.googlesource.com/69091
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-10 01:02:27 +00:00
Russ Cox
0174858c71 cmd/go: add undocumented -debug-actiongraph flag to dump action graph
This will be useful for debugging but is intentionally
undocumented and not guaranteed to persist in any
particular form.

Change-Id: I60710a1e94cfc2ce31fe91fc268c51985060f8df
Reviewed-on: https://go-review.googlesource.com/69330
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-10 00:19:37 +00:00
Daniel Martí
966c459fa4 cmd/link: various cleanups using tools
* remove unnecessary explicit types
* remove dead assignments
* remove unused fields
* unindent code using early continues
* remove some unnecessary type conversions
* remove some unused func parameters

Change-Id: I202c67e92940beacbd80fc2dc179f9556dc5d9e5
Reviewed-on: https://go-review.googlesource.com/69118
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-10-09 22:08:17 +00:00
Keith Randall
7830a19a4f cmd/compile: add ideal int constants to dwarf
The core dump reader would like a bunch of ideal int
constants to be available in dwarf.

Makes the go binary 0.9% bigger.

Update #14517

Change-Id: I00cdfc7f53bcdc56fccba576c1d33010f03bdd95
Reviewed-on: https://go-review.googlesource.com/69270
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2017-10-09 21:30:03 +00:00
David Chase
4a2376ef02 cmd/compile: skip ssa/debug_test.go when gdb missing etc.
CL50610 broke the build for noopt (different inlining
behavior) and clang (no gdb) so it needs to catch those
cases and skip.

The run/no-run logic was slightly cleaned up,
the name of gdb on OSX was made more robust (tries gdb
first, then ggdb), and the file names were canonicalized
before loggging instead of in comparison to reduce
gratuitous noise in diffs when things aren't otherwise
equal.

This probably doesn't fix problems on Alpine, but it should
provide a cleaner and less confusing failure.

Change-Id: I26c65bff5a8d3d60f1cd6ae02a282558c53dda67
Reviewed-on: https://go-review.googlesource.com/69371
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-10-09 21:08:19 +00:00
griesemer
1ddacfea7b cmd/compile/internal/syntax: remove unused code
Change-Id: I9c75dee7e4498cc11c08cad1ae34ff2af75f1469
Reviewed-on: https://go-review.googlesource.com/69071
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-10-09 17:44:08 +00:00
Josselin Costanzi
244c98fe01 encoding/base64: optimize DecodeString
Optimize base64 decoding speed by adding 32-bits and 64-bits specialized
methods that don't perform any error checking and fall back to the more
complex decodeQuantum method when a non-base64 character is present.

On a 64-bits cpu:

name                 old time/op    new time/op     delta
DecodeString/2-4       70.0ns ± 6%     69.2ns ± 0%     ~     (p=0.169 n=5+8)
DecodeString/4-4       91.3ns ± 2%     80.4ns ± 0%  -11.89%  (p=0.001 n=5+10)
DecodeString/8-4        126ns ± 5%      106ns ± 0%  -16.14%  (p=0.000 n=5+7)
DecodeString/64-4       652ns ±21%      361ns ± 0%  -44.57%  (p=0.000 n=5+7)
DecodeString/8192-4    61.0µs ±13%     31.5µs ± 1%  -48.38%  (p=0.001 n=5+9)

name                 old speed      new speed       delta
DecodeString/2-4     57.2MB/s ± 6%   57.7MB/s ± 2%     ~     (p=0.419 n=5+9)
DecodeString/4-4     87.7MB/s ± 2%   99.5MB/s ± 0%  +13.45%  (p=0.001 n=5+10)
DecodeString/8-4     94.8MB/s ± 5%  112.6MB/s ± 1%  +18.82%  (p=0.001 n=5+9)
DecodeString/64-4     136MB/s ±19%    243MB/s ± 0%  +78.17%  (p=0.003 n=5+7)
DecodeString/8192-4   180MB/s ±11%    347MB/s ± 1%  +92.94%  (p=0.001 n=5+9)

Improves #19636

Change-Id: Ic10a454851093a7e1d46ca0c140deed73535d990
Reviewed-on: https://go-review.googlesource.com/38632
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-09 15:39:51 +00:00
Daniel Martí
320b0cdd77 cmd/vet: skip self-assigns with side effects
The existing logic for whether the left and right parts of an assignment
were equal only checked that the gofmt representation of the two was
equal. This only checks that the ASTs were equal.

However, that method is flawed. For example, if either of the
expressions contains a function call, the expressions may actually be
different even if their ASTs are the same. An obvious case is a func
call to math/rand to get a random integer, such as the one added in the
test.

If either of the expressions may have side effects, simply skip the
check. Reuse the logic from bool.go's hasSideEffects.

Fixes #22174.

Change-Id: Ied7f7543dc2bb8852e817230756c6d23bc801d90
Reviewed-on: https://go-review.googlesource.com/69116
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2017-10-09 09:26:31 +00:00
David Crawshaw
e285f39248 cmd/link: ignore macho symbols in invalid sections
Restores linker behavior that existed before CL 68930.
Hopefully fixes the macOS 10.8 builder.

Change-Id: Ib8d6923b59543008cf71c4625addb4e2045cedf6
Reviewed-on: https://go-review.googlesource.com/69170
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
2017-10-08 20:14:33 +00:00
David Chase
ca360c3992 cmd/compile: better XPos for rematerialized values and JMPs
This attempts to choose better values for values that are
rematerialized (uses the XPos of the consumer, not the
original) and for unconditional branches (uses the last
assigned XPos in the block).

The JMP branches seem to sometimes end up with a PC in the
destination block, I think because of register movement
or rematerialization that gets placed in predecessor blocks.
This may be acceptable because (eyeball-empirically) that is
often the line number of the target block, so the line number
flow is correct.

Added proper test, that checks both -N -l and regular compilation.
The test is also capable (for gdb, delve soon) of tracking
variable printing based on comments in the source code.

There's substantial room for improvement in debugger behavior.

Updates #21098.

Change-Id: I13abd48a39141583b85576a015f561065819afd0
Reviewed-on: https://go-review.googlesource.com/50610
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-10-07 22:12:36 +00:00
Marvin Stenger
da4d740fc8 cmd/link/internal/loadmacho: reduce scope of local declarations
Move some local declarations closer to their use, reducing their
respective lifetimes, also improve few error messages.
Follow up of CL 67370.

Updates #22095

Change-Id: I6131159ae8de571015ef5459b33d5c186e543a37
Reviewed-on: https://go-review.googlesource.com/69110
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-07 13:35:26 +00:00
David Crawshaw
f7ad3a04f9 cmd/link: move ldmacho to its own package
For #22095

Change-Id: I660080279692b74669c45f42c28cccff71bd33b5
Reviewed-on: https://go-review.googlesource.com/68930
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-06 22:01:22 +00:00
Russ Cox
840f2c167f cmd/asm, cmd/cgo, cmd/compile, cmd/cover, cmd/link: use standard -V output
Also add -V=full to print a unique identifier of the specific tool being invoked.
This will be used for content-based staleness.

Also sort and clean up a few of the flag doc comments.

Change-Id: I786fe50be0b8e5f77af809d8d2dab721185c2abd
Reviewed-on: https://go-review.googlesource.com/68590
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-10-06 20:28:40 +00:00
David Chase
cf01e6f212 cmd/compile: add test generator for control and data flow
From a compact specification of control flow graphs,
generate complete set of possible assignment patterns to
output y, and also generate an interpretable specification.
Compiles (hoping for crash, or not) and then runs, where
the run checks function output against interpreted output
for various inputs observed to terminate in the interpreter.

In ssa_test.go, added ability to generate a test and run
(compile and run) the generated test, possibly with
modified environment variables.  The generated test is
compiled including the -D=ssa/check/on flag, and if the
interpreter terminates in a small number of steps, then it
is also run to check the result.

Change-Id: I392c828e36c543411b7733ca0799628452733276
Reviewed-on: https://go-review.googlesource.com/22751
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-10-06 17:14:41 +00:00
griesemer
b77d9fe0ea cmd/compile: better error message for assignment mismatches
Keep left-to-right order when referring to the number of
variables and values involved.

Fixes #22159.

Change-Id: Iccca12d3222f9d5e049939a9ccec07513c393faa
Reviewed-on: https://go-review.googlesource.com/68690
Reviewed-by: Russ Cox <rsc@golang.org>
2017-10-06 16:35:44 +00:00
isharipo
e33b01651c cmd/asm: fix build error caused by yextractps
Fix ytab table for EXTRACTPS.
Related to https://go-review.googlesource.com/#/c/go/+/63490/.

Change-Id: I11672d6bb731a204a08905f8321450f02c5bed76
Reviewed-on: https://go-review.googlesource.com/68950
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-06 16:23:44 +00:00
isharipo
41fa265db0 obj/x86: make VEX-specified-register explicit
"VEX.vvvv" field (VSR, VEX-specified-register) made explicit
in Optab encoding.

vexNDS, vexNDD, vexDDS and vexNOVSR do nothing,
this change does not produce any noticeable effect.

Rationale behind this change:
- keep more information inside optab entries
- make encodings match SDM more closely
- one less special rule to keep in mind

Pvex optabs are updated based on the Intel SDM descriptions.

Unused VEX combinations are removed;
it is problematic to choose VSR combinations for them
without actual Optabs that use them.

The origin of this idea can be found in:
https://go-review.googlesource.com/#/c/arch/+/66972/

Change-Id: I54634a72b44d61f4b924a1e45f2240aab7384dc2
Reviewed-on: https://go-review.googlesource.com/67890
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2017-10-06 15:44:54 +00:00
isharipo
ca5127cbcd cmd/asm: add amd64 EXTRACTPS instruction
Adds last missing SSE4 instruction.
Also introduces additional ytab set 'yextractps'.

See https://golang.org/cl/57470 that adds other SSE4 instructions
but skips this one due to 'yextractps'.

To make EXTRACTPS less "sloppy", Yu2 oclass added to forbid
usage of invalid offset values in immediate operand.

Part of the mission to add missing amd64 SSE4 instructions to Go asm.

Change-Id: I0e67e3497054f53257dd8eb4c6268da5118b4853
Reviewed-on: https://go-review.googlesource.com/57490
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2017-10-06 15:44:29 +00:00
Aliaksandr Valialkin
0011cfbe2b cmd/compile: optimize signed non-negative div/mod by a power of 2
This CL optimizes assembly for len() or cap() division
by a power of 2 constants:

    func lenDiv(s []int) int {
        return len(s) / 16
    }

amd64 assembly before the CL:

    MOVQ    "".s+16(SP), AX
    MOVQ    AX, CX
    SARQ    $63, AX
    SHRQ    $60, AX
    ADDQ    CX, AX
    SARQ    $4, AX
    MOVQ    AX, "".~r1+32(SP)
    RET

amd64 assembly after the CL:

    MOVQ    "".s+16(SP), AX
    SHRQ    $4, AX
    MOVQ    AX, "".~r1+32(SP)
    RET

The CL relies on the fact that len() and cap() result cannot
be negative.

Trigger stats for the added SSA rules on linux/amd64 when running
make.bash:

     46 Div64
     12 Mod64

The added SSA rules may trigger on more cases in the future
when SSA values will be populated with the info on their
lower bounds.

For instance:

    func f(i int16) int16 {
        if i < 3 {
            return -1
        }

        // Lower bound of i is 3 here -> i is non-negative,
        // so unsigned arithmetics may be used here.
        return i % 16
    }

Change-Id: I8bc6be5a03e71157ced533c01416451ff6f1a7f0
Reviewed-on: https://go-review.googlesource.com/65530
Reviewed-by: Keith Randall <khr@golang.org>
2017-10-06 15:15:39 +00:00
David Crawshaw
2e8545531e cmd/link: move build/link mode globals into ctxt
Replace Buildmode with BuildMode and Linkmode with LinkMode.

For #22095

Change-Id: I51a6f5719d107727bca29ec8e68e3e9d87e31e33
Reviewed-on: https://go-review.googlesource.com/68334
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-06 13:49:11 +00:00
David Crawshaw
9f9bb97420 cmd/link: give the object reader its own package
For #22095

Change-Id: Ie9ae84c758af99ac7daed26d0b3e3b0a47599edd
Reviewed-on: https://go-review.googlesource.com/67315
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-06 13:33:15 +00:00
Alberto Donizetti
03614562ca cmd/compile: remove x86 arch-specific rules for +2ⁿ multiplication
amd64 and 386 have rules to reduce multiplication by a positive power
of two, but a more general reduction (both for positive and negative
powers of two) is already performed by generic rules that were added
in CL 36323 to replace walkmul (see lines 166:173 in generic.rules).

The x86 and amd64 rules are never triggered during all.bash and can be
removed, reducing rules duplication.

The change also adds a few code generation tests for amd64 and 386.

Change-Id: I566d48186643bd722a4c0137fe94e513b8b20e36
Reviewed-on: https://go-review.googlesource.com/68450
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-10-06 09:30:57 +00:00
Marvin Stenger
d153df8e4b all: revert "all: prefer strings.LastIndexByte over strings.LastIndex"
This reverts https://golang.org/cl/66372.

Updates #22148

Change-Id: I3e94af3dfc11a2883bf28e1d5e1f32f98760b3ee
Reviewed-on: https://go-review.googlesource.com/68431
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-05 23:19:42 +00:00
Marvin Stenger
90d71fe99e all: revert "all: prefer strings.IndexByte over strings.Index"
This reverts https://golang.org/cl/65930.

Fixes #22148

Change-Id: Ie0712621ed89c43bef94417fc32de9af77607760
Reviewed-on: https://go-review.googlesource.com/68430
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-05 23:19:10 +00:00
Matthew Dempsky
31a3b719a0 cmd/compile: cleanup genwrapper slightly
ORETJMP doesn't need an ONAME if we just set the target method on Sym
instead of Left. Conveniently, this is where fmt.go was looking for it
anyway.

Change the iface parameter and global compiling_wrappers to bool.

Passes toolstash-check.

Change-Id: I5333f8bcb4e06bf8161808041125eb95c439aafe
Reviewed-on: https://go-review.googlesource.com/68252
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-10-05 22:37:16 +00:00
Cherry Zhang
a92a77c56f cmd/internal/obj/arm64: fix handling of unaligned offset between 256 and 504
C_PPAUTO was matching offsets that is a multiple 8. But this
condition is dropped in CL 55610, causing unaligned offset
between 256 and 504 mistakenly matched to some classes, e.g.
C_UAUTO8K. This CL restores this condition, also fixes an
error that C_PPAUTO shouldn't match C_PSAUTO, because the
latter is not guaranteed to be multiple of 8. C_PPAUTO_8 is
unnecessary, removed.

Fixes #21992.

Change-Id: I75d5a0e5f5dc3dae335721fbec1bbcd4a3b862f2
Reviewed-on: https://go-review.googlesource.com/65730
Reviewed-by: David Chase <drchase@google.com>
2017-10-05 22:28:17 +00:00
Ilya Tocar
6b8a3c8889 cmd/compile/internal/amd64: add SETccmem
Combine setcc and store of result into setcc that writes directly to memory.
Triggers 200+ times in go tool.

Fixes #21630

Change-Id: Iafa22607426f4120140c88fae4b9aecb46e0bba8
Reviewed-on: https://go-review.googlesource.com/67950
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-10-05 20:53:28 +00:00
Russ Cox
aac0d52d97 cmd/go: stop treating GOROOT binaries specially
This was for cmd/cgo, and cmd/cgo isn't special anymore.

Change-Id: I71efaf553b24798b523c7102859428d36b470698
Reviewed-on: https://go-review.googlesource.com/68530
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-10-05 20:06:29 +00:00
Russ Cox
555c16d8cb cmd/dist, cmd/go: treat cmd/cgo like other build tools
The primary build tools cmd/asm, cmd/compile, and cmd/link are
built during cmd/dist bootstrap and then assumed by cmd/go to
be available for any future builds.

The only tool invoked by cmd/go during a build and not in this list
is cmd/cgo; instead of being built during cmd/dist and assumed by
cmd/go, cmd/go arranges to build cmd/cgo if needed as part of
the regular build. We got here because at the time cmd/go was written,
cmd/cgo was the only build tool written in Go (the others were in C),
and so it made some sense to put cmd/dist in charge of building
the C tools and to have custom code in cmd/go to build cmd/cgo
just in time for it to be used by a particular build.

This custom code has historically been quite subtle, though, because
the build of cmd/cgo inherits whatever build flags apply to the
build that wants to use cmd/cgo. If you're not careful,
"go install -race strings" might under the wrong circumstances
also install a race-enabled cmd/cgo binary, which is unexpected
at the least.

The custom code is only going to get more problematic as we
move toward more precise analysis of whether dependencies are
up-to-date. In that case, "go build -race strings" will check to
see if there is not just a cmd/cgo already but a race-enabled
cmd/cgo, which makes no sense.

Instead of perpetuating the special case, treat cgo like all the
other build tools: build it first in cmd/dist, and then assume it is present.
This simplifies cmd/go.

Building cmd/cgo during bootstrap also allows the default
build of cmd/cgo to be built using cgo, which may be necessary
on future essentially-cgo-only systems.

Change-Id: I414e22c10c9920f4e98f97fa35ff22058c0f143d
Reviewed-on: https://go-review.googlesource.com/68338
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-10-05 18:50:32 +00:00
David Chase
9e21e9c5cb cmd/compile: make loop finder more aware of irreducible loops
The loop finder doesn't return good information if it
encounters an irreducible loop.  Make a start on improving
this, and set a function-level flag to indicate when there
is such a loop (and the returned information might be flaky).

Use that flag to prevent the loop rotater from getting
confused; the existing code seems to depend on artifacts
of the previous loop-finding algorithm. (There is one
irreducible loop in the go library, in "inflate.go").

Change-Id: If6e26feab38d9b009d2252d556e1470c803bde40
Reviewed-on: https://go-review.googlesource.com/42150
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2017-10-05 18:49:10 +00:00
Matthew Dempsky
acdb44765d cmd/internal/dwarf: remove unused SymValue method
Change-Id: Ied42c2778899ce12cc256f0a124b77bf0e141aee
Reviewed-on: https://go-review.googlesource.com/68471
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-05 18:35:39 +00:00
Russ Cox
5edfaa2cf8 cmd/go: clean up implicit compiler and linker dependencies
Telling the truth about these will be important for
content-based staleness checks.

Change-Id: Iaed6ca6c945eb805d815156753a3e5dc48c6f0b9
Reviewed-on: https://go-review.googlesource.com/68336
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-10-05 18:17:57 +00:00
Russ Cox
69b0b3ad22 cmd/go, runtime/cgo: rewrite darwin/arm panicmem setup to avoid init function
Init functions are problematic because we want cmd/link to be
able to insert an import of runtime/cgo for external linking.
For all the other systems that just means putting runtime/cgo into
the binary. The linker is not set up to generate calls to init functions,
and luckily this one can be avoided entirely.

This means people don't have to import _ "runtime/cgo" in their
iOS programs anymore. The linker's default import is now enough.

This CL also adjusts cmd/go to record the linker's default import,
now that the explicit import is gone.

Change-Id: I81d23476663e03664f90d531c24db2e4f2e6c66b
Reviewed-on: https://go-review.googlesource.com/68490
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-05 18:17:27 +00:00
Matthew Dempsky
f22ef70254 cmd/compile: allow := to shadow dot-imported names
Historically, gc optimistically parsed the left-hand side of
assignments as expressions. Later, if it discovered a ":=" assignment,
it rewrote the parsed expressions as declarations.

This failed in the presence of dot imports though, because we lost
information about whether an imported object was named via a bare
identifier "Foo" or a normal qualified "pkg.Foo".

This CL fixes the issue by specially noding the left-hand side of ":="
assignments.

Fixes #22076.

Change-Id: I18190ecdb863112e7d009e1687e6112eec559921
Reviewed-on: https://go-review.googlesource.com/66810
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-05 18:07:37 +00:00
Russ Cox
8ec188975b cmd/go/internal/work: pass *Action to toolchain methods
This shortens the args lists but also sets up better for
the content-based staleness changes.

While we're here, delete the now-unused Pkgpath method.

Change-Id: Ic60fa03efbc37a7c7fe9758a1cfa5dddef1a4151
Reviewed-on: https://go-review.googlesource.com/68335
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-10-05 17:27:26 +00:00
Ben Shi
0ed1c38017 cmd/internal/obj/arm: support more ARMv6 instructions
The following instructions were introduced in ARMv6, and the compiler
can do more optimization with them.

1. "MOVBS Rm@>i, Rd": rotates Rm 0/8/16/24 bits, does signed
byte extension to word, and writes the result to Rd.

2. "MOVHS Rm@>i, Rd": rotates Rm 0/8/16/24 bits, does signed
halfword extension to word, and writes the result to Rd.

3. "MOVBU Rm@>i, Rd": rotates Rm 0/8/16/24 bits, does unsigned
byte extension to word, and writes the result to Rd.

4. "MOVHU Rm@>i, Rd": rotates Rm 0/8/16/24 bits, does unsigned
half-word extension to word, and writes the result to Rd.

5. "XTAB Rm@>i, Rn, Rd": rotates Rm 0/8/16/24 bits, does signed
byte extension to word, adds Rn, and writes the result to Rd.

6. "XTAH Rm@>i, Rn, Rd": rotates Rm 0/8/16/24 bits, does signed
half-word extension to word, adds Rn, and writes the result to Rd.

7. "XTABU Rm@>i, Rn, Rd": rotates Rm 0/8/16/24 bits, does unsigned
byte extension to word, adds Rn, and writes the result to Rd.

8. "XTAHU Rm@>i, Rn, Rd": rotates Rm 0/8/16/24 bits, does unsigned
half-word extension to word, adds Rn, and writes the result to Rd.

Change-Id: I4306d7ebac93015d7e2e40d307f2c4271c03f466
Reviewed-on: https://go-review.googlesource.com/65790
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-05 13:52:42 +00:00
David Crawshaw
a910fe2c83 cmd/link: move Library type to sym package
For #22095

Change-Id: I2cb0d3e0aaf9f97952cf8dda0e99a4379e275020
Reviewed-on: https://go-review.googlesource.com/68332
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-05 12:21:19 +00:00
David Crawshaw
475d92ba4d cmd/link: put symbol data types in new package
For #22095

Change-Id: I07c288208d94dabae164c2ca0a067402a8e5c2e6
Reviewed-on: https://go-review.googlesource.com/68331
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-05 10:50:18 +00:00
David Crawshaw
24e4a128c9 cmd/link: type symbol name mangling for plugins
Moves type symbol name mangling out of the object reader
and into a separate pass. Requires some care, as changing
the name of a type may require dealing with duplicate
symbols for the first time.

Disables DWARF for both plugins and programs that use plugin.Open,
because type manging is currently incompatible with the go.info.*
symbol generator in cmd/link. (It relies on the symbol names to
find type information.) A future fix for this would be moving the
go.info.* generation into the compiler, with the logic we use
for generating the type.* symbols.

Fixes #19529

Change-Id: I75615f8bdda86ff9e767e536d9aa36e15c194098
Reviewed-on: https://go-review.googlesource.com/67312
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-05 09:51:31 +00:00
Russ Cox
be272ec071 cmd/go/internal/cache: add support definitions
There is no cache here yet. This CL defines ActionID, Hash, and HashFile,
which the new content-based staleness code can use. Eventually we'll
put a real cache implementation here, but it's not necessary yet.

Change-Id: Ide433cb449f4dbe658694453f348c947642df79b
Reviewed-on: https://go-review.googlesource.com/67311
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-10-05 08:28:41 +00:00
Austin Clements
ba42b3ffd3 cmd/link: sniff runtime-gdb.py path from runtime/proc.go
Currently the linker figures out where runtime-gdb.py should be by
looking for the path to runtime/debug.go. However, debug.go contains
only a few symbols and can easily get dead-code eliminated entirely,
especially from simple binaries. When this happens, the resulting
binary lacks a reference to runtime-gdb.py, so the GDB helpers don't
get loaded.

Fix this by instead sniffing for runtime/proc.go. This contains
runtime.main and the scheduler, so it's not going anywhere.

Change-Id: Ie3380c77c840d28614fada68b8c5861625f2aff5
Reviewed-on: https://go-review.googlesource.com/68019
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-10-05 02:02:50 +00:00