domtree: domtree_build() creates extraneous bb->doms entries

Each time domtree_build gets called, extraneous/duplicated child nodes
get left in the bb->doms ptrlist. This is because the existing children
are not cleared from bb->doms before rebuilding it.

In addition to consuming memory, the extraneous child nodes result
in a malformed dominance tree.

The following 3 line patch fixes this problem by freeing the dominator
tree before rebuilding it.

Signed-off-by: Xan Phung <xan.phung@gmail.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
diff --git a/flowgraph.c b/flowgraph.c
index 8fc22dc..73c29fc 100644
--- a/flowgraph.c
+++ b/flowgraph.c
@@ -166,6 +166,10 @@
 		} END_FOR_EACH_PTR(b);
 	} while (changed);
 
+	FOR_EACH_PTR(ep->bbs, bb) {
+		free_ptr_list(&bb->doms);
+	} END_FOR_EACH_PTR(bb);
+
 	// set the idom links
 	FOR_EACH_PTR(ep->bbs, bb) {
 		struct basic_block *idom = doms[bb->postorder_nr];