Commit Graph

8501 Commits

Author SHA1 Message Date
Matthew Dempsky d2eab5ff19 cmd/compile/internal/ir: remove OrigNode
The OrigNode functionality used to be relevant to the typecheck
frontend, because we wanted to report errors using the same syntax as
the user originally wrote. However, now that types2 handles all
spec-required error diagnostics, there's no need to preserve original
nodes anymore.

Change-Id: I64a0540b8952513913021e7b84d165beb1f9f801
Reviewed-on: https://go-review.googlesource.com/c/go/+/526397
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-08 18:56:07 +00:00
Matthew Dempsky 0a49d4a778 cmd/compile/internal/ir: simplify formatting of CompLitExpr
Composite literals always have a type now, so the extra fallback code
isn't necessary. But also, to prepare for the upcoming removal of
OrigNode, we need to print OSLICELIT with Implicit set as
"... argument" to satisfy existing regress tests.

Change-Id: I365e879066903eebf1b78e10c1b505565cea3ce3
Reviewed-on: https://go-review.googlesource.com/c/go/+/526396
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2023-09-08 18:54:34 +00:00
Matthew Dempsky 7f1f4a1936 cmd/internal/ir: remove ConstExpr in favor of BasicLit
OrigNode will be going away soon, which is the only reason for
ConstExpr to exist. Otherwise, it's identical to BasicLit.

To keep existing code working, change NewConstExpr to construct and
return a BasicLit instead.

Change-Id: I68b43ec1fcaa57e6723f289ce9f953996aeefb14
Reviewed-on: https://go-review.googlesource.com/c/go/+/526395
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-09-08 18:51:02 +00:00
Matthew Dempsky 18c6ec1e4a cmd/compile/internal/noder: stop preserving original const strings
One of the more tedious quirks of the original frontend (i.e.,
typecheck) to preserve was that it preserved the original
representation of constants into the backend. To fit into the unified
IR model, I ended up implementing a fairly heavyweight workaround:
simply record the original constant's string expression in the export
data, so that diagnostics could still report it back, and match the
old test expectations.

But now that there's just a single frontend to support, it's easy
enough to just update the test expectations and drop this support for
"raw" constant expressions.

Change-Id: I1d859c5109d679879d937a2b213e777fbddf4f2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/526376
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-09-08 18:50:24 +00:00
Jes Cok ac2ec69e19 all: use io.{SeekStart, SeekCurrent, SeekEnd}
Currently we include these symbols in bootstrap code.

Change-Id: I19b504237b0344f0e87cda0fbe651811c72daba1
GitHub-Last-Rev: 5134baec38
GitHub-Pull-Request: golang/go#62368
Reviewed-on: https://go-review.googlesource.com/c/go/+/524258
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-09-07 19:06:17 +00:00
Keith Randall fb5bdb4cc9 cmd/compile: absorb InvertFlags into Noov comparisons
Unfortunately, there isn't a single op that provides the resulting
computation.
At least, I couldn't find one.

Fixes #62469

Change-Id: I236f3965b827aaeb3d70ef9fe89be66b116494f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/526276
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2023-09-07 15:14:39 +00:00
Matthew Dempsky 0725410df5 cmd/compile/internal/inline/inlheur: remove ConstExpr assumption
OLITERAL isn't always ConstExpr. It can also be BasicLit or Name.

Change-Id: I44d595830f9e206eccf6fb37bd47ddf957db0866
Reviewed-on: https://go-review.googlesource.com/c/go/+/526277
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-09-07 15:10:40 +00:00
Matthew Dempsky ae09ca6c0f cmd/compile/internal/ir: simplify printing of OLITERALs
This formatting used to be relevant to user error diagnostics and
(much earlier) even to the old textual export data format, but now
it's only relevant to backend debugging. So we can simplify a lot,
adjusting a few test expectations accordingly.

Change-Id: Ibe8e029284ce6150bfa24ef794d8d9eff66dbdea
Reviewed-on: https://go-review.googlesource.com/c/go/+/526375
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-09-07 15:10:10 +00:00
thepudds fbaf71f36b cmd/compile/internal/dwarfgen: make scope test less sensitive to changes in escape analysis
The test function fi is used in TestEscape, and the intent of fi
seems to be to leak its argument, but fi is currently
sensitive to changes in escape analysis regarding interface receivers.

Make fi less sensitive by directly leaking its argument.

Change-Id: I16cc3d3a6bd7b08a08c8fc292b0b99c9a54d68d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/524943
Run-TryBot: t hepudds <thepudds1460@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-09-07 00:29:59 +00:00
Than McIntosh 3f0f76734e cmd/compile/internal/inline: analyze function result properties
Add code to analyze properties of function result values, specifically
heuristics for cases where we always return allocated memory, always
return the same constant, or always return the same function.

Updates #61502.

