]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: leave JMPs in when using -N
authorKeith Randall <khr@golang.org>
Tue, 23 Feb 2016 07:19:00 +0000 (23:19 -0800)
committerKeith Randall <khr@golang.org>
Wed, 24 Feb 2016 16:53:00 +0000 (16:53 +0000)
Helps keep line numbers around for debugging, particularly
for break and continue statements (which often compile
down to nothing).

Update #14379

Change-Id: I6ea06aa887b0450d9ba4f11e319e5c263f5a98ba
Reviewed-on: https://go-review.googlesource.com/19848
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/critical.go

index 13d866370632ad45cb2a2806de36b907e4e50131..598f12015529a85702d0f948c03fd0cd4da259ce 100644 (file)
@@ -3627,7 +3627,10 @@ func genssa(f *ssa.Func, ptxt *obj.Prog, gcargs, gclocals *Sym) {
                }
                // Emit control flow instructions for block
                var next *ssa.Block
-               if i < len(f.Blocks)-1 {
+               if i < len(f.Blocks)-1 && Debug['N'] == 0 {
+                       // If -N, leave next==nil so every block with successors
+                       // ends in a JMP.  Helps keep line numbers for otherwise
+                       // empty blocks.
                        next = f.Blocks[i+1]
                }
                x := Pc
index ba754508759a5df6512ad22d76eb2c53cf3d32c5..9fea0ec1cd49e6272e3b5b189d3d1c4164a04b41 100644 (file)
@@ -21,6 +21,7 @@ func critical(f *Func) {
 
                        // allocate a new block to place on the edge
                        d := f.NewBlock(BlockPlain)
+                       d.Line = c.Line
 
                        // splice it in
                        d.Preds = append(d.Preds, c)