ssa: TestIf

This commit is contained in:
xushiwei
2024-04-20 19:53:00 +08:00
parent 905c05e099
commit 55a757b9f8
4 changed files with 120 additions and 42 deletions

View File

@@ -61,17 +61,15 @@ func (p *context) compileFunc(pkg llssa.Package, f *ssa.Function) {
defer func() {
p.fn = nil
}()
if f.Blocks == nil { // external function
nblk := len(f.Blocks)
if nblk == 0 { // external function
return
}
b := fn.MakeBody("")
for _, block := range f.Blocks {
p.compileBlock(b, block)
}
b := fn.MakeBody(nblk)
p.compileBlock(b, f.Blocks[0])
}
func (p *context) compileBlock(b llssa.Builder, block *ssa.BasicBlock) {
_ = block.Index
for _, instr := range block.Instrs {
p.compileInstr(b, instr)
}