]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.typeparams] cmd/compile: incremental typecheck during unified IR
authorMatthew Dempsky <mdempsky@google.com>
Thu, 1 Jul 2021 22:23:41 +0000 (15:23 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 2 Jul 2021 14:56:37 +0000 (14:56 +0000)
commita18726a648df48917e0ed1404cf6cdbc81acd495
tree3523ed696e16507d1d37bb9e8d542b05d0233945
parent2aea44204ef8e3467bd2d21865e3d2b8045f3d12
[dev.typeparams] cmd/compile: incremental typecheck during unified IR

This CL changes unified IR to incrementally typecheck the IR as it's
constructed. This is significant, because it means reader can now use
typecheck.Expr to typecheck sub-expressions when it's needed. This
should be helpful for construction and insertion of dictionaries.

This CL does introduce two quirks outside of unified IR itself,
which simplify preserving binary output:

1. Top-level declarations are sorted after they're constructed, to
avoid worrying about the order that closures are added.

2. Zero-padding autotmp_N variable names. Interleaving typechecking
means autotmp variables are sometimes named differently (since their
naming depends on the number of variables declared so far), and this
ensures that code that sorts variables by names doesn't suddenly sort
autotmp_8/autotmp_9 differently than it would have sorted
autotmp_9/autotmp_10.

While at it, this CL also updated reader to use ir.WithFunc instead of
manually setting and restoring ir.CurFunc. There's now only one
remaining direct use of ir.CurFunc.

Change-Id: I6233b4c059596e471c53166f94750917d710462f
Reviewed-on: https://go-review.googlesource.com/c/go/+/332469
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/noder/reader.go
src/cmd/compile/internal/noder/unified.go
src/cmd/compile/internal/noder/unified_test.go
src/cmd/compile/internal/typecheck/dcl.go