ssa: fix function and global var debug info scope

This commit is contained in:
Li Jie
2024-09-20 12:22:08 +08:00
parent d89b68a279
commit f71e34fd9f
6 changed files with 38 additions and 10 deletions

View File

@@ -730,15 +730,20 @@ func (p *context) compileInstr(b llssa.Builder, instr ssa.Instruction) {
// Not a local variable.
return
}
if v.IsAddr {
// skip *ssa.Alloc or *ssa.FieldAddr
if variable.IsField() {
// skip *ssa.FieldAddr
return
}
pos := p.goProg.Fset.Position(v.Pos())
value := p.compileValue(b, v.X)
fn := v.Parent()
dbgVar := p.getLocalVariable(b, fn, variable)
b.DIValue(value, dbgVar, p.fn, pos, b.Func.Block(v.Block().Index))
if v.IsAddr {
// *ssa.Alloc
b.DIDeclare(value, dbgVar, p.fn, pos, b.Func.Block(v.Block().Index))
} else {
b.DIValue(value, dbgVar, p.fn, pos, b.Func.Block(v.Block().Index))
}
}
default:
panic(fmt.Sprintf("compileInstr: unknown instr - %T\n", instr))