tree-optimization/106881 - constrain uninit control edge add
Commit Message
The following avoids adding fallthru edges to the control chain from
the post-dominator walk.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
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.
---
gcc/gimple-predicate-analysis.cc | 9 ++++++---
gcc/testsuite/gcc.dg/uninit-pr106881.c | 16 ++++++++++++++++
2 files changed, 22 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/uninit-pr106881.c
@@ -1065,9 +1065,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;
new file mode 100644
@@ -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();
+}