Change-Id: I8b0a3295b5be7f7ad4c2d5b9803925aea0639376
Reviewed-on: https://go-review.googlesource.com/c/go/+/511559
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-06 18:30:19 +00:00
Than McIntosh 3d62c76736 cmd/compile/internal/ir: add "never returns" func flag
Add a flag to ir.Func's flags field to record whether a given function
is deemed to never return (e.g. always calls exit or panic or
equivalent on all control paths). So as to not increase the amount of
flag storage, this new flag replaces the existing "ExportInline" flag,
which is currently unused.

Change-Id: Idd336e47381048cfc995eda05faf8b62f06ba206
Reviewed-on: https://go-review.googlesource.com/c/go/+/518256
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-06 18:29:16 +00:00
Than McIntosh e844d72421 cmd/compile/internal/inline: no-return flag analysis for inline heuristics
Add code to compute whether a given function appears to
unconditionally call panic or exit, as a means of driving inlining
decisions. Note that this determination is based on
heuristics/guesses, as opposed to strict safety analysis; in some
cases we may miss a function that does indeed always panic, or mark a
function as always invoking panic when it doesn't; the intent is get
the right answer in "most" cases.

Updates #61502.

Change-Id: Ibba3e60c06c2e54cf29b3ffa0f816518aaacb9a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/511558
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-06 17:43:02 +00:00
Paul E. Murphy 5cdb132228 cmd/compile/internal/ssa: improve masking codegen on PPC64
Generate RLDIC[LR] instead of MOVD mask, Rx; AND Rx, Ry, Rz.
This helps reduce code size, and reduces the latency caused
by the constant load.

Similarly, for smaller-than-register values, truncate constants
which exceed the range of the value's type to avoid needing to
load a constant.

Change-Id: I6019684795eb8962d4fd6d9585d08b17c15e7d64
Reviewed-on: https://go-review.googlesource.com/c/go/+/515576
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-09-06 16:34:20 +00:00
Dmitri Shuralyov 0dfb22ed70 all: use ^TestName$ regular pattern for invoking a single test
Use ^ and $ in the -run flag regular expression value when the intention
is to invoke a single named test. This removes the reliance on there not
being another similarly named test to achieve the intended result.

In particular, package syscall has tests named TestUnshareMountNameSpace
and TestUnshareMountNameSpaceChroot that both trigger themselves setting
GO_WANT_HELPER_PROCESS=1 to run alternate code in a helper process. As a
consequence of overlap in their test names, the former was inadvertently
triggering one too many helpers.

Spotted while reviewing CL 525196. Apply the same change in other places
to make it easier for code readers to see that said tests aren't running
extraneous tests. The unlikely cases of -run=TestSomething intentionally
being used to run all tests that have the TestSomething substring in the
name can be better written as -run=^.*TestSomething.*$ or with a comment
so it is clear it wasn't an oversight.

Change-Id: Iba208aba3998acdbf8c6708e5d23ab88938bfc1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/524948
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-05 23:35:29 +00:00
Egon Elbre a2647f08f0 compile/internal/walk: add walkGrowslice
Move growslice generation to a separate func so that specialization
logic can be shared.

Updates #49480

Change-Id: I9ea5bb898753622d2d767546a46b4db6410dc725
Reviewed-on: https://go-review.googlesource.com/c/go/+/495877
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
2023-09-05 15:06:41 +00:00
Egon Elbre 1d84b02b22 runtime: introduce nextslicecap
This allows to reuse the slice cap computation across
specialized growslice funcs.

Updates #49480

Change-Id: Ie075d9c3075659ea14c11d51a9cd4ed46aa0e961
Reviewed-on: https://go-review.googlesource.com/c/go/+/495876
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Egon Elbre <egonelbre@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2023-09-04 17:50:50 +00:00
Jes Cok 778f5fc079 cmd/compile/internal/ssa: fix typos in comments
Change-Id: Idb09d68ce1e4823c8a330430e082d5c7ac2d8fc5
GitHub-Last-Rev: 5a2b71b21e
GitHub-Pull-Request: golang/go#62441
Reviewed-on: https://go-review.googlesource.com/c/go/+/525415
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2023-09-04 17:23:05 +00:00
zhangjian 05d4b57c9f cmd/compile/internal/liveness: remove excess bits for stackmap
ArgWidth() already includes the stack space required for
input parameters and return values, so their offset will
not exceed the value of ArgWidth(), so there is no need
to double it.

Change-Id: I10fde7afbf2a5714b5142075c2116af14debc7e8
GitHub-Last-Rev: eaf3fd5eb8
GitHub-Pull-Request: golang/go#60591
Reviewed-on: https://go-review.googlesource.com/c/go/+/500675
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: guangyuan zhou <zhouguangyuan@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2023-09-03 15:46:21 +00:00
cui fliter 0cd473d97a cmd: fix some comments
Change-Id: I8b3eb51e31139314d222d796b56ab7d42338797f
Reviewed-on: https://go-review.googlesource.com/c/go/+/525315
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
2023-09-02 22:09:21 +00:00
Matthew Dempsky c9bb7ce2d7 cmd/internal/obj: simplify filename handling
The old Go object file format used linker symbols like "gofile..foo"
to record references to the filename "foo". But the current object
file format has a dedicated section for file names, so we don't need
these useless prefixes anymore.

