cmd/compile: fix Node.Etype overloading

Add helper methods that validate n.Op and convert to/from the
appropriate type.

Notably, there was a lot of code in walk.go that thought setting
Etype=1 on an OADDR node affected escape analysis.

Passes toolstash-check.

TBR=marvin

Change-Id: Ieae7c67225c1459c9719f9e6a748a25b975cf758
Reviewed-on: https://go-review.googlesource.com/99535
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Matthew Dempsky 2018-03-08 04:18:18 -08:00
parent 91102bf723
commit e4de522c95
11 changed files with 98 additions and 72 deletions

View file

@ -114,16 +114,15 @@ func lexinit() {
}
for _, s := range builtinFuncs {
// TODO(marvin): Fix Node.EType type union.
s2 := builtinpkg.Lookup(s.name)
s2.Def = asTypesNode(newname(s2))
asNode(s2.Def).Etype = types.EType(s.op)
asNode(s2.Def).SetSubOp(s.op)
}
for _, s := range unsafeFuncs {
s2 := unsafepkg.Lookup(s.name)
s2.Def = asTypesNode(newname(s2))
asNode(s2.Def).Etype = types.EType(s.op)
asNode(s2.Def).SetSubOp(s.op)
}
types.Idealstring = types.New(TSTRING)