diff mbox series

[3/4] Diagnostic passes adjustments

Message ID 20220204134926.D470013A96@imap2.suse-dmz.suse.de
State New
Headers show
Series [1/4,RFC] middle-end/90348 - add explicit birth | expand

Commit Message

Richard Biener Feb. 4, 2022, 1:49 p.m. UTC
This adjusts diagnostic passes for the birth CLOBBERs where
necessary.  In particular the uninit diagnostics relies on particular
shaped IL to simplify the expression printed (to be cleaned up independently)
in gcc.dg/pr86058.c.

2022-02-02  Richard Biener  <rguenther@suse.de>

	* tree-ssa-uninit.cc (check_defs_data::found_full_clobber):
	New member.
	(check_defs): Set it.
	(maybe_warn_operand): Use it to treat expression simplification
	the same way as when the function entry was reached.
---
 gcc/tree-ssa-uninit.cc | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/gcc/tree-ssa-uninit.cc b/gcc/tree-ssa-uninit.cc
index 02e88d58e1f..f2b15439113 100644
--- a/gcc/tree-ssa-uninit.cc
+++ b/gcc/tree-ssa-uninit.cc
@@ -319,6 +319,8 @@  struct check_defs_data
 {
   /* If we found any may-defs besides must-def clobbers.  */
   bool found_may_defs;
+  /* If we found a GIMPLE clobber that made the whole ref undefined.  */
+  bool found_full_clobber;
 };
 
 /* Return true if STMT is a call to built-in function all of whose
@@ -501,7 +503,10 @@  check_defs (ao_ref *ref, tree vdef, void *data_)
   if (gimple_clobber_p (def_stmt))
     {
       if (stmt_kills_ref_p (def_stmt, ref))
-	return true;
+	{
+	  data->found_full_clobber = true;
+	  return true;
+	}
       return false;
     }
 
@@ -601,6 +606,7 @@  maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs,
   check_defs_data data;
   bool fentry_reached = false;
   data.found_may_defs = false;
+  data.found_full_clobber = false;
   tree use = gimple_vuse (stmt);
   if (!use)
     return NULL_TREE;
@@ -666,7 +672,10 @@  maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs,
 	  if (tree ba = get_base_address (base))
 	    base = ba;
 	}
+    }
 
+  if (fentry_reached || data.found_full_clobber)
+    {
       /* Replace the RHS expression with BASE so that it
 	 refers to it in the diagnostic (instead of to
 	 '<unknown>').  */