public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/pheeck/heads/sccp)] fixed segfault, tarjan works
@ 2022-07-17  7:55 Filip Kastl
  0 siblings, 0 replies; 2+ messages in thread
From: Filip Kastl @ 2022-07-17  7:55 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:059c7ef6f85a3014c1757a8de111304d12b87288

commit 059c7ef6f85a3014c1757a8de111304d12b87288
Author: Filip Kastl <filip.kastl@gmail.com>
Date:   Sun Jul 17 09:52:00 2022 +0200

    fixed segfault, tarjan works

Diff:
---
 gcc/sccp.cc | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/gcc/sccp.cc b/gcc/sccp.cc
index 23a7a38d941..ea4a5d2fc84 100644
--- a/gcc/sccp.cc
+++ b/gcc/sccp.cc
@@ -34,7 +34,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple-pretty-print.h"
 #include "vec.h"
 #include "libiberty.h"
-#include <algorithm>
+
+#include "print-tree.h"
+#include "dumpfile.h"
 
 // TODO Imported for global var num_ssa_names to work
 #include "backend.h"
@@ -68,7 +70,7 @@ struct vertex
 /* Each SSA name corresponds to a vertex.  Indexed by SSA version number.  */
 static *vertices;
 /* Each SCC is a vector of version nums.  */
-static vec<vec<unsigned>*> tarjan_sccs;
+static vec<vec<unsigned>*> tarjan_sccs; // TODO Correct * style?
 static vec<unsigned> tarjan_stack;
 static unsigned tarjan_index = 0;
 
@@ -95,6 +97,7 @@ tarjan_assign_index (unsigned vnum)
 {
   vertices[vnum].index = tarjan_index;
   vertices[vnum].lowlink = tarjan_index;
+  vertices[vnum].visited = true;
   tarjan_index++;
 }
 
