cl: don't declare var of ssa.Alloc and ssa.FieldAddr

This commit is contained in:
Li Jie
2024-09-20 12:19:51 +08:00
parent 2a4a01cb7b
commit d89b68a279

View File

@@ -730,26 +730,21 @@ func (p *context) compileInstr(b llssa.Builder, instr ssa.Instruction) {
// Not a local variable.
return
}
if v.IsAddr {
// skip *ssa.Alloc or *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)
if v.IsAddr {
// *ssa.Alloc or *ssa.FieldAddr
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))
}
b.DIValue(value, dbgVar, p.fn, pos, b.Func.Block(v.Block().Index))
}
default:
panic(fmt.Sprintf("compileInstr: unknown instr - %T\n", instr))
}
}
type poser interface {
Pos() token.Pos
}
func (p *context) getLocalVariable(b llssa.Builder, fn *ssa.Function, v *types.Var) llssa.DIVar {
pos := p.fset.Position(v.Pos())
t := b.Prog.Type(v.Type(), llssa.InGo)