Also, change DWARF generation to pass around the src.Pos directly,
rather than the old file symbols, which it just turned back into a
file index before writing out anyway.

Finally, directly record the FileIndex into src.PosBase, so that we
can skip the map lookups.

Change-Id: Ia4a5ebfa95da271f2522e45befdb9f137c16d373
Reviewed-on: https://go-review.googlesource.com/c/go/+/523378
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-09-01 15:52:41 +00:00
Guoqi Chen 06f420fc19 runtime: remove the meaningless offset of 8 for duffzero on loong64
Currently we subtract 8 from offset when calling duffzero because 8
is added to offset in the duffzero implementation. This operation is
meaningless, so remove it.

Change-Id: I7e451d04d7e98ccafe711645d81d3aadf376766f
Reviewed-on: https://go-review.googlesource.com/c/go/+/487295
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Run-TryBot: WANG Xuerui <git@xen0n.name>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2023-09-01 15:48:45 +00:00
Dominique Lefevre b4c889b561 cmd/internal/objabi: rename R_USEGENERICIFACEMETHOD to R_USENAMEDMETHOD.
Now we have two cases when we want to keep methods with a specific name:
calls to generic interface methods and MethodByName("Foo"). Both use
the same relocation type, so let us give it a name that is not limited
to the implementation of generic interfaces.

Also, introduce staticdata.StrSymNoCommon(). It creates a symbol that
does not appear in the final binary and only communicates arguments
to the linker.

