On Wed, Aug 16, 2017 at 11:34 AM, Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> wrote: > > +pseudo_t insert_phi_node(struct basic_block *bb, struct symbol *type) > +{ > + struct instruction *phi_node = alloc_typed_instruction(OP_PHI, type); > + struct instruction *insn; > + pseudo_t phi; > + > + phi = alloc_pseudo(phi_node); > + phi_node->target = phi; > + phi_node->bb = bb; > + > + FOR_EACH_PTR(bb->insns, insn) { > + enum opcode op = insn->opcode; > + if (op == OP_ENTRY || op == OP_PHI) > + continue; > + INSERT_CURRENT(phi_node, insn); You do need to preserve the order of the phi node, right? At first I was thinking always insert the phi at the first instruction. Then I realized that, it is possible some phi node use some other phi node as source in case of a loop. So the order does need to be preserved some how. > + return phi; > + } END_FOR_EACH_PTR(insn); > + > + add_instruction(&bb->insns, phi_node); > + return phi; > +} > + Chris -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html