This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Enable ipa-cp with -fwhopr


Hi,
this patch enables the ipa-cp at WHOPR.  This makes WHOPR IPA infrasructure
complette.  We still need paralellizing of the build and some extra features,
but it should now work as well (or as badly) as -flto.

PTA and struct-reorg are small ipa passes, I will move them to the beggining
of local compilation so they will work at ltrans units instead of whole
program until we get full IPA implementation.

The patch also fixes omission in ipa_detect_param_modifications where we did not
look into phi nodes that might contain addresses of non-gimples.

I've also added a testcase that tests that clonning and decl merging work
as expected.

Bootstrapped/regtested x86_64-linux. Will commit it after some further testing on
-fwhopr builds.

Honza

	* gcc.dg/lto/ipacp_0.c: New test.
	* gcc.dg/lto/ipacp_1.c: New test.

	* opts.c (decode_options): Do not disable whopr at ipa_cp.
	* ipa-prop.c (ipa_detect_param_modifications): Walk PHI nodes too.
Index: testsuite/gcc.dg/lto/ipacp_0.c
===================================================================
--- testsuite/gcc.dg/lto/ipacp_0.c	(revision 0)
+++ testsuite/gcc.dg/lto/ipacp_0.c	(revision 0)
@@ -0,0 +1,14 @@
+/* { dg-lto-options {{ -O1 -fwhopr -fipa-cp -fipa-cp-clone}} } */
+/* { dg-lto-do run } */
+
+/* Test that clonning happens and we unify declarations of a from both units.  */
+const int a = 5;
+extern void clone_me (int *);
+
+void
+main(void)
+{
+  int i;
+  for (i=0;i<100;i++)
+   clone_me ((int *)&a);
+}
Index: testsuite/gcc.dg/lto/ipacp_1.c
===================================================================
--- testsuite/gcc.dg/lto/ipacp_1.c	(revision 0)
+++ testsuite/gcc.dg/lto/ipacp_1.c	(revision 0)
@@ -0,0 +1,12 @@
+void abort (void);
+extern int a;
+
+__attribute__ ((noinline))
+void
+clone_me (int *ptr)
+{
+  if (ptr != &a)
+    abort ();
+  if (!__builtin_constant_p (ptr != &a))
+    abort ();
+}
Index: opts.c
===================================================================
--- opts.c	(revision 159527)
+++ opts.c	(working copy)
@@ -1150,7 +1150,6 @@ decode_options (unsigned int argc, const
   if (flag_wpa || flag_ltrans)
     {
       /* These passes are not WHOPR compatible yet.  */
-      flag_ipa_cp = 0;
       flag_ipa_pta = 0;
       flag_ipa_struct_reorg = 0;
     }
Index: ipa-prop.c
===================================================================
--- ipa-prop.c	(revision 159527)
+++ ipa-prop.c	(working copy)
@@ -269,11 +269,18 @@ ipa_detect_param_modifications (struct c
 
   func = DECL_STRUCT_FUNCTION (decl);
   FOR_EACH_BB_FN (bb, func)
-    for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-      walk_stmt_load_store_addr_ops (gsi_stmt (gsi), info,
-				     visit_load_for_mod_analysis,
-				     visit_store_addr_for_mod_analysis,
-				     visit_store_addr_for_mod_analysis);
+    {
+      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+	walk_stmt_load_store_addr_ops (gsi_stmt (gsi), info,
+				       visit_load_for_mod_analysis,
+				       visit_store_addr_for_mod_analysis,
+				       visit_store_addr_for_mod_analysis);
+      for (gsi = gsi_start (phi_nodes (bb)); !gsi_end_p (gsi); gsi_next (&gsi))
+	walk_stmt_load_store_addr_ops (gsi_stmt (gsi), info,
+				       visit_load_for_mod_analysis,
+				       visit_store_addr_for_mod_analysis,
+				       visit_store_addr_for_mod_analysis);
+    }
 
   info->modification_analysis_done = 1;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]