Skip to content

Commit

Permalink
cmd/compile: rip out support for OVARKILL from compiler frontend
Browse files Browse the repository at this point in the history
Change-Id: I2c5b1064084bade68aaa065cf74dca6886fb752f
Reviewed-on: https://go-review.googlesource.com/c/go/+/419236
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Run-TryBot: Keith Randall <[email protected]>
Reviewed-by: David Chase <[email protected]>
  • Loading branch information
randall77 committed Aug 22, 2022
1 parent a10da77 commit e21c1f7
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/ir/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ func (n *UnaryExpr) SetOp(op Op) {
case OBITNOT, ONEG, ONOT, OPLUS, ORECV,
OALIGNOF, OCAP, OCLOSE, OIMAG, OLEN, ONEW,
OOFFSETOF, OPANIC, OREAL, OSIZEOF,
OCHECKNIL, OCFUNC, OIDATA, OITAB, OSPTR, OVARDEF, OVARKILL, OVARLIVE:
OCHECKNIL, OCFUNC, OIDATA, OITAB, OSPTR, OVARDEF, OVARLIVE:
n.op = op
}
}
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/ir/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ const (
OCFUNC // reference to c function pointer (not go func value)
OCHECKNIL // emit code to ensure pointer/interface not nil
OVARDEF // variable is about to be fully initialized
OVARKILL // variable is dead
OVARLIVE // variable is alive
ORESULT // result of a function call; Xoffset is stack offset
OINLMARK // start of an inlined body, with file/line of caller. Xoffset is an index into the inline tree.
Expand Down
31 changes: 15 additions & 16 deletions src/cmd/compile/internal/ir/op_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/cmd/compile/internal/ssagen/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -1384,8 +1384,8 @@ func (s *state) stmtList(l ir.Nodes) {

// stmt converts the statement n to SSA and adds it to s.
func (s *state) stmt(n ir.Node) {
if !(n.Op() == ir.OVARKILL || n.Op() == ir.OVARLIVE || n.Op() == ir.OVARDEF) {
// OVARKILL, OVARLIVE, and OVARDEF are invisible to the programmer, so we don't use their line numbers to avoid confusion in debugging.
if !(n.Op() == ir.OVARLIVE || n.Op() == ir.OVARDEF) {
// OVARLIVE and OVARDEF are invisible to the programmer, so we don't use their line numbers to avoid confusion in debugging.
s.pushLine(n.Pos())
defer s.popLine()
}
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/compile/internal/typecheck/typecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func typecheck(n ir.Node, top int) (res ir.Node) {
case ir.OAPPEND:
// Must be used (and not BinaryExpr/UnaryExpr).
isStmt = false
case ir.OCLOSE, ir.ODELETE, ir.OPANIC, ir.OPRINT, ir.OPRINTN, ir.OVARKILL, ir.OVARLIVE:
case ir.OCLOSE, ir.ODELETE, ir.OPANIC, ir.OPRINT, ir.OPRINTN, ir.OVARLIVE:
// Must not be used.
isExpr = false
isStmt = true
Expand Down Expand Up @@ -750,7 +750,6 @@ func typecheck1(n ir.Node, top int) ir.Node {
ir.ODCL,
ir.OGOTO,
ir.OFALL,
ir.OVARKILL,
ir.OVARLIVE:
return n

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/walk/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ func (o *orderState) stmt(n ir.Node) {
default:
base.Fatalf("order.stmt %v", n.Op())

case ir.OVARKILL, ir.OVARLIVE, ir.OINLMARK:
case ir.OVARLIVE, ir.OINLMARK:
o.out = append(o.out, n)

case ir.OAS:
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/walk/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func walkStmt(n ir.Node) ir.Node {
ir.ODCLTYPE,
ir.OCHECKNIL,
ir.OVARDEF,
ir.OVARKILL,
ir.OVARLIVE:
return n

Expand Down
13 changes: 2 additions & 11 deletions src/cmd/compile/internal/walk/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,19 +372,10 @@ func allCaseExprsAreSideEffectFree(sw *ir.SwitchStmt) bool {

// endsInFallthrough reports whether stmts ends with a "fallthrough" statement.
func endsInFallthrough(stmts []ir.Node) (bool, src.XPos) {
// Search backwards for the index of the fallthrough
// statement. Do not assume it'll be in the last
// position, since in some cases (e.g. when the statement
// list contains autotmp_ variables), one or more OVARKILL
// nodes will be at the end of the list.

i := len(stmts) - 1
for i >= 0 && stmts[i].Op() == ir.OVARKILL {
i--
}
if i < 0 {
if len(stmts) == 0 {
return false, src.NoXPos
}
i := len(stmts) - 1
return stmts[i].Op() == ir.OFALL, stmts[i].Pos()
}

Expand Down

0 comments on commit e21c1f7

Please sign in to comment.