Change-Id: Icc9f49febfde1f31a4455b5acb903e8838d1c0af
Reviewed-on: https://go-review.googlesource.com/c/go/+/523016
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-09-01 15:08:50 +00:00
Dominique Lefevre e802f211b0 cmd/compile: special-case MethodByName(string literal) to keep the DCE enabled.
Normally, a call to MethodByName() disables the DCE because the linker
assumes that any method can be accessed this way. This pessimises
the code generation for k8s.io/apimachinery which needs MethodByName()
to verify whether or not a struct implements DeepCopyInto(). It cannot
cast a struct to `interface { DeepCopyInto() Foo }` because the return
type may vary. Instead, it does the following:

  if m := reflect.ValueOf(obj).MethodByName("DeepCopyInto"); ... {

In this case there is no need to disable the DCE altogether. It
suffices to add a relocation to keep methods named DeepCopyInto().

Fixes #62257.

Change-Id: I583c2f04d8309a8807de75cd962c04151baeeb1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/522436
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-01 15:06:51 +00:00
Robert Griesemer 7a4787d12a go/types, types2: fix doc string
Change-Id: I9ab93c90d128d0abd0c84c7520f8c72983fee79b
Reviewed-on: https://go-review.googlesource.com/c/go/+/524975
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-31 23:57:29 +00:00
Jes Cok ffc4ccea07 cmd/compile/internal/types2: use strings.ReplaceAll for goTypeName
strings.ReplaceAll is currently available.

Change-Id: I111b97f12723c97791b59d81fd035a0d5e97cd4b
GitHub-Last-Rev: 561dbab6d2
GitHub-Pull-Request: golang/go#62369
Reviewed-on: https://go-review.googlesource.com/c/go/+/524157
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-08-31 21:14:38 +00:00
Robert Griesemer 2fa7129836 go/types, types2: use asNamed(t) instead of t.(*Named) type assertions
Preparation for the introduction of alias types.
Because asNamed is not exported, existing external
tests continue to use t.(*Named).

Change-Id: I4754b406dd6b23030d3703a486d6f6620b2464fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/522876
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-30 15:45:21 +00:00
Keith Randall 0e02baa59a Revert "cmd/compile: use shorter ANDL/TESTL if upper 32 bits are known to be zero"
This reverts commit c1dfbf72e1.

Reason for revert: TESTL rule is wrong when the result is used for an ordered comparison.

Fixes #62360

Change-Id: I4d5b6aca24389b0a2bf767bfbc0a9d085359eb38
Reviewed-on: https://go-review.googlesource.com/c/go/+/524255
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-08-30 15:15:28 +00:00
Robert Griesemer 1f8f2ab966 go/types, types2: remove order dependency in inference involving channels
In inexact unification, when a named type matches against an inferred
unnamed type, we change the previously inferred type to the named type.
This preserves the type name and assignability.

We have to do the same thing when encountering a directional channel:
a bidirectional channel can always be assigned to a directional channel
but not the other way around. Thus, if we see a directional channel, we
must choose the directional channel.

This CL extends the previously existing logic for named types to
directional channels and also makes the code conditional on inexact
unification. The latter is an optimization - if unification is exact,
type differences don't exist and updating an already inferred type has
no effect.

Fixes #62157.

Change-Id: I807e3b9f9ab363f9ed848bdb18b2577b1d680ea7
Reviewed-on: https://go-review.googlesource.com/c/go/+/521500
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-29 23:22:35 +00:00
Matthew Dempsky 22eba6a1f8 cmd/compile/internal/ir: remove old variable capture logic
This logic is no longer used, since the removal of the non-unified
frontends.

Change-Id: I7256d4eb06f0b4e5308bc7c7476e90af9e70b7d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/524215
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-08-29 21:43:42 +00:00
Matthew Dempsky 52a5881bee cmd/compile: remove vestigial importpath symbol logic
The object file format now has an explicit section for tracking which
packages were imported, so we don't need to write out importpath
symbols for all directly imported packages anymore.

However, keep the logic for writing out individual importpath symbols,
because it's still relevant to runtime type descriptor generation.

Change-Id: I184ff320e894ba43ca0f8a3d2678e4b2bbbe6da5
Reviewed-on: https://go-review.googlesource.com/c/go/+/523875
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-08-29 20:28:09 +00:00
Matthew Dempsky 08bf6d1405 cmd/compile/internal/ir: drop Inl.Body
We don't actually depend on Inl.Body anywhere, except it implicitly
serves to indicate whether Inl.Dcl has been populated. So replace it
with a boolean so we don't need to keep a useless copy of every
inlinable function body in memory.

While here, also add some Fatalfs to make sure there are no unused
local variables. The unified frontend now omits unreachable code
during export data writing, so there shouldn't be unused local
variables.

Also, since unified IR uses the same code/data to construct the
original function as inlined and/or imported functions, the Dcl list
should always be the same, which addresses the real root issue (i.e.,
that export/import could skew the Dcl lists).

Change-Id: I6e3435f3a0352f6efbae787344006efac1891e84
Reviewed-on: https://go-review.googlesource.com/c/go/+/523315
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-08-29 20:28:07 +00:00
Matthew Dempsky ad74bc4a92 cmd/internal/obj: add Func type to replace "curfn any"
This adds a modicum of type safety to these APIs, which are otherwise
quite confusing to follow.

Change-Id: I268a9a1a99a47dcfef6dc1e9e5be13673af3fb85
Reviewed-on: https://go-review.googlesource.com/c/go/+/523396
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-08-29 20:19:46 +00:00
Matthew Dempsky 98c26afa8c cmd/compile/internal/ssagen: stop canonicalizing symabis
cmd/asm writes canonicalized symabis now.

Change-Id: I65cc39ce1671a3c225f14003b336015f0cc33980
Reviewed-on: https://go-review.googlesource.com/c/go/+/523339
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-29 18:31:12 +00:00
Matthew Dempsky cf338eb890 cmd/compile: eliminate fallback code for missing -p flag
cmd/compile has required the -p flag since go.dev/cl/391014. It's safe
to eliminate the fallback code that tried to cope without.

Change-Id: I9a62ff829e34a6fa5bfe6ae6a836610cc3f0cd33
Reviewed-on: https://go-review.googlesource.com/c/go/+/523337
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-29 18:31:08 +00:00
Dominique Lefevre 07faf8fab5 cmd/compile: do not flag reflect.StructOf() as a ReflectMethod.
StructOf() calls reflect.Type.Method(), but looks up only methods
accessible via interfaces. DCE does not remove such methods, so
there is no need to disable the DCE if StructOf() is used.

There is a dependency chain between struct rtype and StructOf():

  (*rtype).Method() -> FuncOf() -> initFuncTypes() -> StructOf().

Thus, any use of (*rtype).Method() or (*rtype).MethodByName()
disables the DCE in the linker. This is not an issue just yet
because all users of Method() and MethodByName() are flagged
as ReflectMethods. A subsequent patch avoids this flag on callers
of MethodByName(string literal). When that patch is applied,
it becomes important to have no ReflectMethods down the call
chain of MethodByName().

Change-Id: I9b3e55c495c122ed70ef31f9d978c0e2e0573799
Reviewed-on: https://go-review.googlesource.com/c/go/+/522435
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2023-08-29 15:26:57 +00:00
Matthew Dempsky eaae2d45c7 cmd: simplify some handling of package paths
We have obj.Link.Pkgpath, so we don't need to pass it redundantly in
places where we already have an *obj.Link.

Also, renaming the parser's "compilingRuntime" field to "allowABI", to
match the "AllowAsmABI" name used by objabi.LookupPkgSpecial.

Finally, push the handling of GOEXPERIMENT_* flags up to cmd/asm's
main entry point, by simply appending them to flags.D.

Change-Id: I6ada134522b0cbc90d35bcb145fbe045338fefb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/523297
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-29 07:48:38 +00:00
shuang cui f7f1c4f86d Revert "cmd/compile/internal/liveness: remove repetitive word"
This reverts commit 50bd17205f.

Reason for revert: The first being the English word, the second being the name of the 3rd parameter.

Change-Id: Iabca436b93ecc5481874e1eac0a1768292447431
Reviewed-on: https://go-review.googlesource.com/c/go/+/523835
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: shuang cui <imcusg@gmail.com>
2023-08-29 06:42:53 +00:00
Jes Cok c5569f09f2 cmd/compile/internal/types2: use ReplaceAll in *Context.instanceHash
strings.ReplaceAll is currently available.

Change-Id: I5e03ed43be123f9091a4e3b6bf05ffae8fb0d59b
GitHub-Last-Rev: 2cccdd0305
GitHub-Pull-Request: golang/go#62307
Reviewed-on: https://go-review.googlesource.com/c/go/+/523298
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
2023-08-28 17:29:21 +00:00
cui fliter 50bd17205f cmd/compile/internal/liveness: remove repetitive word
Change-Id: I27789840d92cc2c1e799db5b58e1eb1570e264df
Reviewed-on: https://go-review.googlesource.com/c/go/+/523235
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Run-TryBot: shuang cui <imcusg@gmail.com>
2023-08-28 17:27:14 +00:00
Jakub Ciolek c1dfbf72e1 cmd/compile: use shorter ANDL/TESTL if upper 32 bits are known to be zero
compilecmp linux/amd64:

math/bits
math/bits.Div32 122 -> 121  (-0.82%)
math/bits.Rem32 39 -> 38  (-2.56%)

math/bits [cmd/compile]
math/bits.Rem32 39 -> 38  (-2.56%)
math/bits.Div32 122 -> 121  (-0.82%)

runtime
runtime.funcMaxSPDelta 296 -> 294  (-0.68%)
runtime.dumpGCProg 677 -> 666  (-1.62%)
runtime.(*itabTableType).find 66 -> 65  (-1.52%)
runtime.(*itabTableType).add 71 -> 70  (-1.41%)
runtime.funpack32 122 -> 121  (-0.82%)

vendor/golang.org/x/net/dns/dnsmessage
vendor/golang.org/x/net/dns/dnsmessage.(*Message).pack 211 -> 200  (-5.21%)
vendor/golang.org/x/net/dns/dnsmessage.(*Header).pack 163 -> 161  (-1.23%)
vendor/golang.org/x/net/dns/dnsmessage.NewBuilder 589 -> 581  (-1.36%)

runtime [cmd/compile]
runtime.dumpGCProg 677 -> 666  (-1.62%)
runtime.funpack32 122 -> 121  (-0.82%)
runtime.(*itabTableType).add 71 -> 70  (-1.41%)
runtime.(*itabTableType).find 66 -> 65  (-1.52%)

internal/types/errors
internal/types/errors.Code.String 666 -> 634  (-4.80%)

internal/types/errors [cmd/compile]
internal/types/errors.Code.String 666 -> 634  (-4.80%)

debug/gosym
debug/gosym.(*LineTable).stringFrom 436 -> 435  (-0.23%)

debug/dwarf
debug/dwarf.Class.String 186 -> 175  (-5.91%)

vendor/golang.org/x/text/unicode/norm
vendor/golang.org/x/text/unicode/norm.(*reorderBuffer).runeAt 181 -> 180  (-0.55%)
vendor/golang.org/x/text/unicode/norm.(*reorderBuffer).assignRune 222 -> 221  (-0.45%)

debug/macho
debug/macho.RelocTypeARM64.String 186 -> 175  (-5.91%)
debug/macho.RelocTypeGeneric.String 186 -> 175  (-5.91%)
debug/macho.RelocTypeX86_64.String 186 -> 175  (-5.91%)
debug/macho.RelocTypeARM.String 186 -> 175  (-5.91%)

internal/xcoff
internal/xcoff.getString 173 -> 172  (-0.58%)

debug/pe
debug/pe.StringTable.String 278 -> 277  (-0.36%)

math/big
math/big.(*Int).Int64 35 -> 34  (-2.86%)
math/big.(*Float).ord 57 -> 56  (-1.75%)
math/big.Accuracy.String 219 -> 217  (-0.91%)
math/big.(*Int).Cmp 153 -> 152  (-0.65%)

go/constant
go/constant.makeInt 155 -> 154  (-0.65%)

archive/tar
archive/tar.(*Reader).readHeader.func2 51 -> 50  (-1.96%)

crypto/rsa
crypto/rsa.VerifyPKCS1v15 1288 -> 1285  (-0.23%)
crypto/rsa.decryptPKCS1v15 495 -> 493  (-0.40%)

vendor/golang.org/x/net/idna
vendor/golang.org/x/net/idna.(*Profile).simplify 114 -> 113  (-0.88%)
vendor/golang.org/x/net/idna.validateFromPunycode 607 -> 591  (-2.64%)

encoding/asn1
encoding/asn1.parseBitString 298 -> 297  (-0.34%)

log/slog
log/slog.TextHandler.attrSep 57 -> 56  (-1.75%)
log/slog.(*handleState).appendKey 747 -> 746  (-0.13%)
log/slog.JSONHandler.attrSep 57 -> 56  (-1.75%)
log/slog.(*TextHandler).attrSep 59 -> 58  (-1.69%)
log/slog.(*JSONHandler).attrSep 59 -> 58  (-1.69%)

cmd/internal/objabi
cmd/internal/objabi.SymKind.String 219 -> 207  (-5.48%)

vendor/golang.org/x/crypto/cryptobyte
vendor/golang.org/x/crypto/cryptobyte.(*String).readLengthPrefixed 315 -> 313  (-0.63%)

cmd/internal/goobj
cmd/internal/goobj.(*FuncInfo).ReadInlTree 216 -> 215  (-0.46%)
cmd/internal/goobj.(*Reader).BytesAt 96 -> 95  (-1.04%)

html/template
html/template.state.String 219 -> 207  (-5.48%)

cmd/internal/obj
cmd/internal/obj.AddrType.String 219 -> 207  (-5.48%)

go/build
go/build.(*Context).importGo 4511 -> 4505  (-0.13%)

cmd/internal/gcprog
cmd/internal/gcprog.progbits 569 -> 549  (-3.51%)

cmd/compile/internal/base
cmd/compile/internal/base.PkgLinksym 373 -> 367  (-1.61%)

cmd/cgo
main.(*Package).writeDefsFunc 6117 -> 6085  (-0.52%)

cmd/compile/internal/types
cmd/compile/internal/types.Kind.String 219 -> 207  (-5.48%)
cmd/compile/internal/types.AlgKind.String 207 -> 201  (-2.90%)

cmd/internal/gcprog [cmd/compile]
cmd/internal/gcprog.progbits 569 -> 549  (-3.51%)

crypto/tls
crypto/tls.CurveID.String 273 -> 265  (-2.93%)

cmd/internal/objabi [cmd/compile]
cmd/internal/objabi.SymKind.String 219 -> 207  (-5.48%)

cmd/internal/goobj [cmd/compile]
cmd/internal/goobj.(*FuncInfo).ReadInlTree 216 -> 215  (-0.46%)
cmd/internal/goobj.(*Reader).BytesAt 96 -> 95  (-1.04%)

math/big [cmd/compile]
math/big.(*Float).ord 57 -> 56  (-1.75%)
math/big.(*Int).Cmp 153 -> 152  (-0.65%)
math/big.(*Int).Int64 35 -> 34  (-2.86%)
math/big.Accuracy.String 219 -> 217  (-0.91%)

go/constant [cmd/compile]
go/constant.makeInt 155 -> 154  (-0.65%)

cmd/internal/obj [cmd/compile]
cmd/internal/obj.AddrType.String 219 -> 207  (-5.48%)

cmd/link/internal/sym
cmd/link/internal/sym.SymKind.String 219 -> 207  (-5.48%)

cmd/compile/internal/base [cmd/compile]
cmd/compile/internal/base.PkgLinksym 317 -> 315  (-0.63%)

go/build [cmd/compile]
go/build.(*Context).importGo 4511 -> 4505  (-0.13%)

cmd/go/internal/script
cmd/go/internal/script.(*Engine).ListCmds 1269 -> 1263  (-0.47%)

cmd/go/internal/modindex
cmd/go/internal/modindex.fromBytes 1206 -> 1199  (-0.58%)
cmd/go/internal/modindex.(*decoder).boolAt 212 -> 201  (-5.19%)
cmd/go/internal/modindex.(*reader).bool 229 -> 218  (-4.80%)

cmd/link/internal/loader
cmd/link/internal/loader.(*FuncInfo).File 142 -> 141  (-0.70%)

cmd/compile/internal/types [cmd/compile]
cmd/compile/internal/types.Kind.String 219 -> 207  (-5.48%)
cmd/compile/internal/types.(*Sym).LinksymABI 333 -> 332  (-0.30%)
cmd/compile/internal/types.AlgKind.String 207 -> 201  (-2.90%)

cmd/link/internal/loadmacho
cmd/link/internal/loadmacho.macholoadsym 1243 -> 1236  (-0.56%)

cmd/vendor/golang.org/x/sys/unix
cmd/vendor/golang.org/x/sys/unix.(*FileHandle).Bytes 80 -> 79  (-1.25%)
cmd/vendor/golang.org/x/sys/unix.Mkdev 54 -> 52  (-3.70%)

cmd/go/internal/work
cmd/go/internal/work.(*Builder).printLinkerConfig 1865 -> 1864  (-0.05%)

cmd/go/internal/run
cmd/go/internal/run.runRun 3197 -> 3182  (-0.47%)

cmd/compile/internal/ssa [cmd/compile]
cmd/compile/internal/ssa.rewriteValueAMD64 21221 -> 19514  (-8.04%)

file                                       before   after    Δ       %
math/bits.s                                2373     2371     -2      -0.084%
math/bits [cmd/compile].s                  2373     2371     -2      -0.084%
runtime.s                                  520472   520467   -5      -0.001%
vendor/golang.org/x/net/dns/dnsmessage.s   74378    74357    -21     -0.028%
runtime [cmd/compile].s                    582206   582203   -3      -0.001%
internal/types/errors.s                    750      718      -32     -4.267%
internal/types/errors [cmd/compile].s      750      718      -32     -4.267%
debug/gosym.s                              34742    34741    -1      -0.003%
debug/dwarf.s                              113249   113238   -11     -0.010%
vendor/golang.org/x/text/unicode/norm.s    62802    62800    -2      -0.003%
debug/macho.s                              29021    28977    -44     -0.152%
internal/xcoff.s                           17911    17910    -1      -0.006%
debug/pe.s                                 23421    23420    -1      -0.004%
math/big.s                                 163522   163517   -5      -0.003%
go/constant.s                              28512    28511    -1      -0.004%
archive/tar.s                              58377    58376    -1      -0.002%
crypto/rsa.s                               26261    26256    -5      -0.019%
vendor/golang.org/x/net/idna.s             21342    21325    -17     -0.080%
encoding/asn1.s                            45357    45356    -1      -0.002%
log/slog.s                                 78618    78613    -5      -0.006%
cmd/internal/objabi.s                      15878    15866    -12     -0.076%
vendor/golang.org/x/crypto/cryptobyte.s    30577    30575    -2      -0.007%
cmd/internal/goobj.s                       11515    11513    -2      -0.017%
html/template.s                            87816    87804    -12     -0.014%
cmd/internal/obj.s                         124786   124774   -12     -0.010%
go/build.s                                 67665    67659    -6      -0.009%
cmd/internal/gcprog.s                      5856     5836     -20     -0.342%
cmd/compile/internal/base.s                41802    41796    -6      -0.014%
cmd/internal/obj/arm64.s                   144141   144172   +31     +0.022%
cmd/cgo.s                                  197681   197649   -32     -0.016%
cmd/compile/internal/types.s               62811    62793    -18     -0.029%
cmd/internal/gcprog [cmd/compile].s        5856     5836     -20     -0.342%
crypto/tls.s                               318862   318854   -8      -0.003%
cmd/internal/objabi [cmd/compile].s        15887    15875    -12     -0.076%
cmd/internal/goobj [cmd/compile].s         11596    11594    -2      -0.017%
math/big [cmd/compile].s                   165178   165173   -5      -0.003%
go/constant [cmd/compile].s                29743    29742    -1      -0.003%
cmd/internal/obj [cmd/compile].s           165646   165634   -12     -0.007%
cmd/link/internal/sym.s                    1829     1817     -12     -0.656%
cmd/compile/internal/base [cmd/compile].s  41937    41935    -2      -0.005%
go/build [cmd/compile].s                   67601    67595    -6      -0.009%
cmd/go/internal/script.s                   79959    79953    -6      -0.008%
cmd/go/internal/modindex.s                 85936    85907    -29     -0.034%
cmd/internal/obj/arm64 [cmd/compile].s     144090   144121   +31     +0.022%
cmd/link/internal/loader.s                 77864    77863    -1      -0.001%
cmd/compile/internal/types [cmd/compile].s 76072    76053    -19     -0.025%
cmd/link/internal/loadmacho.s              20367    20360    -7      -0.034%
cmd/vendor/golang.org/x/sys/unix.s         118027   118024   -3      -0.003%
cmd/go/internal/work.s                     285265   285264   -1      -0.000%
cmd/go/internal/run.s                      4758     4743     -15     -0.315%
cmd/compile/internal/ssa.s                 3191919  3192241  +322    +0.010%
cmd/compile/internal/ssa [cmd/compile].s   3362994  3361609  -1385   -0.041%
total                                      30756856 30755380 -1476   -0.005%

Change-Id: Ia259c87216af6ff67efe33c7d39f3dbde7f37a43
Reviewed-on: https://go-review.googlesource.com/c/go/+/522975
Auto-Submit: Keith Randall <khr@golang.org>
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
2023-08-28 17:25:18 +00:00
Jes Cok 7e7dd4dcd9 cmd/compile/internal/ir: remove redundant not in doc
Change-Id: Ia4fc2ceafa92f38742d3a017e37350875fdcc25e
GitHub-Last-Rev: 482f5e4fe6
GitHub-Pull-Request: golang/go#62299
Reviewed-on: https://go-review.googlesource.com/c/go/+/522940
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-08-28 15:21:02 +00:00
Matthew Dempsky 4f97a7e6ea cmd/compile/internal/ir: set Addrtaken on Canonical ONAME too
In CL 522879, I moved the logic for setting Addrtaken from typecheck's
markAddrOf and ComputeAddrtaken directly into ir.NewAddrExpr. However,
I took the logic from markAddrOf, and failed to notice that
ComputeAddrtaken also set Addrtaken on the canonical ONAME.

The result is that if the only address-of expressions were within a
function literal, the canonical variable never got marked Addrtaken.
In turn, this could cause the consistency check in ir.Reassigned to
fail. (Yay for consistency checks turning mistakes into ICEs, rather
than miscompilation.)

Fixes #62313.

Change-Id: Ieab2854cd7fcc1b6c5d1e61de66453add9890a4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/523375
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-28 14:32:14 +00:00
Cuong Manh Le 079c0441d5 cmd/compile: un-hide closure func in init function
Same as CL 492135, but for init function.

Fixes #62277

Change-Id: If5ff9bc2ce2a73193b1f7ee5f7f14045d1354f56
Reviewed-on: https://go-review.googlesource.com/c/go/+/522956
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-08-26 01:54:41 +00:00
Matthew Dempsky 611c3af30d cmd/compile/internal/ir: mark Addrtaken in NewAddrExpr
This CL changes NewAddrExpr to require its operand to always be
typechecked, so it can return an appropriately typechecked node and
mark Addrtaken as appropriate in the process.

Change-Id: I97c1f29305a9abfda35c42a43561c4c15fb5b52e
Reviewed-on: https://go-review.googlesource.com/c/go/+/522879
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2023-08-25 16:41:59 +00:00
Matthew Dempsky b036d7e17f cmd/compile/internal/noder: avoid ir.Node temps in FixValue
Instead of constructing an untyped basic literal IR node, having
typecheck convert it and return a new one, only to extract the
constant.Value; just have typecheck export the underlying value
conversion function, so we can call it directly.

Change-Id: Ie98f5362b3926a728d80262b0274a0b4fd023eaf
Reviewed-on: https://go-review.googlesource.com/c/go/+/522878
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2023-08-25 16:39:04 +00:00
Matthew Dempsky 99ea5b9765 cmd/compile: remove ErrorfVers and base.Flag.Lang hack
ErrorfVers used to be used by typecheck to report when new language
functionality was used, but the -lang flag (from go.mod) was set to an
older version. However, all of the callers have been since removed,
now that this is handled by types2.

And for the same reason, we can stop changing base.Flag.Lang. This was
previously a workaround so that the unified frontend could generate
arbitrary IR without upsetting typecheck, at a time when typecheck was
itself a real frontend. Now it's just a glorified desugaring pass.

Change-Id: I1c0316dbfe2e08ba089acd50fdfe20b17176be25
Reviewed-on: https://go-review.googlesource.com/c/go/+/522877
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-25 16:38:07 +00:00
Matthew Dempsky 88cb17e106 cmd/compile: create "init" function during noding
This CL arranges for package-scope initialization statements to be
constructed directly into their eventual "init" function, so we can
eliminate the roundabout solution of using InitTodoFunc.

While here, somewhat simplify and generalize the logic for outlining
map initialization statements.

Change-Id: I8aff042e6b266f7024de436424ec6711b8b69129
Reviewed-on: https://go-review.googlesource.com/c/go/+/522318
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-24 23:19:42 +00:00
Matthew Dempsky cf68384674 cmd/compile/internal/gc: steps towards work-queue
[This is a reattempt of go.dev/cl/520611.]

This CL reorganizes the top-level functions for handling package-level
declarations, runtime type descriptors, and SSA compilation to work in
a loop. This generalizes the loop that previously existed in dumpdata.

Change-Id: I7502798a8662b3cec92d3001169f3af4f804df2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/522339
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-24 23:18:16 +00:00
Tobias Klauser 96b6e78ea9 cmd/compile/internal/syntax: use strings.LastIndexByte in trailingDigits
Previously, strings.LastIndexByte couldn't be used because it was only
added in Go 1.5 but Go 1.4 was required for bootstrapping. In Go 1.18,
the bootstrap toolchain was bumped to Go 1.17 (see #44505), thus
strings.LastIndexByte can be used now.

Change-Id: I01a70a59dbfc853cf03d49747a2dd62d21ba74e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/522197
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2023-08-24 20:39:18 +00:00
Matthew Dempsky d5c5808534 cmd/compile/internal/syntax: add Unparen and UnpackListExpr helpers
We've added Unparen to go/ast, so add syntax.Unparen to be
consistent (and because it's similarly useful).

Also, types2 and noder both have similar functions for unpacking
ListExprs, so might as well add a common implementation in package
syntax too.

Finally, addressing the TODO: UnpackListExpr is small enough to be
inlined (when default optimizations are enabled), and for typical uses
of UnpackListExpr (e.g., "range UnpackListExpr(x)") the single-element
slice result is stack allocated in the caller. This CL adds a test
using testing.AllocsPerRun to ensure this remains so in the future.

Change-Id: I96a5591d202193ed5bf1ce6f290919107e3dc01b
Reviewed-on: https://go-review.googlesource.com/c/go/+/522336
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2023-08-24 07:17:27 +00:00