]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/arm: fix line numbers after constant pool
authorRuss Cox <rsc@golang.org>
Thu, 30 Jul 2015 14:28:44 +0000 (10:28 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 30 Jul 2015 15:47:31 +0000 (15:47 +0000)
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>

src/cmd/internal/obj/arm/asm5.go
src/cmd/internal/obj/arm64/asm7.go

index f55357cd4b457f97e7d20911cff7e6d5769aa829..e50dcf56f89902764600993764f415e851209325 100644 (file)
@@ -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
index 9537fcecf992575c457266f8422cabc7ecd1f65b..ab0f7aebdb608f712ac1a179e0a3488affb007b8 100644 (file)
@@ -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