From d676e847e2148df972adf5b72c7a1309a531d02a Mon Sep 17 00:00:00 2001 From: Zhijin Zeng Date: Fri, 10 Nov 2023 11:38:31 +0800 Subject: [PATCH] fix issue #38 for if-convert 1. the be will crash if compile the code like that: ``` int sre_random(void) { long rnd1; static long tbl[64]; int i; for (i = 0; i < 64; i++) { tbl[i] = rnd1; if (tbl[i] < 0) tbl[i] += 0; } return 0; } ``` Signed-off-by: Zhijin Zeng --- osprey/be/opt/opt_cfg.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osprey/be/opt/opt_cfg.cxx b/osprey/be/opt/opt_cfg.cxx index fb83e097..86e8b136 100644 --- a/osprey/be/opt/opt_cfg.cxx +++ b/osprey/be/opt/opt_cfg.cxx @@ -1983,6 +1983,13 @@ CFG::if_convert(WN *wn) WN_kid0(store) = sel; WN_Set_Linenum(store, WN_Get_Linenum(wn)); + if (empty_then ? then_wn : else_wn) { + if (WN * other_stmt = WN_first(empty_then ? then_wn : else_wn)) { + INT32 vertex = WN_get_dep_graph_vertex(other_stmt); + WN_detach_wn_from_dep_graph(vertex); + } + } + WN *block = WN_CreateBlock(); WN_INSERT_BlockFirst(block, store); if (if_select_return) {