1
0
mirror of https://github.com/golang/go synced 2024-09-29 14:24:32 -06:00
Commit Graph

52018 Commits

Author SHA1 Message Date
Ian Lance Taylor
5fcc6554d9 os: use syscall.Timespec.Unix
Use the syscall method instead of repeating the type conversions for each OS.

Change-Id: I1db975b3aaa189cf724d7b1b7c5c41bc64dd964d
Reviewed-on: https://go-review.googlesource.com/c/go/+/374574
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2022-03-28 04:41:26 +00:00
mzh
ad646b33c9 Revert "reflect, runtime: add reflect support for regabi on riscv64"
This reverts commit 56400fc706.

Reason for revert: this CL requires CL360296 be merged

Change-Id: I4c48c4d23b73b6e892cf86cbbc864698ebc5c992
Reviewed-on: https://go-review.googlesource.com/c/go/+/396076
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-28 01:10:35 +00:00
Patrick Gundlach
0eea25159f encoding/xml: expose decoder line and column
The existing implementation of the xml decoder uses the line number
only for reporting syntax errors. The line number of the last read
token and the column within the line is useful for the users even
in non-error conditions.

Fixes #45628

Change-Id: I37b5033ff5ff8411793d8f5180f96aa4537e83f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/311270
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2022-03-27 20:26:46 +00:00
zhangjian
234283d8ab go/build: remove unused code in TestDependencies
Change-Id: I7ccffbf96bd30f33bb42b6a2592962e2d4dda9fc
GitHub-Last-Rev: 2d6e214ac5
GitHub-Pull-Request: golang/go#51231
Reviewed-on: https://go-review.googlesource.com/c/go/+/386374
Reviewed-by: mzh <mzh@golangcn.org>
Trust: mzh <mzh@golangcn.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2022-03-27 20:23:47 +00:00
Carl Johnson
0bbd05b826 time: add Duration.Abs
Fixes #51414

Change-Id: Ia3b1674f2a902c8396fe029397536643a3bc1784
GitHub-Last-Rev: 67159648af
GitHub-Pull-Request: golang/go#51739
Reviewed-on: https://go-review.googlesource.com/c/go/+/393515
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2022-03-27 20:23:17 +00:00
Andy Pan
737837c9d4 regexp: use input.step() to advance one rune in Regexp.allMatches()
Change-Id: I32944f4ed519419e168e62f9ed6df63961839259
Reviewed-on: https://go-review.googlesource.com/c/go/+/359197
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-27 20:22:06 +00:00
Keith Randall
018b78cc5b test: fix inline test on noopt builder
CL 394074 broke the noopt builder. Something about time.After's inlining
depends on the build flags to make.bash, not the build flags that run.go
passes.

Change-Id: Ib284c66ea2008a4d32829c055d57c54a34ec3fb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/396037
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2022-03-27 18:38:56 +00:00
Keith Randall
3bd8c78575 cmd/compile: upgrade prove pass to know results of math/bits ops are nonnegative
Fixes #51963

Change-Id: Ib9e0521222e6fc41e787f3150b254e058a19addc
Reviewed-on: https://go-review.googlesource.com/c/go/+/396036
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Eric Fang <eric.fang@arm.com>
2022-03-27 17:03:16 +00:00
Keith Randall
7d3b64a2e3 cmd/compile: optimize BSRQ with nonzero input
Same as BSFQ, if the input is known to be nonzero we don't need a CMOV
to correct for the weird all-zero behavior of the BSRQ instruction.

Fixes #51964

Change-Id: Ic1d14fdf3e7e698ff2f47efecfd761d8a036012a
Reviewed-on: https://go-review.googlesource.com/c/go/+/396034
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-03-27 17:02:31 +00:00
Meng Zhuo
56400fc706 reflect, runtime: add reflect support for regabi on riscv64
This CL adds regabi support needed for reflect.

