summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndreas Fried <andreas.fried@kit.edu>2021-11-23 14:40:13 +0100
committerAndreas Fried <andreas.fried@kit.edu>2021-11-23 14:40:13 +0100
commit388dbd418e85184c775171795b0ce8cdfd2f98a4 (patch)
tree3fd46b4b47754ee82a1feb081b08f0245a400d6f
parent9f0e6d3bb0708f4fba8ababc714a241af7f6ac17 (diff)
Prevent infinite loop in irgopt for invalid graphs.HEADmaster
If the End Block of a graph is unreachable by control flow due to wrong graph construction, optimize_graph_df runs into an infinite loop trying to remove the End Block. This adds commit adds a debug-only panic to catch that situation.
-rw-r--r--ir/opt/irgopt.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ir/opt/irgopt.c b/ir/opt/irgopt.c
index cf88a02..7f9e71b 100644
--- a/ir/opt/irgopt.c
+++ b/ir/opt/irgopt.c
@@ -105,6 +105,12 @@ static void find_unreachable_blocks(ir_node *block, void *env)
if (get_Block_dom_depth(block) >= 0)
return;
+#ifdef DEBUG_libfirm
+ if (block == get_irg_end_block(get_irn_irg(block))) {
+ panic("Control flow does not reach the end block.");
+ }
+#endif
+
deq_t *waitq = (deq_t *)env;
foreach_block_succ(block, edge) {
ir_node *succ_block = get_edge_src_irn(edge);