diff options
author | Than McIntosh <thanm@google.com> | 2021-04-28 18:26:54 -0400 |
---|---|---|
committer | Than McIntosh <thanm@google.com> | 2021-04-30 18:46:51 +0000 |
commit | afa58ddf5a17a3618a24baf161b06cf0e066cb88 (patch) | |
tree | 4054cb1b643bc5ac4ca4e4b4fce87e5c66d21494 /src/cmd/compile/internal/ssa | |
parent | 83ac59b1a55a4ae728393b445e2d2438f930b767 (diff) | |
download | go-afa58ddf5a17a3618a24baf161b06cf0e066cb88.tar.gz go-afa58ddf5a17a3618a24baf161b06cf0e066cb88.zip |
cmd/compile: revise block/func end sentinels in debug analysis
The SSA code for debug variable location analysis (for DWARF) has two
special 'sentinel' values that it uses to handshake with the
debugInfo.GetPC callback when capturing the PC values of debug
variable ranges after prog generatoin: "BlockStart" and "BlockEnd".
"BlockStart" has the expected semantics: it means "the PC value of the
first instruction of block B", but "BlockEnd" does not mean "PC value
of the last instruction of block B", but rather it is implemented as
"the PC value of the last instruction of the function". This causes
confusion when reading the code, and seems to to result in implementation
flaws in the past, leading to incorrect ranges in some cases.
To help with this, add a new sentinel "FuncEnd" (which has the "last
inst in the function" semantics) and change the implementation of
"BlockEnd" to actually mean what its name implies (last inst in
block).
Updates #45720.
Change-Id: Ic3497fb60413e898d2bfe27805c3db56483d12a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/314930
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa')
-rw-r--r-- | src/cmd/compile/internal/ssa/debug.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/ssa/debug.go b/src/cmd/compile/internal/ssa/debug.go index d725fc526e..46743f54eb 100644 --- a/src/cmd/compile/internal/ssa/debug.go +++ b/src/cmd/compile/internal/ssa/debug.go @@ -152,6 +152,12 @@ var BlockEnd = &Value{ Aux: StringToAux("BlockEnd"), } +var FuncEnd = &Value{ + ID: -30000, + Op: OpInvalid, + Aux: StringToAux("FuncEnd"), +} + // RegisterSet is a bitmap of registers, indexed by Register.num. type RegisterSet uint64 @@ -948,7 +954,7 @@ func (state *debugState) buildLocationLists(blockLocs []*BlockDebug) { // Flush any leftover entries live at the end of the last block. for varID := range state.lists { - state.writePendingEntry(VarID(varID), state.f.Blocks[len(state.f.Blocks)-1].ID, BlockEnd.ID) + state.writePendingEntry(VarID(varID), state.f.Blocks[len(state.f.Blocks)-1].ID, FuncEnd.ID) list := state.lists[varID] if state.loggingEnabled { if len(list) == 0 { |