Change-Id: Ib78f8c7765f03e3a7b46e8b115bf8870b8076e6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/360994
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-03-27 12:55:16 +00:00
Baokun Lee
79e051ad33 cmd/go/internal/modfetch: remove unused FileRev struct
In CL 367756 we remove ReadFileRevs function, We simplified
the implementation of the interface Repo. and the type FileRev
is no longer used.

Change-Id: Iec9e2f0d6bb227f4d0d0f565e897137dcf392a3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/373375
Trust: Lee Baokun <bk@golangcn.org>
Run-TryBot: Lee Baokun <bk@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-03-27 06:12:30 +00:00
hopehook
b0750de656 os: document DirFS implements fs.StatFS
Fixes #51856

Change-Id: I8328d73bbb7bc166d58281180b64785a634e9bab
Reviewed-on: https://go-review.googlesource.com/c/go/+/394555
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-26 23:18:20 +00:00
Keith Randall
3f69cc7d77 Revert "cmd/compile: stop interface conversions for generic method calls from allocating"
This reverts commit e550c30545.

Reason for revert: Method bound calls are no longer implemented using interface calls, so it is no longer necessary. Leaving the test, though.

Change-Id: I80f1e4cd921063cd27ca8f07998316ca282e075b
Reviewed-on: https://go-review.googlesource.com/c/go/+/395594
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-26 20:36:39 +00:00
Keith Randall
f326964824 cmd/compile: use method expression closures to implement bound method calls
When we have x.M(args) where x is a value of type parameter type, we
currently cast x to the bound of that type parameter (which is an interface)
and then invoke the method on that interface. That's pretty inefficient
because:
 1) We need to convert x to an interface, which often requires allocation.
    With CL 378178 it is at least stack allocation, but allocation nontheless.
 2) We need to call through wrapper functions to unpack the interface
    into the right argument locations for the callee.

Instead, let's just call the target directly. The previous CL to this one
added method expression closures to the dictionary, which is a simple
captureless closure that implements T.M for type parameter T and method M.
So to implement x.M(args) for x of type T, we use methodexpr(T,M)(x, args).
We just need to move x from the receiver slot to the first argument, and
use the dictionary entry to implement the polymorphism. This works because
we stencil by shape, so we know how to marshal x for the call even though
we don't know its exact type.

We should be able to revert CL 378178 after this one, as that optimization
will no longer be necssary as we're not converting values to interfaces
to implement this language construct anymore.

Update #50182

Change-Id: I813de4510e41ab63626e58bd1167f9ae93016202
Reviewed-on: https://go-review.googlesource.com/c/go/+/385274
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-26 20:36:29 +00:00
Keith Randall
7fc38802e1 cmd/compile: implement generic method expressions with closures in dictionary
Currently we do quite a dance for method expressions on generic
types. We write a new closure, and in that closure convert the
receiver to an interface with the required method, then call the
target using an interface call.

Instead in this CL, we just allocate a (captureless) closure in the
dictionary which implements that method expression.

This CL makes method expressions faster and simpler. But the real win
is some followon CLs, where we can use the same closure to implement
bound method calls using the same closure, instead of converting to
interface and having wrappers convert back. Much faster and simpler.

Still thinking about how to do method values. The receiver still
needs to be captured, so there must be some closure involved, I think.

Update #50182

Change-Id: I1fbd57e7105663f8b049955b8f4111649a5f4aa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/385254
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-26 20:36:23 +00:00
Meng Zhuo
0652274c10 internal/abi: define riscv64 register ABI constants
Add the riscv64 register ABI constants and allow regabi
value to be set for riscv64

