llgo/ssa.Phi: AddIncoming fix

This commit is contained in:
xushiwei
2024-05-24 09:20:58 +08:00
parent 97e38255c6
commit 056ad51c24
12 changed files with 555 additions and 470 deletions

View File

@@ -274,7 +274,7 @@ func (p Function) NewBuilder() Builder {
b := prog.ctx.NewBuilder()
// TODO(xsw): Finalize may cause panic, so comment it.
// b.Finalize()
return &aBuilder{b, p, p.Pkg, prog}
return &aBuilder{b, nil, p, p.Pkg, prog}
}
// HasBody reports whether the function has a body.
@@ -287,7 +287,7 @@ func (p Function) HasBody() bool {
func (p Function) MakeBody(nblk int) Builder {
p.MakeBlocks(nblk)
b := p.NewBuilder()
b.impl.SetInsertPointAtEnd(p.blks[0].impl)
b.impl.SetInsertPointAtEnd(p.blks[0].last)
return b
}
@@ -306,7 +306,7 @@ func (p Function) MakeBlocks(nblk int) []BasicBlock {
func (p Function) addBlock(idx int) BasicBlock {
label := "_llgo_" + strconv.Itoa(idx)
blk := llvm.AddBasicBlock(p.impl, label)
ret := &aBasicBlock{blk, p, idx}
ret := &aBasicBlock{blk, blk, p, idx}
p.blks = append(p.blks, ret)
return ret
}