Commit 8906d2a1 authored by Keith Randall's avatar Keith Randall

[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/19848Reviewed-by: default avatarDavid Chase <drchase@google.com>
parent d337e556
......@@ -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
......
......@@ -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)
......
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