@@ -115,7 +118,7 @@ tarjan_update_lowlink (unsigned vnum, unsigned new_lowlink)
 static void
 tarjan_strongconnect (gphi *phi)
 {
-  tree foo = gimple_vdef (phi); // TODO Name.  Do I want vuse?
+  tree foo = gimple_get_lhs (phi); // TODO foo
   unsigned vnum = SSA_NAME_VERSION (foo);
 
   tarjan_assign_index (vnum);
@@ -174,9 +177,11 @@ tarjan_compute_sccs (void)
       for (pi = gsi_start_phis (bb); !gsi_end_p (pi); gsi_next (&pi))
 	{
 	  gphi *phi = pi.phi ();
-	  tree foo = gimple_vdef (phi); // TODO Name
+	  tree foo = gimple_get_lhs (phi); // TODO foo
+	  //fprintf (dump_file, "ahoj\n"); // DEBUG, use -fdump-tree-sccp
+	  //debug_tree (foo); // DEBUG
 	  unsigned vnum = SSA_NAME_VERSION (foo);
-	  // TODO Filtrovat stmts jako v copyprop
+	  // TODO Filtrovat stmts jako v copyprop?
 	  if (!vertices[vnum].visited)
 	    {
 	      tarjan_strongconnect (phi);
@@ -217,9 +222,27 @@ public:
 unsigned
 pass_sccp::execute (function *)
 {
+  // DEBUG
+  /*
+  basic_block bb;
+  FOR_EACH_BB_FN (bb, cfun)
+    {
+      debug_bb (bb);
+      gphi_iterator pi;
+      std::cerr << "PHI LIST" << std::endl;
+      for (pi = gsi_start_phis (bb); !gsi_end_p (pi); gsi_next (&pi))
+	{
+	  gphi *phi = pi.phi ();
+	  debug_gimple_stmt (phi);
+	}
+      std::cerr << std::endl << std::endl;
+    }
+  */
+
   init_sccp ();
   tarjan_compute_sccs ();
 
+  std::cerr << "ahoj" << std::endl;
   for (vec<unsigned> *scc : tarjan_sccs)
     {
       for (unsigned phi : *scc)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/users/pheeck/heads/sccp)] fixed segfault, tarjan works
@ 2023-02-15 10:13 Filip Kastl
  0 siblings, 0 replies; 2+ messages in thread
From: Filip Kastl @ 2023-02-15 10:13 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1053d91dd8f0916d82c1f968fd06d3e095d5bd3a

commit 1053d91dd8f0916d82c1f968fd06d3e095d5bd3a
Author: Filip Kastl <filip.kastl@gmail.com>
Date:   Sun Jul 17 09:52:00 2022 +0200

    fixed segfault, tarjan works

Diff:
---
 gcc/sccp.cc | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/gcc/sccp.cc b/gcc/sccp.cc
index 23a7a38d941..ea4a5d2fc84 100644
--- a/gcc/sccp.cc
+++ b/gcc/sccp.cc
@@ -34,7 +34,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple-pretty-print.h"
 #include "vec.h"
 #include "libiberty.h"
-#include <algorithm>
+
+#include "print-tree.h"
+#include "dumpfile.h"
 
 // TODO Imported for global var num_ssa_names to work
 #include "backend.h"
@@ -68,7 +70,7 @@ struct vertex
 /* Each SSA name corresponds to a vertex.  Indexed by SSA version number.  */
 static *vertices;
 /* Each SCC is a vector of version nums.  */
-static vec<vec<unsigned>*> tarjan_sccs;
+static vec<vec<unsigned>*> tarjan_sccs; // TODO Correct * style?
 static vec<unsigned> tarjan_stack;
 static unsigned tarjan_index = 0;
 
@@ -95,6 +97,7 @@ tarjan_assign_index (unsigned vnum)
 {
   vertices[vnum].index = tarjan_index;
   vertices[vnum].lowlink = tarjan_index;
+  vertices[vnum].visited = true;
   tarjan_index++;
 }
 
@@ -115,7 +118,7 @@ tarjan_update_lowlink (unsigned vnum, unsigned new_lowlink)
 static void
 tarjan_strongconnect (gphi *phi)
 {
-  tree foo = gimple_vdef (phi); // TODO Name.  Do I want vuse?
+  tree foo = gimple_get_lhs (phi); // TODO foo
   unsigned vnum = SSA_NAME_VERSION (foo);
 
   tarjan_assign_index (vnum);
@@ -174,9 +177,11 @@ tarjan_compute_sccs (void)
       for (pi = gsi_start_phis (bb); !gsi_end_p (pi); gsi_next (&pi))
 	{
 	  gphi *phi = pi.phi ();
-	  tree foo = gimple_vdef (phi); // TODO Name
+	  tree foo = gimple_get_lhs (phi); // TODO foo
+	  //fprintf (dump_file, "ahoj\n"); // DEBUG, use -fdump-tree-sccp
+	  //debug_tree (foo); // DEBUG
 	  unsigned vnum = SSA_NAME_VERSION (foo);
-	  // TODO Filtrovat stmts jako v copyprop
+	  // TODO Filtrovat stmts jako v copyprop?
 	  if (!vertices[vnum].visited)
 	    {
 	      tarjan_strongconnect (phi);
@@ -217,9 +222,27 @@ public:
 unsigned
 pass_sccp::execute (function *)
 {
+  // DEBUG
+  /*
+  basic_block bb;
+  FOR_EACH_BB_FN (bb, cfun)
+    {
+      debug_bb (bb);
+      gphi_iterator pi;
+      std::cerr << "PHI LIST" << std::endl;
+      for (pi = gsi_start_phis (bb); !gsi_end_p (pi); gsi_next (&pi))
+	{
+	  gphi *phi = pi.phi ();
+	  debug_gimple_stmt (phi);
+	}
+      std::cerr << std::endl << std::endl;
+    }
+  */
+
   init_sccp ();
   tarjan_compute_sccs ();
 
+  std::cerr << "ahoj" << std::endl;
   for (vec<unsigned> *scc : tarjan_sccs)
     {
       for (unsigned phi : *scc)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-15 10:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-17  7:55 [gcc(refs/users/pheeck/heads/sccp)] fixed segfault, tarjan works Filip Kastl
2023-02-15 10:13 Filip Kastl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).