From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7879) id 0131B3858D28; Sun, 17 Jul 2022 07:55:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0131B3858D28 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Filip Kastl To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/pheeck/heads/sccp)] fixed segfault, tarjan works X-Act-Checkin: gcc X-Git-Author: Filip Kastl X-Git-Refname: refs/users/pheeck/heads/sccp X-Git-Oldrev: d27a4a2e310515fdfea6a51d80537a1a77f8b497 X-Git-Newrev: 059c7ef6f85a3014c1757a8de111304d12b87288 Message-Id: <20220717075542.0131B3858D28@sourceware.org> Date: Sun, 17 Jul 2022 07:55:42 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jul 2022 07:55:42 -0000 https://gcc.gnu.org/g:059c7ef6f85a3014c1757a8de111304d12b87288 commit 059c7ef6f85a3014c1757a8de111304d12b87288 Author: Filip Kastl 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 + +#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*> tarjan_sccs; +static vec*> tarjan_sccs; // TODO Correct * style? static vec 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 *scc : tarjan_sccs) { for (unsigned phi : *scc)