From: Heschi Kreinick Date: Wed, 28 Feb 2018 21:32:11 +0000 (-0500) Subject: cmd/compile/internal/ssa: avoid accidental list ends X-Git-Tag: go1.11beta1~1382 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=bff29f2d1798cb0c8b6a4a8440c076f4b9460158;p=gostls13.git cmd/compile/internal/ssa: avoid accidental list ends Some SSA values don't translate into any instructions. If a function began with two of them, and both modified the storage of the same variable, we'd end up with a location list entry that started and ended at 0. That looks like an end-of-list entry, which would then confuse downstream tools, particularly the fixup in the linker. "Fix" this by changing the end of such entries to 1. Should be harmless, since AFAIK we don't generate any 1-byte instructions. Later CLs will reduce the frequency of these entries anyway. Change-Id: I9b7e5e69f914244cc826fb9f4a6acfe2dc695f81 Reviewed-on: https://go-review.googlesource.com/97955 Run-TryBot: Heschi Kreinick TryBot-Result: Gobot Gobot Reviewed-by: David Chase --- diff --git a/src/cmd/compile/internal/ssa/debug.go b/src/cmd/compile/internal/ssa/debug.go index 68705aa9dd..9750c4d017 100644 --- a/src/cmd/compile/internal/ssa/debug.go +++ b/src/cmd/compile/internal/ssa/debug.go @@ -947,14 +947,20 @@ func (debugInfo *FuncDebug) PutLocationList(list []byte, ctxt *obj.Link, listSym getPC := debugInfo.GetPC // Re-read list, translating its address from block/value ID to PC. for i := 0; i < len(list); { - translate := func() { - bv := readPtr(ctxt, list[i:]) - pc := getPC(decodeValue(ctxt, bv)) - writePtr(ctxt, list[i:], uint64(pc)) - i += ctxt.Arch.PtrSize + begin := getPC(decodeValue(ctxt, readPtr(ctxt, list[i:]))) + end := getPC(decodeValue(ctxt, readPtr(ctxt, list[i+ctxt.Arch.PtrSize:]))) + + // Horrible hack. If a range contains only zero-width + // instructions, e.g. an Arg, and it's at the beginning of the + // function, this would be indistinguishable from an + // end entry. Fudge it. + if begin == 0 && end == 0 { + end = 1 } - translate() - translate() + + writePtr(ctxt, list[i:], uint64(begin)) + writePtr(ctxt, list[i+ctxt.Arch.PtrSize:], uint64(end)) + i += 2 * ctxt.Arch.PtrSize i += 2 + int(ctxt.Arch.ByteOrder.Uint16(list[i:])) }