Skip to content

Commit e6b154d

Browse files
andreimateidr2chase
authored andcommitted
ssa: clarify semantics of ID-to-PC translation function
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 <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Run-TryBot: David Chase <[email protected]> Reviewed-by: David Chase <[email protected]>
1 parent d33ad2d commit e6b154d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/cmd/compile/internal/ssa/debug.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ type FuncDebug struct {
4242
OptDcl []*ir.Name
4343

4444
// Filled in by the user. Translates Block and Value ID to PC.
45-
GetPC func(ID, ID) int64
45+
//
46+
// NOTE: block is only used if value is BlockStart.ID or BlockEnd.ID.
47+
// Otherwise, it is ignored.
48+
GetPC func(block, value ID) int64
4649
}
4750

4851
type BlockDebug struct {
@@ -1368,7 +1371,7 @@ func (state *debugState) buildLocationLists(blockLocs []*BlockDebug) {
13681371

13691372
// Flush any leftover entries live at the end of the last block.
13701373
for varID := range state.lists {
1371-
state.writePendingEntry(VarID(varID), state.f.Blocks[len(state.f.Blocks)-1].ID, FuncEnd.ID)
1374+
state.writePendingEntry(VarID(varID), -1, FuncEnd.ID)
13721375
list := state.lists[varID]
13731376
if state.loggingLevel > 0 {
13741377
if len(list) == 0 {

src/cmd/compile/internal/ssagen/ssa.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7578,9 +7578,9 @@ func genssa(f *ssa.Func, pp *objw.Progs) {
75787578
for i, b := range f.Blocks {
75797579
idToIdx[b.ID] = i
75807580
}
7581-
// Note that at this moment, Prog.Pc is a sequence number; it's
7582-
// not a real PC until after assembly, so this mapping has to
7583-
// be done later.
7581+
// Register a callback that will be used later to fill in PCs into location
7582+
// lists. At the moment, Prog.Pc is a sequence number; it's not a real PC
7583+
// until after assembly, so the translation needs to be deferred.
75847584
debugInfo.GetPC = func(b, v ssa.ID) int64 {
75857585
switch v {
75867586
case ssa.BlockStart.ID:

0 commit comments

Comments
 (0)