Commit ad6c6915 authored by Keith Randall's avatar Keith Randall Committed by Keith Randall

cmd/compile: remove AUNDEF opcode

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 <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent cb664623
...@@ -1208,7 +1208,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) { ...@@ -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()}) s.Branches = append(s.Branches, gc.Branch{P: p, B: b.Succs[0].Block()})
} }
case ssa.BlockExit: case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here
case ssa.BlockRet: case ssa.BlockRet:
s.Prog(obj.ARET) s.Prog(obj.ARET)
case ssa.BlockRetJmp: case ssa.BlockRetJmp:
......
...@@ -929,7 +929,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) { ...@@ -929,7 +929,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
} }
case ssa.BlockExit: case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here
case ssa.BlockRet: case ssa.BlockRet:
s.Prog(obj.ARET) s.Prog(obj.ARET)
......
...@@ -1006,7 +1006,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) { ...@@ -1006,7 +1006,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
} }
case ssa.BlockExit: case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here
case ssa.BlockRet: case ssa.BlockRet:
s.Prog(obj.ARET) s.Prog(obj.ARET)
......
...@@ -5335,6 +5335,13 @@ func genssa(f *ssa.Func, pp *Progs) { ...@@ -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 { if inlMarks != nil {
// We have some inline marks. Try to find other instructions we're // We have some inline marks. Try to find other instructions we're
......
...@@ -828,7 +828,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) { ...@@ -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()}) s.Branches = append(s.Branches, gc.Branch{P: p, B: b.Succs[0].Block()})
} }
case ssa.BlockExit: case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here
case ssa.BlockRet: case ssa.BlockRet:
s.Prog(obj.ARET) s.Prog(obj.ARET)
case ssa.BlockRetJmp: case ssa.BlockRetJmp:
......
...@@ -793,7 +793,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) { ...@@ -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()}) s.Branches = append(s.Branches, gc.Branch{P: p, B: b.Succs[0].Block()})
} }
case ssa.BlockExit: case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here
case ssa.BlockRet: case ssa.BlockRet:
s.Prog(obj.ARET) s.Prog(obj.ARET)
case ssa.BlockRetJmp: case ssa.BlockRetJmp:
......
...@@ -1291,7 +1291,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) { ...@@ -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()}) s.Branches = append(s.Branches, gc.Branch{P: p, B: b.Succs[0].Block()})
} }
case ssa.BlockExit: case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here
case ssa.BlockRet: case ssa.BlockRet:
s.Prog(obj.ARET) s.Prog(obj.ARET)
case ssa.BlockRetJmp: case ssa.BlockRetJmp:
......
...@@ -815,7 +815,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) { ...@@ -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()}) s.Branches = append(s.Branches, gc.Branch{P: p, B: b.Succs[0].Block()})
} }
case ssa.BlockExit: case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here
case ssa.BlockRet: case ssa.BlockRet:
s.Prog(obj.ARET) s.Prog(obj.ARET)
case ssa.BlockRetJmp: case ssa.BlockRetJmp:
......
...@@ -97,7 +97,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) { ...@@ -97,7 +97,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
p.To.Sym = b.Aux.(*obj.LSym) p.To.Sym = b.Aux.(*obj.LSym)
case ssa.BlockExit: case ssa.BlockExit:
s.Prog(obj.AUNDEF)
case ssa.BlockDefer: case ssa.BlockDefer:
p := s.Prog(wasm.AGet) p := s.Prog(wasm.AGet)
......
...@@ -916,7 +916,6 @@ func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) { ...@@ -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()}) s.Branches = append(s.Branches, gc.Branch{P: p, B: b.Succs[0].Block()})
} }
case ssa.BlockExit: case ssa.BlockExit:
s.Prog(obj.AUNDEF) // tell plive.go that we never reach here
case ssa.BlockRet: case ssa.BlockRet:
s.Prog(obj.ARET) s.Prog(obj.ARET)
case ssa.BlockRetJmp: case ssa.BlockRetJmp:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment