Commit a1e42207 authored by Russ Cox's avatar Russ Cox

cmd/internal/obj/arm: fix line numbers after constant pool

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/12894Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
parent ab714a70
...@@ -862,17 +862,16 @@ func flushpool(ctxt *obj.Link, p *obj.Prog, skip int, force int) bool { ...@@ -862,17 +862,16 @@ func flushpool(ctxt *obj.Link, p *obj.Prog, skip int, force int) bool {
ctxt.Elitrl = q 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 ctxt.Elitrl.Link = p.Link
p.Link = ctxt.Blitrl 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.Blitrl = nil /* BUG: should refer back to values until out-of-range */
ctxt.Elitrl = nil ctxt.Elitrl = nil
pool.size = 0 pool.size = 0
......
...@@ -699,17 +699,17 @@ func flushpool(ctxt *obj.Link, p *obj.Prog, skip int) { ...@@ -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 { } else if p.Pc+int64(pool.size)-int64(pool.start) < 1024*1024 {
return return
} }
ctxt.Elitrl.Link = p.Link
p.Link = ctxt.Blitrl
// BUG(minux): how to correctly handle line number for constant pool entries? // The line number for constant pool entries doesn't really matter.
// for now, we set line number to the last instruction preceding them at least // We set it to the line number of the preceding instruction so that
// this won't bloat the .debug_line tables // there are no deltas to encode in the pc-line tables.
for ctxt.Blitrl != nil { for q := ctxt.Blitrl; q != nil; q = q.Link {
ctxt.Blitrl.Lineno = p.Lineno q.Lineno = p.Lineno
ctxt.Blitrl = ctxt.Blitrl.Link
} }
ctxt.Elitrl.Link = p.Link
p.Link = ctxt.Blitrl
ctxt.Blitrl = nil /* BUG: should refer back to values until out-of-range */ ctxt.Blitrl = nil /* BUG: should refer back to values until out-of-range */
ctxt.Elitrl = nil ctxt.Elitrl = nil
pool.size = 0 pool.size = 0
......
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