]> Cypherpunks repositories - gostls13.git/commitdiff
ssa: clarify semantics of ID-to-PC translation function
authorAndrei Matei <andreimatei1@gmail.com>
Mon, 5 Jun 2023 23:14:01 +0000 (19:14 -0400)
committerDavid Chase <drchase@google.com>
Mon, 20 Nov 2023 16:21:26 +0000 (16:21 +0000)
Make it clear that the `block` argument is not always used, and stop
passing it in a case where it didn't really make sense - at the end of a
function.

Change-Id: I2fa86bed6ceb53a1b1cbfda5c3392e7e9da9579d
Reviewed-on: https://go-review.googlesource.com/c/go/+/502115
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/ssa/debug.go
src/cmd/compile/internal/ssagen/ssa.go

index 7e0e1f34a87c6cf549b16792985823c45cbd3fc7..05a72787f345fa01672f71c137714e580a786cde 100644 (file)
@@ -42,7 +42,10 @@ type FuncDebug struct {
        OptDcl []*ir.Name
 
        // Filled in by the user. Translates Block and Value ID to PC.
-       GetPC func(ID, ID) int64
+       //
+       // NOTE: block is only used if value is BlockStart.ID or BlockEnd.ID.
+       // Otherwise, it is ignored.
+       GetPC func(block, value ID) int64
 }
 
 type BlockDebug struct {
@@ -1368,7 +1371,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, FuncEnd.ID)
+               state.writePendingEntry(VarID(varID), -1, FuncEnd.ID)
                list := state.lists[varID]
                if state.loggingLevel > 0 {
                        if len(list) == 0 {
index 8d1e30e1e65e2878462b5d9b3424fbaa2f05810c..45bf0e6dc438a4025f34acf66447ed6343cafd16 100644 (file)
@@ -7578,9 +7578,9 @@ func genssa(f *ssa.Func, pp *objw.Progs) {
                for i, b := range f.Blocks {
                        idToIdx[b.ID] = i
                }
-               // Note that at this moment, Prog.Pc is a sequence number; it's
-               // not a real PC until after assembly, so this mapping has to
-               // be done later.
+               // Register a callback that will be used later to fill in PCs into location
+               // lists. At the moment, Prog.Pc is a sequence number; it's not a real PC
+               // until after assembly, so the translation needs to be deferred.
                debugInfo.GetPC = func(b, v ssa.ID) int64 {
                        switch v {
                        case ssa.BlockStart.ID: