diff options
author | Xan Phung <xan.phung@gmail.com> | 2020-01-23 16:27:41 +0800 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-01-29 07:59:33 +0100 |
commit | 1dc00f876305b6a4d3dda38889a9165ff4bf1b0b (patch) | |
tree | 48fd75f319b1168a6c83c1a82249f45a6951bea2 | |
parent | 47b6dfef9d8d581fbe83ee50bc737be01a9a0748 (diff) | |
download | sparse-1dc00f876305b6a4d3dda38889a9165ff4bf1b0b.tar.gz |
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>
-rw-r--r-- | flowgraph.c | 4 |
1 files changed, 4 insertions, 0 deletions
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]; |