debug: supports scope (if, for)

This commit is contained in:
Li Jie
2024-09-29 16:20:41 +08:00
parent e392956e2a
commit 88cb607975
8 changed files with 274 additions and 95 deletions

View File

@@ -273,7 +273,8 @@ func (p Function) NewBuilder() Builder {
b := prog.ctx.NewBuilder()
// TODO(xsw): Finalize may cause panic, so comment it.
// b.Finalize()
return &aBuilder{b, nil, p, p.Pkg, prog, make(map[Expr]dbgExpr)}
return &aBuilder{b, nil, p, p.Pkg, prog,
make(map[Expr]dbgExpr), make(map[*types.Scope]DIScope)}
}
// HasBody reports whether the function has a body.
@@ -327,3 +328,23 @@ func (p Function) SetRecover(blk BasicBlock) {
}
// -----------------------------------------------------------------------------
type inlineAttr int
const (
NoInline inlineAttr = iota
AlwaysInline
InlineHint
)
func (p Function) Inline(inline inlineAttr) {
inlineAttrName := map[inlineAttr]string{
NoInline: "noinline",
AlwaysInline: "alwaysinline",
InlineHint: "inlinehint",
}[inline]
inlineAttr := p.Pkg.mod.Context().CreateEnumAttribute(llvm.AttributeKindID(inlineAttrName), 0)
p.impl.AddFunctionAttr(inlineAttr)
}
// -----------------------------------------------------------------------------