public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Filip Kastl <pheeck@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/pheeck/heads/sccp)] fixed segfault, tarjan works
Date: Sun, 17 Jul 2022 07:55:42 +0000 (GMT)	[thread overview]
Message-ID: <20220717075542.0131B3858D28@sourceware.org> (raw)

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)


             reply	other threads:[~2022-07-17  7:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-17  7:55 Filip Kastl [this message]
2023-02-15 10:13 Filip Kastl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220717075542.0131B3858D28@sourceware.org \
    --to=pheeck@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).