Change-Id: I3ce98bf9a29d2acc00f92650b27bc59884ed62ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/359336
Trust: mzh <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-26 01:27:54 +00:00
Wayne Zuo
80a7504a13 cmd/compile: enable inlining SELECT
Change-Id: I90c8e12a0be05d82bf6e147b5249859518f35c14
Reviewed-on: https://go-review.googlesource.com/c/go/+/394074
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Keith Randall <khr@golang.org>
2022-03-25 22:34:45 +00:00
Matthew Dempsky
3dac99ad4c cmd/compile: simplify fingerprint logic
Historically, we sometimes recorded imports based on either package
path ("net/http") or object file path ("net/http.a"). But modern Go
build systems always use package path, and the extra ".a" suffix
doesn't mean anything anyway.

Change-Id: I6060ef8bafa324168710d152a353f4d8db062133
Reviewed-on: https://go-review.googlesource.com/c/go/+/395254
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-03-25 21:58:03 +00:00
Adam Pritchard
3dac914b77 net/netip: fix uses of "IPv4-mapped IPv6" in doc comments
The correct (or at least mostly commonly used) name for addresses of the
form ::ffff:192.0.2.128 is "IPv4-mapped IPv6". Some of the comments in
the netip package used that name, but others used "IPv6-mapped IPv4" or
"v6-mapped". This change makes the usage of the term consistent.

Change-Id: Ic01309ddf9252705a2387322d940b777e88800a5
GitHub-Last-Rev: 56044dcb97
GitHub-Pull-Request: golang/go#51950
Reviewed-on: https://go-review.googlesource.com/c/go/+/395914
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
2022-03-25 20:23:27 +00:00
Russ Cox
2bbf383774 net/mail: improve detection of charset errors
The detection of the "unknown charset" case was too tailored
to one specific address parser. Make it generalize, so that custom
address parsers behave the same way as the default one
for character sets they do not handle.

Fixes #41625.

Change-Id: I347d4bb6844d0a1f23e908b776d21e8be5af3874
Reviewed-on: https://go-review.googlesource.com/c/go/+/283632
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-25 19:04:59 +00:00
Cuong Manh Le
f25631b490 cmd/compile/internal/ir: remove NewClosureExpr
The only usage of NewClosureExpr is inside NewClosureFunc, which is its
alternative version. So just remove NewClosureExpr and inline it there.

Change-Id: I1900f4fbb48d7b4f6e6a857f7f7760cd27302671
Reviewed-on: https://go-review.googlesource.com/c/go/+/395855
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-03-25 18:19:09 +00:00
Maisem Ali
1d19cea740 net/http/httptest: fix race in Server.Close
When run with race detector the test fails without the fix.

Fixes #51799

Change-Id: I273adb6d3a2b1e0d606b9c27ab4c6a9aa4aa8064
GitHub-Last-Rev: a5ddd146a2
GitHub-Pull-Request: golang/go#51805
Reviewed-on: https://go-review.googlesource.com/c/go/+/393974
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2022-03-25 16:08:06 +00:00
Cuong Manh Le
3fd8b8627f cmd/compile: handle sole component for 1-byte type interface conversion
For 1-byte type, we have a special case for converting to interface
type. But we missed an optimization for sole component-ed types, this CL
add that one.

goos: linux
goarch: amd64
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Benchmark_BoolField-8    	1000000000	         0.6473 ns/op
Benchmark_ByteField-8    	1000000000	         0.6094 ns/op
Benchmark_Uint8Field-8   	1000000000	         0.6385 ns/op
Benchmark_Int16Field-8   	785179434	         1.481 ns/op
Benchmark_Int32Field-8   	796127782	         1.539 ns/op
Benchmark_Int64Field-8   	718815478	         1.657 ns/op

Fixes #49879

Change-Id: Idc0e9d3ff738c8c8081b8e8d65093dacf2bcf392
Reviewed-on: https://go-review.googlesource.com/c/go/+/367755
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-25 15:15:57 +00:00
fanzha02
8ab42a945a cmd/compile: merge ANDconst and UBFX into UBFX on arm64
Add a new rewrite rule to merge ANDconst and UBFX into
UBFX.

Add test cases.

