]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: redo mknode.go
authorKeith Randall <khr@golang.org>
Tue, 19 Jul 2022 18:09:01 +0000 (11:09 -0700)
committerKeith Randall <khr@golang.org>
Wed, 31 Aug 2022 22:09:44 +0000 (22:09 +0000)
commit5f5c018ca46b6634da9372f5af759cb36fcaed5f
treef252edc670cdec8c480de1cf27dfdcbb36092bf7
parent69aed4712d73c9c1b70be3e2e222eb55391e2fb0
cmd/compile: redo mknode.go

The current mknode has a few problems:
1) It tends not to run successfully if the tree is in a broken state.
2) It requires that it be run by the go tool in the tree (somewhat related to 1)
3) It requires setting GOROOT
4) It imports code outside the tree (x/packages)

This makes mknode.go very fragile. In particular, I've spent lots of
time fighting mknode when adding or removing code, related to 1.

Rewrite to just use go/ast and friends. No typechecking, no importing,
etc. It can run with any go version, it doesn't need to be the one
corresponding to the code in which it is run. (e.g. you can use go
1.16 to run mknode). It will work as long as the ir package is parseable.

When run, it generates identical output to the old mknode.

Fixes #53959

Change-Id: I5ce0b55572ebcd2fcd11af57a5f29bbf9fa4ed33
Reviewed-on: https://go-review.googlesource.com/c/go/+/418375
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
src/cmd/compile/internal/ir/mini.go
src/cmd/compile/internal/ir/mknode.go