From a1e422071cd8122b4b93bbdeb02d0ea646519955 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 30 Jul 2015 10:28:44 -0400 Subject: [PATCH] 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/12894 Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor --- src/cmd/internal/obj/arm/asm5.go | 15 +++++++-------- src/cmd/internal/obj/arm64/asm7.go | 16 ++++++++-------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/cmd/internal/obj/arm/asm5.go b/src/cmd/internal/obj/arm/asm5.go index f55357cd4b457..e50dcf56f8990 100644 --- a/src/cmd/internal/obj/arm/asm5.go +++ b/src/cmd/internal/obj/arm/asm5.go @@ -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 diff --git a/src/cmd/internal/obj/arm64/asm7.go b/src/cmd/internal/obj/arm64/asm7.go index 9537fcecf9925..ab0f7aebdb608 100644 --- a/src/cmd/internal/obj/arm64/asm7.go +++ b/src/cmd/internal/obj/arm64/asm7.go @@ -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