From 1dc00f876305b6a4d3dda38889a9165ff4bf1b0b Mon Sep 17 00:00:00 2001 From: Xan Phung Date: Thu, 23 Jan 2020 16:27:41 +0800 Subject: 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 Signed-off-by: Luc Van Oostenryck --- flowgraph.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flowgraph.c b/flowgraph.c index 8fc22dcf..73c29fc9 100644 --- a/flowgraph.c +++ b/flowgraph.c @@ -166,6 +166,10 @@ void domtree_build(struct entrypoint *ep) } 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]; -- cgit 1.2.3-korg