Change-Id: I24d6442d0c956d7ce092c3a3858d4a3a41771670
Reviewed-on: https://go-review.googlesource.com/c/go/+/377054
Trust: Fannie Zhang <Fannie.Zhang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-25 01:24:44 +00:00
Damien Neil
a10a209b23 net/http/httputil: ignore CloseNotify when a non-background context is present
If the http.Request passed to ReverseProxy.ServeHTTP has a context
with a non-nil Done channel, don't watch the ResponseWriter's
CloseNotify channel.

Avoids starting an extra background goroutine in the common case.

Change-Id: I1328f3e02d3025caa0f446a2f20dfc14ef604c64
Reviewed-on: https://go-review.googlesource.com/c/go/+/376415
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Damien Neil <dneil@google.com>
2022-03-24 21:51:49 +00:00
Robert Findley
b88600f926 go/types, types2: clean up a few typos, and an unused const
Change-Id: I01717cc52c9728b4eaaf2c996707f59a113bff9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/395434
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2022-03-24 21:50:14 +00:00
Matthew Dempsky
b95d332c7e test: compile source files as if from "test" module
This CL updates test/run.go to compile xxx.dir/x.go with a package
path of "test/x" instead of just "x". This prevents collisions with
standard library packages.

It also requires updating a handful of tests to account for the
updated package paths.

Fixes #25693.

Change-Id: I49208c56ab3cb229ed667d547cd6e004d2175fcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/395258
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-24 17:50:47 +00:00
Romanos Skiadas
b2643c6739 runtime: update framepointer_enabled doc
Change-Id: I69e64ebf8c11145ce32aa4c11178e3a47d22fb84
Reviewed-on: https://go-review.googlesource.com/c/go/+/394915
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
2022-03-24 15:51:28 +00:00
Cherry Mui
cccfb8ffdb cmd/link: do not add label symbols for DWARF on Windows/ARM64
Label symbols are only useful for relocations from text. No need
to do it for DWARF. And the PE symbol table doesn't like them.

May fix #51903.

Change-Id: Ibe6ea880d8533ba1dcc017030072c7dffee0e9e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/395215
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2022-03-24 14:44:47 +00:00
Daniel Martí
0ed31eb73b cmd/gofmt: return a proper error for empty Go files
I was testing edge cases in gofumpt, a fork of gofmt,
and noticed that gofmt will return a bare io error on empty files,
as demonstrated by the added test case without a fix:

        > ! exec $GOROOT/bin/gofmt empty.go nopackage.go
        [stderr]
        EOF
        nopackage.go:1:1: expected 'package', found not

The problem is the code that detects concurrent modifications.
It relies on ReadFull and correctly deals with io.ErrUnexpectedEOF,
but it did not pay attention to io.EOF, which can happen when size==0.

Change-Id: I6092391721edad4584fb5922d3e3a8fb3da86493
Reviewed-on: https://go-review.googlesource.com/c/go/+/393757
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Trust: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-24 09:17:34 +00:00
Robert Griesemer
9058080319 cmd/compile: clarify help message for -L flag
The file names reported in error messages by the compiler are
printed unchanged from the file names provided to the compiler;
the -L flag has no impact on the file names themselves, contrary
to what the old flag description suggested.

If an error is reported on a line that is affected by a //line
directive, an error message reports the file name and line as
controlled by the directive (i.e., the actual source position
is not known).

If the -L flag is provided, the actual source position is also
reported in square brackets.

This change documents this with an updated help string for the
flag.

For #36988.

Change-Id: I39ee35e6ff6cd5cfa44d87dabb05b8d78575d631
Reviewed-on: https://go-review.googlesource.com/c/go/+/395115
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-03-24 03:55:46 +00:00
Cuong Manh Le
209521c3e3 cmd/compile: refactor walkIndexMap
So all runtime map functions will use the same code path, make it easier
for future CL to handle stack object for map key.

Passes toolstash -cmp.

For #43753

