Skip to content

Commit

Permalink
cmd/internal/obj/arm: fix line numbers after constant pool
Browse files Browse the repository at this point in the history
If a function is large enough to need to flush the constant pool
mid-function, the line number assignment code was forcing the
line numbers not just for the constant pool but for all the instructions
that follow it. This made the line number information completely
wrong for all but the beginning of large functions on arm.

Same problem in code copied into arm64.

This broke runtime/trace's TestTraceSymbolize.

Fixes arm build.

Change-Id: I84d9fb2c798c4085f69b68dc766ab4800c7a6ca4
Reviewed-on: https://go-review.googlesource.com/12894
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
rsc committed Jul 30, 2015
1 parent ab714a7 commit a1e4220
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
15 changes: 7 additions & 8 deletions src/cmd/internal/obj/arm/asm5.go
Expand Up @@ -862,17 +862,16 @@ func flushpool(ctxt *obj.Link, p *obj.Prog, skip int, force int) bool {
ctxt.Elitrl = q
}

// The line number for constant pool entries doesn't really matter.
// We set it to the line number of the preceding instruction so that
// there are no deltas to encode in the pc-line tables.
for q := ctxt.Blitrl; q != nil; q = q.Link {
q.Lineno = p.Lineno
}

ctxt.Elitrl.Link = p.Link
p.Link = ctxt.Blitrl

// BUG(minux): how to correctly handle line number for constant pool entries?
// for now, we set line number to the last instruction preceding them at least
// this won't bloat the .debug_line tables
for ctxt.Blitrl != nil {
ctxt.Blitrl.Lineno = p.Lineno
ctxt.Blitrl = ctxt.Blitrl.Link
}

ctxt.Blitrl = nil /* BUG: should refer back to values until out-of-range */
ctxt.Elitrl = nil
pool.size = 0
Expand Down
16 changes: 8 additions & 8 deletions src/cmd/internal/obj/arm64/asm7.go
Expand Up @@ -699,17 +699,17 @@ func flushpool(ctxt *obj.Link, p *obj.Prog, skip int) {
} else if p.Pc+int64(pool.size)-int64(pool.start) < 1024*1024 {
return
}
ctxt.Elitrl.Link = p.Link
p.Link = ctxt.Blitrl

// BUG(minux): how to correctly handle line number for constant pool entries?
// for now, we set line number to the last instruction preceding them at least
// this won't bloat the .debug_line tables
for ctxt.Blitrl != nil {
ctxt.Blitrl.Lineno = p.Lineno
ctxt.Blitrl = ctxt.Blitrl.Link
// The line number for constant pool entries doesn't really matter.
// We set it to the line number of the preceding instruction so that
// there are no deltas to encode in the pc-line tables.
for q := ctxt.Blitrl; q != nil; q = q.Link {
q.Lineno = p.Lineno
}

ctxt.Elitrl.Link = p.Link
p.Link = ctxt.Blitrl

ctxt.Blitrl = nil /* BUG: should refer back to values until out-of-range */
ctxt.Elitrl = nil
pool.size = 0
Expand Down

0 comments on commit a1e4220

Please sign in to comment.