From 8e6f364351e52ff58ad518e76dab4a4cda9adee9 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 22 May 2018 12:42:11 -0400
Subject: [PATCH 16/24] FIXME: use optinfo in various other places

---
 gcc/domwalk.c            |  8 ++++++++
 gcc/gimple-ssa-evrp.c    |  6 ++++++
 gcc/gimple-ssa-sprintf.c | 14 ++++++++++++++
 gcc/tree-ssa-dce.c       |  6 ++++++
 gcc/tree-ssa-dom.c       | 19 +++++++++++++++++++
 gcc/tree-ssa-dse.c       |  9 +++++++++
 gcc/tree-ssa-sccvn.c     |  8 ++++++++
 gcc/tree-tailcall.c      |  6 ++++++
 8 files changed, 76 insertions(+)

diff --git a/gcc/domwalk.c b/gcc/domwalk.c
index 2791e93..7334d14 100644
--- a/gcc/domwalk.c
+++ b/gcc/domwalk.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cfganal.h"
 #include "domwalk.h"
 #include "dumpfile.h"
+#include "optinfo.h"
 
 /* This file implements a generic walker for dominator trees.
 
@@ -301,6 +302,13 @@ dom_walker::propagate_unreachable_to_edges (basic_block bb,
   if (dump_file && (dump_flags & TDF_DETAILS))
     fprintf (dump_file, "Marking all outgoing edges of unreachable "
 	     "BB %d as not executable\n", bb->index);
+  /* FIXME.  */
+  if (optinfo_enabled_p ())
+    {
+      OPTINFO_SUCCESS (bb)
+	<< optinfo_printf ("marking all outgoing edges of unreachable "
+			   "BB %d as not executable", bb->index);
+    }
 
   edge_iterator ei;
   edge e;
diff --git a/gcc/gimple-ssa-evrp.c b/gcc/gimple-ssa-evrp.c
index c9bbf09..c95c1e8 100644
--- a/gcc/gimple-ssa-evrp.c
+++ b/gcc/gimple-ssa-evrp.c
@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-cfgcleanup.h"
 #include "vr-values.h"
 #include "gimple-ssa-evrp-analyze.h"
+#include "optinfo.h"
 
 class evrp_folder : public substitute_and_fold_engine
 {
@@ -256,6 +257,11 @@ evrp_dom_walker::cleanup (void)
 	  print_gimple_stmt (dump_file, stmt, 0);
 	  fprintf (dump_file, "\n");
 	}
+      /* FIXME.  */
+      if (optinfo_enabled_p ())
+	OPTINFO_SUCCESS (stmt)
+	  << "removing dead stmt: "
+	  << stmt;
       gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
       if (gimple_code (stmt) == GIMPLE_PHI)
 	remove_phi_node (&gsi, true);
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index 4ec5860..d808341 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -83,6 +83,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "alloc-pool.h"
 #include "vr-values.h"
 #include "gimple-ssa-evrp-analyze.h"
+#include "optinfo.h"
 
 /* The likely worst case value of MB_LEN_MAX for the target, large enough
    for UTF-8.  Ideally, this would be obtained by a target hook if it were
@@ -3667,6 +3668,19 @@ try_substitute_return_value (gimple_stmt_iterator *gsi,
 		       info.nowrite ? "statement" : "return value");
 	    }
 	}
+      /* FIXME.  */
+      if (optinfo_enabled_p ())
+	{
+	  pending_optinfo inf = OPTINFO_SUCCESS (info.callstmt);
+	  if (removed)
+	    inf << "removing call statement: " << info.callstmt;
+	  else
+	    {
+	      inf << "substituting " << slim (cst)
+		  << optinfo_printf (" for %s",
+				     info.nowrite ? "statement" : "return value");
+	    }
+	}
     }
   else if (lhs)
     {
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index 7ec3cc1..7824f05 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -68,6 +68,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-chkp.h"
 #include "tree-ssa-propagate.h"
 #include "gimple-fold.h"
+#include "optinfo.h"
 
 static struct stmt_stats
 {
@@ -1761,6 +1762,11 @@ simple_dce_from_worklist (bitmap worklist)
 	  fprintf (dump_file, "Removing dead stmt:");
 	  print_gimple_stmt (dump_file, t, 0);
 	}
+      /* FIXME */
+      if (optinfo_enabled_p ())
+	OPTINFO_SUCCESS (t)
+	  << "removing dead stmt: " << t;
+
       gimple_stmt_iterator gsi = gsi_for_stmt (t);
       if (gimple_code (t) == GIMPLE_PHI)
 	remove_phi_node (&gsi, true);
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index a6f176c..2147ac6 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -50,6 +50,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-vrp.h"
 #include "vr-values.h"
 #include "gimple-ssa-evrp-analyze.h"
+#include "optinfo.h"
 
 /* This file implements optimizations on the dominator tree.  */
 
@@ -1564,6 +1565,13 @@ eliminate_redundant_computations (gimple_stmt_iterator* gsi,
 	  print_generic_expr (dump_file, cached_lhs, dump_flags);
           fprintf (dump_file, "'\n");
 	}
+      /* FIXME */
+      if (optinfo_enabled_p ())
+	OPTINFO_SUCCESS (stmt)
+	  << "replaced redundant expr "
+	  << stmt
+	  << " with "
+	  << slim (cached_lhs);
 
       opt_stats.num_re++;
 
@@ -1743,6 +1751,17 @@ cprop_operand (gimple *stmt, use_operand_p op_p)
 	  print_generic_expr (dump_file, val, dump_flags);
 	  fprintf (dump_file, "'\n");
 	}
