ssa: make block with label name for debug readable
This commit is contained in:
@@ -318,7 +318,7 @@ func (p *context) compileBlock(b llssa.Builder, block *ssa.BasicBlock, n int, do
|
|||||||
modPtr := pkg.PyNewModVar(modName, true).Expr
|
modPtr := pkg.PyNewModVar(modName, true).Expr
|
||||||
mod := b.Load(modPtr)
|
mod := b.Load(modPtr)
|
||||||
cond := b.BinOp(token.NEQ, mod, prog.Nil(mod.Type))
|
cond := b.BinOp(token.NEQ, mod, prog.Nil(mod.Type))
|
||||||
newBlk := fn.MakeBlock()
|
newBlk := fn.MakeBlock("")
|
||||||
b.If(cond, jumpTo, newBlk)
|
b.If(cond, jumpTo, newBlk)
|
||||||
b.SetBlockEx(newBlk, llssa.AtEnd, false)
|
b.SetBlockEx(newBlk, llssa.AtEnd, false)
|
||||||
b.Store(modPtr, b.PyImportMod(modPath))
|
b.Store(modPtr, b.PyImportMod(modPath))
|
||||||
|
|||||||
12
ssa/decl.go
12
ssa/decl.go
@@ -293,13 +293,15 @@ func (p Function) MakeBlocks(nblk int) []BasicBlock {
|
|||||||
p.blks = make([]BasicBlock, 0, nblk)
|
p.blks = make([]BasicBlock, 0, nblk)
|
||||||
}
|
}
|
||||||
for i := 0; i < nblk; i++ {
|
for i := 0; i < nblk; i++ {
|
||||||
p.addBlock(n + i)
|
p.addBlock(n+i, "")
|
||||||
}
|
}
|
||||||
return p.blks[n:]
|
return p.blks[n:]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Function) addBlock(idx int) BasicBlock {
|
func (p Function) addBlock(idx int, label string) BasicBlock {
|
||||||
label := "_llgo_" + strconv.Itoa(idx)
|
if label == "" {
|
||||||
|
label = "_llgo_" + strconv.Itoa(idx)
|
||||||
|
}
|
||||||
blk := llvm.AddBasicBlock(p.impl, label)
|
blk := llvm.AddBasicBlock(p.impl, label)
|
||||||
ret := &aBasicBlock{blk, blk, p, idx}
|
ret := &aBasicBlock{blk, blk, p, idx}
|
||||||
p.blks = append(p.blks, ret)
|
p.blks = append(p.blks, ret)
|
||||||
@@ -307,8 +309,8 @@ func (p Function) addBlock(idx int) BasicBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MakeBlock creates a new basic block for the function.
|
// MakeBlock creates a new basic block for the function.
|
||||||
func (p Function) MakeBlock() BasicBlock {
|
func (p Function) MakeBlock(label string) BasicBlock {
|
||||||
return p.addBlock(len(p.blks))
|
return p.addBlock(len(p.blks), label)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block returns the ith basic block of the function.
|
// Block returns the ith basic block of the function.
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ func (b Builder) getDefer(kind DoAction) *aDefer {
|
|||||||
czero := prog.IntVal(0, prog.CInt())
|
czero := prog.IntVal(0, prog.CInt())
|
||||||
retval := b.Sigsetjmp(jb, czero)
|
retval := b.Sigsetjmp(jb, czero)
|
||||||
if kind != DeferAlways {
|
if kind != DeferAlways {
|
||||||
rundBlk = self.MakeBlock()
|
rundBlk = self.MakeBlock("")
|
||||||
} else {
|
} else {
|
||||||
blks = self.MakeBlocks(2)
|
blks = self.MakeBlocks(2)
|
||||||
next, rundBlk = blks[0], blks[1]
|
next, rundBlk = blks[0], blks[1]
|
||||||
@@ -228,7 +228,7 @@ func (b Builder) Defer(kind DoAction, fn Expr, args ...Expr) {
|
|||||||
// RunDefers emits instructions to run deferred instructions.
|
// RunDefers emits instructions to run deferred instructions.
|
||||||
func (b Builder) RunDefers() {
|
func (b Builder) RunDefers() {
|
||||||
self := b.getDefer(DeferInCond)
|
self := b.getDefer(DeferInCond)
|
||||||
blk := b.Func.MakeBlock()
|
blk := b.Func.MakeBlock("")
|
||||||
self.runsNext = append(self.runsNext, blk)
|
self.runsNext = append(self.runsNext, blk)
|
||||||
|
|
||||||
b.Store(self.rundPtr, blk.Addr())
|
b.Store(self.rundPtr, blk.Addr())
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ func (b Builder) setBlockMoveLast(blk BasicBlock) (next BasicBlock) {
|
|||||||
|
|
||||||
impl := b.impl
|
impl := b.impl
|
||||||
|
|
||||||
next = b.Func.MakeBlock()
|
next = b.Func.MakeBlock("")
|
||||||
impl.SetInsertPointAtEnd(next.last)
|
impl.SetInsertPointAtEnd(next.last)
|
||||||
impl.Insert(last)
|
impl.Insert(last)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user