Change-Id: I374fa4e351c1eba079e2ccb637b1ef5adad1488f
Reviewed-on: https://go-review.googlesource.com/c/go/+/321713
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-24 03:04:13 +00:00
Matthew Dempsky
60be4ec096 test: remove unused oldescape_linkname.dir directory
CL 187617 removed oldescape_linkname.go, but forgot to remove this
directory too.

Change-Id: I6d208c4d96d636b3df93adec1ee22fe1d4f5f61d
Reviewed-on: https://go-review.googlesource.com/c/go/+/395259
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-24 02:16:28 +00:00
Matthew Dempsky
d14c02a20c test: remove obsolete test case that misuses -p
bug302 compiles p.go with -p=p, and then manually creates a pp.a
archive, and imports it as both "p" and "pp". This is a misuse of
cmd/compile's -p flag, and it isn't representative of how any actual
Go build systems work anyway.

This test made sense back when cmd/compile still wrote out bare object
files, which was then split into separate __.PKGDEF and _go_.o archive
entries when added to a pack archive. But since CL 102236, cmd/compile
always writes out pack files.

Updates #51734.

Change-Id: I4b5de22d348ecc0a72c98b512351c2d267c77736
Reviewed-on: https://go-review.googlesource.com/c/go/+/393896
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-24 02:15:49 +00:00
Matthew Dempsky
999589e148 test: use dot-relative imports where appropriate
Currently, run.go's *dir tests allow "x.go" to be imported
interchangeably as either "x" or "./x". This is generally fine, but
can cause problems when "x" is the name of a standard library
package (e.g., "fixedbugs/bug345.dir/io.go").

This CL is an automated rewrite to change all `import "x"` directives
to use `import "./x"` instead. It has no effect today, but will allow
subsequent CLs to update test/run.go to resolve "./x" to "test/x" to
avoid stdlib collisions.

Change-Id: Ic76cd7140e83b47e764f8a499e59936be2b3c876
Reviewed-on: https://go-review.googlesource.com/c/go/+/395116
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-24 02:14:15 +00:00
Meng Zhuo
849e42f028 cmd/compile: update riscv64 CALL* ops
This CL allow the CALL ops to take variable number of arguments.

Change-Id: If84bb306c2f23a0a934e31dfeabbca7bed0c1796
Reviewed-on: https://go-review.googlesource.com/c/go/+/360216
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-03-24 01:26:58 +00:00
Cuong Manh Le
947bf333fc cmd/compile/internal/types: simplify AllowsGoVersion
After CL 394556, only LocalPkg is passed to AllowsGoVersion, so simplify
the code to not depend on Pkg anymore.

Change-Id: I8f9bfd4090100eec60cf3959c0d8fa92a26fc32a
Reviewed-on: https://go-review.googlesource.com/c/go/+/394954
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-03-23 19:31:59 +00:00
Cuong Manh Le
0eb2c77124 cmd/compile: remove types.Field.{Broken,SetBroken}
SetBroken is never called and Broken always returns false.

Updates #51691

Change-Id: I7e3fd3f2121268596d2e93a28c69e895bcf802ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/394558
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-23 19:31:50 +00:00
Cuong Manh Le
2792a414c6 cmd/compile/internal/types: remove anyBroke
anyBroke now always return false, we can get rid of it.

Updates #51691

Change-Id: Idab5bc9f9f222cc63e50bdde2b23b9404a4bd74e
Reviewed-on: https://go-review.googlesource.com/c/go/+/394557
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-23 19:31:43 +00:00
Cuong Manh Le
810868c9f6 cmd/compile: remove AllowsGoVersion checks in old typechecker
types2 handles those checks instead.

The only exception is noder.checkEmbed, since when types2
have not known about "//go:embed" pragma yet.

Updates #51691

Change-Id: I74ded03536023fe838f23fa7421e04513f904f66
Reviewed-on: https://go-review.googlesource.com/c/go/+/394556
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-03-23 19:31:36 +00:00
Cuong Manh Le
489e4882ef cmd/compile: remove typecheck.FuncBody
CL 388535 removed the only usage of this function.