+#if 0
+      /* FIXME */
+      if (optinfo_enabled_p ())
+	OPTINFO_SUCCESS (stmt)
+	  << "replaced "
+	  << slim (op)
+	  << optinfo_printf (" with %s ",
+			     (TREE_CODE (val) != SSA_NAME
+			      ? "constant" : "variable"))
+	  << slim (val);
+#endif
 
       if (TREE_CODE (val) != SSA_NAME)
 	opt_stats.num_const_prop++;
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index 9220fea..8b58518 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-cfgcleanup.h"
 #include "params.h"
 #include "alias.h"
+#include "optinfo.h"
 
 /* This file implements dead store elimination.
 
@@ -696,6 +697,10 @@ delete_dead_call (gimple_stmt_iterator *gsi)
       print_gimple_stmt (dump_file, stmt, 0, dump_flags);
       fprintf (dump_file, "\n");
     }
+  /* FIXME */
+  if (optinfo_enabled_p ())
+    OPTINFO_SUCCESS (stmt)
+      << "deleted dead call: " << stmt;
 
   tree lhs = gimple_call_lhs (stmt);
   if (lhs)
@@ -730,6 +735,10 @@ delete_dead_assignment (gimple_stmt_iterator *gsi)
       print_gimple_stmt (dump_file, stmt, 0, dump_flags);
       fprintf (dump_file, "\n");
     }
+  /* FIXME */
+  if (optinfo_enabled_p ())
+    OPTINFO_SUCCESS (stmt)
+      << "deleted dead store: " << stmt;
 
   /* Then we need to fix the operand of the consuming stmt.  */
   unlink_stmt_vdef (stmt);
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index d8ab1f0..a94fed1 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -70,6 +70,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-ssa-loop.h"
 #include "tree-scalar-evolution.h"
 #include "tree-ssa-sccvn.h"
+#include "optinfo.h"
 
 /* This algorithm is based on the SCC algorithm presented by Keith
    Cooper and L. Taylor Simpson in "SCC-Based Value numbering"
@@ -4042,6 +4043,13 @@ visit_use (tree use)
 	      print_generic_expr (dump_file, simplified);
 	      fprintf (dump_file, "\n");
 	    }
+	  /* FIXME.  */
+	  if (optinfo_enabled_p ())
+	    OPTINFO_SUCCESS (ass)
+	      << "RHS "
+	      << ass
+	      << " simplified to "
+	      << slim (simplified);
 	}
       /* Setting value numbers to constants will occasionally
 	 screw up phi congruence because constants are not
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index 9ebed9d..2a072aa 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cfgloop.h"
 #include "common/common-target.h"
 #include "ipa-utils.h"
+#include "optinfo.h"
 
 /* The file implements the tail recursion elimination.  It is also used to
    analyze the tail calls in general, passing the results to the rtl level
@@ -861,6 +862,11 @@ eliminate_tail_call (struct tailcall *t)
       print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
       fprintf (dump_file, "\n");
     }
+  /* FIXME.  */
+  if (optinfo_enabled_p ())
+    OPTINFO_SUCCESS (stmt)
+      << "eliminated tail recursion: "
+      << stmt;
 
   gcc_assert (is_gimple_call (stmt));
 
-- 
1.8.5.3

