1
0
mirror of https://github.com/golang/go synced 2024-11-24 16:30:17 -07:00

[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 <drchase@google.com>
This commit is contained in:
Keith Randall 2016-02-22 23:19:00 -08:00
parent d337e55672
commit 8906d2a171
2 changed files with 5 additions and 1 deletions

View 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

View 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)