mirror of
https://github.com/golang/go.git
synced 2025-05-14 11:54:38 +00:00
cmd/compile: ensure first instruction of function is stmt
In gdb, "b f" gets confused if the first instruction of "f" is not marked as a statement in the DWARF line table. To ensure gdb is not confused, move the first statement marker in "f" to its first instruction. The screwy-looking conditional for "what's the first instruction with a statement marker" will become simpler in the future. Fixes #24695. Change-Id: I2eef81676b64d1bd9bff5da03b89b9dc0c18f44f Reviewed-on: https://go-review.googlesource.com/104955 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
33eaf75a03
commit
eda22a06fb
@ -4666,6 +4666,16 @@ func genssa(f *ssa.Func, pp *Progs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the very first instruction is not tagged as a statement,
|
||||||
|
// debuggers may attribute it to previous function in program.
|
||||||
|
firstPos := src.NoXPos
|
||||||
|
for _, v := range f.Entry.Values {
|
||||||
|
if v.Op != ssa.OpArg && v.Op != ssa.OpVarDef && v.Pos.IsStmt() != src.PosNotStmt { // TODO will be == src.PosIsStmt in pending CL, more accurate
|
||||||
|
firstPos = v.Pos.WithIsStmt()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Emit basic blocks
|
// Emit basic blocks
|
||||||
for i, b := range f.Blocks {
|
for i, b := range f.Blocks {
|
||||||
s.bstart[b.ID] = s.pp.next
|
s.bstart[b.ID] = s.pp.next
|
||||||
@ -4709,6 +4719,11 @@ func genssa(f *ssa.Func, pp *Progs) {
|
|||||||
CheckLoweredPhi(v)
|
CheckLoweredPhi(v)
|
||||||
default:
|
default:
|
||||||
// let the backend handle it
|
// let the backend handle it
|
||||||
|
// Special case for first line in function; move it to the start.
|
||||||
|
if firstPos != src.NoXPos {
|
||||||
|
s.SetPos(firstPos)
|
||||||
|
firstPos = src.NoXPos
|
||||||
|
}
|
||||||
thearch.SSAGenValue(&s, v)
|
thearch.SSAGenValue(&s, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user