]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove AUNDEF opcode
authorKeith Randall <keithr@alum.mit.edu>
Sat, 6 Apr 2019 19:42:51 +0000 (12:42 -0700)
committerKeith Randall <khr@golang.org>
Sun, 7 Apr 2019 01:15:28 +0000 (01:15 +0000)
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: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/amd64/ssa.go
src/cmd/compile/internal/arm/ssa.go
src/cmd/compile/internal/arm64/ssa.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/mips/ssa.go
src/cmd/compile/internal/mips64/ssa.go
src/cmd/compile/internal/ppc64/ssa.go
src/cmd/compile/internal/s390x/ssa.go
src/cmd/compile/internal/wasm/ssa.go
src/cmd/compile/internal/x86/ssa.go

index 5b8590c357f5e31780ab1765ed31af3f7810680a..693316bdc7f497c9e5d59d8b216235701433e459 100644 (file)
@@ -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:
index 8af6b1e6ed18628816f44dadaa3cbfe0147957e9..ee9c9f1c3fc3fda9d54eb94f9f93de49b699a523 100644 (file)
@@ -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)
index 0b9f62834c2c393b1de1605b744d1d97d2e60593..be4ddb4b6b67b69014053517519d49384bf3c450 100644 (file)
@@ -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)
index be317c210994a06fe6e605bbcda13b4442932dc8..dd056afcca61b10d5912837fbc91f139920bd905 100644 (file)
@@ -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
index d2ea0f46bb97bd4edbc627856ef5a9547cb71cbe..19b7c95bfdb0e78547745f72225821a1ed344f07 100644 (file)
@@ -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:
index d0c8b069005a3a0954b8c40eca5ab2283d1b5898..01b8ed05644751dd67883921725457998e0765dc 100644 (file)
@@ -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:
index a32f80fb29aa9d7b45223823fd3370e67627e0b7..49f78ee188717f09cf56d819f1183e1f08639ace 100644 (file)
@@ -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:
index d90605bcbd0a6f97da940b90f2f084b2510fae83..c5b2d74bcc3c5377c56cad85940ae705d7f262ad 100644 (file)
@@ -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:
index 63eb319edb8d3307eb6b17e16073c165bafcfe29..7fdd335ee9fa5e2ac5b280ca46a8303a780641be 100644 (file)
@@ -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)
index b7b0f445299ccdb0fc5fa1655f0361b769928d1f..66c7b753c6cc6d4b189caf95d677ffaaece765a9 100644 (file)
@@ -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: