From: Keith Randall Date: Tue, 23 Feb 2016 07:19:00 +0000 (-0800) Subject: [dev.ssa] cmd/compile: leave JMPs in when using -N X-Git-Tag: go1.7beta1~1623^2^2~26 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8906d2a171153ab337a88d4e9f59a7626ac55019;p=gostls13.git [dev.ssa] cmd/compile: leave JMPs in when using -N 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 --- diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index 13d8663706..598f120155 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -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 diff --git a/src/cmd/compile/internal/ssa/critical.go b/src/cmd/compile/internal/ssa/critical.go index ba75450875..9fea0ec1cd 100644 --- a/src/cmd/compile/internal/ssa/critical.go +++ b/src/cmd/compile/internal/ssa/critical.go @@ -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)