On the dev.regabi branch, there's now a lot of code that uses ir.Node when really *ir.Name or *ir.Func would be sufficient, clearer, and more efficient. We should change those where possible.
For example, both of these fields only ever store *ir.Name:
|
vars []ir.Node |
|
idx map[ir.Node]int32 |
As basic steps, I'd recommend:
-
Pick a slice or map that appears to only be used for variables (or functions) and change it from ir.Node to *ir.Name (or *ir.Func).
-
Add type assertions and type conversions as necessary to get it to compile.
-
Check that it still works correctly.
-
Rewrite function signatures to push the type assertions as far out as possible.
Beware: Sometimes code may mostly store Names, but still occasionally store other Nodes. For example, state.vars says it's only used for ONAMEs, but then OANDAND/OOROR nodes end up getting stuffed in there too.
I'd recommend for contributors to start small. Maybe a few variables. Ideally sticking to just one file at a time. Also, coordinate here to avoid redundant work, or to ask questions if you're unsure.
/cc @cuonglm @zephyrtronium @rsc
On the dev.regabi branch, there's now a lot of code that uses
ir.Nodewhen really*ir.Nameor*ir.Funcwould be sufficient, clearer, and more efficient. We should change those where possible.For example, both of these fields only ever store
*ir.Name:go/src/cmd/compile/internal/gc/plive.go
Lines 106 to 107 in 351bc2f
As basic steps, I'd recommend:
Pick a slice or map that appears to only be used for variables (or functions) and change it from ir.Node to *ir.Name (or *ir.Func).
Add type assertions and type conversions as necessary to get it to compile.
Check that it still works correctly.
Rewrite function signatures to push the type assertions as far out as possible.
Beware: Sometimes code may mostly store Names, but still occasionally store other Nodes. For example, state.vars says it's only used for ONAMEs, but then OANDAND/OOROR nodes end up getting stuffed in there too.
I'd recommend for contributors to start small. Maybe a few variables. Ideally sticking to just one file at a time. Also, coordinate here to avoid redundant work, or to ask questions if you're unsure.
/cc @cuonglm @zephyrtronium @rsc