cmd/compile: replace uses of ir.Node with ir.Expr or ir.Stmt where appropriate #52731
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
In go/ast, we use ast.Expr and ast.Stmt to represent when an ast.Node is known to be an expression or statement, respectively.
Within cmd/compile, we have analogous ir.Expr and ir.Stmt interface types, but for historical reasons most code still uses ir.Node. This issue lays out a plan for how to migrate the compiler to use them. (Having started a few attempts at this, it's clearly not something that can gracefully land in a single CL.)
ir.ExprNode
andir.StmtNode
types. Normally, these will be type aliases toir.Node
; but if thestrict-ir
build tag is set, then they'll be aliases toir.Expr
andir.Stmt
, respectively, instead.strict-ir
build tag set.ir.Node
withir.ExprNode
orir.StmtNode
as possible (and refactoring code as needed), and then add the package to the unit test from step 2 to prevent backsliding.ir.ExprNode
andir.StmtNode
to be aliases toir.Expr
andir.Stmt
unconditionally (i.e., makestrict-ir
the default/only mode), and removeTestStrictIR
too.ir.ExprNode
andir.StmtNode
and replacing all uses withir.Expr
andir.Stmt
. (This could be split into 2 or more steps if we're concerned about conflicts with in-flight CLs; but I think as long as we give heads up before landing the CL, it should be fine.)I don't think this is pressing work, but wanted to lay out a plan and start getting buy-in from the rest of the compiler team before embarking upon it.
Two possible cons to this plan to note:
[]ir.Node
code paths to also operate on[]ir.Expr
and[]ir.Stmt
.It's worth noting though that both of these cons apply to go/ast already, and I've not heard them raised before. But then Go 1 compatibility also precludes any work that could address these issues.
The text was updated successfully, but these errors were encountered: