Exemple #1
0
func printIdom(b *ssa.BasicBlock, out *bytes.Buffer) {
	if b.Index == 0 {
		out.WriteString("Basic Block has no idom because it is a entry node.")
		return
	}
	if b == b.Parent().Recover {
		out.WriteString("Basic Block has no idom because it is a recover node")
		return
	}
	out.WriteString("  Idom of ")
	out.WriteString(strconv.Itoa(b.Index))
	out.WriteString(" is: ")
	out.WriteString(strconv.Itoa(b.Idom().Index))
	out.WriteString("\n")
}
Exemple #2
0
func visitBlock(blk *ssa.BasicBlock, fr *frame) {
	if len(blk.Preds) > 1 {
		blkLabel := fmt.Sprintf("%s#%d", blk.Parent().String(), blk.Index)

		if _, found := fr.gortn.visited[blk]; found {
			fr.gortn.AddNode(sesstype.NewGotoNode(blkLabel))
			return
		}
		// Make a label for other edges that enter this block
		label := sesstype.NewLabelNode(blkLabel)
		fr.gortn.AddNode(label)
		fr.gortn.visited[blk] = label // XXX visited is initialised by append if lblNode is head of tree
	}

	for _, inst := range blk.Instrs {
		visitInst(inst, fr)
	}
}