From: Richard Biener Date: Thu, 8 Sep 2022 10:22:26 +0000 (+0200) Subject: tree-optimization/106881 - constrain uninit control edge add X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8d3b44dfa2851659f966627835497667c5fed6c;p=platform%2Fupstream%2Fgcc.git tree-optimization/106881 - constrain uninit control edge add The following avoids adding fallthru edges to the control chain from the post-dominator walk. PR tree-optimization/106881 * gimple-predicate-analysis.cc (compute_control_dep_chain_pdom): Add only non-fallthru edges and avoid the same set of edges as the caller does. * gcc.dg/uninit-pr106881.c: New testcase. --- diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index f81af25..910ab97 100644 --- a/gcc/gimple-predicate-analysis.cc +++ b/gcc/gimple-predicate-analysis.cc @@ -1060,9 +1060,12 @@ compute_control_dep_chain_pdom (basic_block cd_bb, const_basic_block dep_bb, gcc.dg/unninit-pred-12.c and PR106754. */ if (single_pred_p (cd_bb)) { - edge e2 = find_edge (prev_cd_bb, cd_bb); - gcc_assert (e2); - cur_cd_chain.safe_push (e2); + edge e2 = single_pred_edge (cd_bb); + gcc_assert (e2->src == prev_cd_bb); + /* But avoid adding fallthru or abnormal edges. */ + if (!(e2->flags & (EDGE_FAKE | EDGE_ABNORMAL | EDGE_DFS_BACK)) + && !single_succ_p (prev_cd_bb)) + cur_cd_chain.safe_push (e2); } } return found_cd_chain; diff --git a/gcc/testsuite/gcc.dg/uninit-pr106881.c b/gcc/testsuite/gcc.dg/uninit-pr106881.c new file mode 100644 index 0000000..343b13e --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-pr106881.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fexceptions -Wuninitialized" } */ + +void l_free (void *); +char *l_settings_get_string (); +void eap_append_secret (); +inline void auto_free(void *a) { + void **p = a; + l_free(*p); /* { dg-warning "uninitialized" } */ +} +void eap_gtc_check_settings() { + char *identity __attribute__((cleanup(auto_free))); + char password __attribute__((cleanup(auto_free))); + identity = l_settings_get_string(); + eap_append_secret(); +}