Change-Id: Ie5a61cce75b03d83162f62989fe52388b069c9bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/394576
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-23 19:31:29 +00:00
Cuong Manh Le
c10fb50894 cmd/compile: remove ir.Node.SetDiag
And use base.Fatalf in code that use n.SetDiag(true) instead.

Updates #51691

Change-Id: Ib3c0b9c89b8d95717391cbe7d424240e288ada1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/394575
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-23 19:31:19 +00:00
Cuong Manh Le
515135f4c3 cmd/compile: remove types.Type.SetBroken
And use base.Fatalf in code that use t.SetBroke(true) instead.

Updates #51691

Change-Id: I9f3613379dd82d0dd069cdf7b61cbb281810e2e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/394574
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-23 19:31:11 +00:00
Cuong Manh Le
7e0a1d340f cmd/compile: remove reportTypeLoop
reportTypeLoop used to be used to report invalid recursive types in old
typechecker.

However, types2 now reports this error, so this can be removed.

Updates #51691

Change-Id: I5e73369dadafb0cc56e682668b32cbd1e1210f2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/394554
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-23 19:31:03 +00:00
Robert Griesemer
f9747b7f73 go/types, types2: report struct type for literals with too few/many elements
This change essentially matches the 1.17 compiler error message for
this error.

Fixes #51877.

Change-Id: I24ec2f9cc93d8cd2283d097332a39bc1a0eed3a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/394914
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-03-23 18:22:52 +00:00
Cherry Mui
dd211cf039 debug/gosym: skip non-real functions in LineToPC lookup
The code iterates through the func table to find a function with
a given file and line number. The code panics if it sees a non-
real function (e.g. go.buildid), because its CU offset is -1,
which causes an index-out-of-bounds error. The debug/gosym package
recovers the panic and returns "not found", without looping
through the rest of the entries.

Skip the non-real functions. They cannot be looked up by line
number anyway.

Fixes #51890.

Change-Id: I96f64c17b4a53ffdce047c8244b35a402a0d39ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/395074
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2022-03-23 17:12:00 +00:00
Cherry Mui
909a7a3213 cmd/compile: don't mark non-generic defined type symbol dupok
For a non-generic defined type, we generate its type descriptor
symbol only in the defining package. So there is no duplicate and
it doesn't need to be dupok.

For unnamed types and instantiated types, the type descriptor can
be generated in multiple packages and so still need to be dupok.

Change-Id: I92ed68c998ad68c5917b77b1dfd62eac4ced6bcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/394636
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-03-23 16:12:07 +00:00
Cherry Mui
20ba3f5de5 cmd/compile: default to -p=main for main package
With the previous CL the compiler emits an unlinkable object if
the -p flag is not specified. It is actually okay (and convenient)
to omit the -p flag for (just) the main package. This CL makes it
so.

Change-Id: I978d54d14c45b3bb9ed7471e40a2c47f269b56f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/394834
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-03-23 14:57:56 +00:00
Robert Griesemer
1e34c00b4c go/types, types2: remove uses of "type list" and "operational type" (cleanup)
Fixes #49193.

Change-Id: Ief31ea6b3dddf9452efb94763c89b8639aa3ce9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/394656
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-22 23:20:56 +00:00
Robert Findley
fd1b5904ae cmd/compile/internal/importer: key tparams by Package instead of pkgname
The importer type param index used package name type parameter key,
causing type parameters to be reused/overwritten if two packages in the
import graph had the same combination of (name, declaration name, type
parameter name).

Fix this by instead using the *Package in the key.

Fixes #51836

Change-Id: I881ceaf3cf7c1ab4e0835962350feb552e79b233
Reviewed-on: https://go-review.googlesource.com/c/go/+/394219
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2022-03-22 21:38:10 +00:00