Skip to content

Commit

Permalink
cmd/compile: remove AUNDEF opcode
Browse files Browse the repository at this point in the history
This opcode was only used to mark unreachable code for plive to use.
plive now uses the SSA representation, so it knows locations are
unreachable because they are ends of Exit blocks. It doesn't need
these opcodes any more.

These opcodes actually used space in the binary, 2 bytes per undef
on x86 and more for other archs.

Makes the amd64 go binary 0.2% smaller.

Change-Id: I64c84c35db7c7949617a3a5830f09c8e5fcd2620
Reviewed-on: https://go-review.googlesource.com/c/go/+/171058
Run-TryBot: Keith Randall <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
randall77 committed Apr 7, 2019
1 parent cb66462 commit ad6c691
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/cmd/compile/internal/amd64/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
s.Branches = append(s.Branches, gc.Branch{P: p, B: b.Succs[0].Block()})
}
case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here
case ssa.BlockRet:
s.Prog(obj.ARET)
case ssa.BlockRetJmp:
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/arm/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
}

case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here

case ssa.BlockRet:
s.Prog(obj.ARET)
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/arm64/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
}

case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here

case ssa.BlockRet:
s.Prog(obj.ARET)
Expand Down
7 changes: 7 additions & 0 deletions src/cmd/compile/internal/gc/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -5335,6 +5335,13 @@ func genssa(f *ssa.Func, pp *Progs) {
}
}
}
if f.Blocks[len(f.Blocks)-1].Kind == ssa.BlockExit {
// We need the return address of a panic call to
// still be inside the function in question. So if
// it ends in a call which doesn't return, add a
// nop (which will never execute) after the call.
thearch.Ginsnop(pp)
}

if inlMarks != nil {
// We have some inline marks. Try to find other instructions we're
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/mips/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
s.Branches = append(s.Branches, gc.Branch{P: p, B: b.Succs[0].Block()})
}
case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here
case ssa.BlockRet:
s.Prog(obj.ARET)
case ssa.BlockRetJmp:
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/mips64/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
s.Branches = append(s.Branches, gc.Branch{P: p, B: b.Succs[0].Block()})
}
case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here
case ssa.BlockRet:
s.Prog(obj.ARET)
case ssa.BlockRetJmp:
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/ppc64/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
s.Branches = append(s.Branches, gc.Branch{P: p, B: b.Succs[0].Block()})
}
case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here
case ssa.BlockRet:
s.Prog(obj.ARET)
case ssa.BlockRetJmp:
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/s390x/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
s.Branches = append(s.Branches, gc.Branch{P: p, B: b.Succs[0].Block()})
}
case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here
case ssa.BlockRet:
s.Prog(obj.ARET)
case ssa.BlockRetJmp:
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/wasm/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
p.To.Sym = b.Aux.(*obj.LSym)

case ssa.BlockExit:
s.Prog(obj.AUNDEF)

case ssa.BlockDefer:
p := s.Prog(wasm.AGet)
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/x86/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
s.Branches = append(s.Branches, gc.Branch{P: p, B: b.Succs[0].Block()})
}
case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here
case ssa.BlockRet:
s.Prog(obj.ARET)
case ssa.BlockRetJmp:
Expand Down

0 comments on commit ad6c691

Please sign in to comment.