public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/pheeck/heads/sccp)] fixed crashing on 20090917-1.c
@ 2023-02-15 10:25 Filip Kastl
0 siblings, 0 replies; only message in thread
From: Filip Kastl @ 2023-02-15 10:25 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:4894c7738e555630329e04100af6ffcb7265bb85
commit 4894c7738e555630329e04100af6ffcb7265bb85
Author: Filip Kastl <filip.kastl@gmail.com>
Date: Tue Nov 29 12:49:22 2022 +0100
fixed crashing on 20090917-1.c
Diff:
---
gcc/sccp.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/gcc/sccp.cc b/gcc/sccp.cc
index c8c24fca2cf..5079b6e10df 100644
--- a/gcc/sccp.cc
+++ b/gcc/sccp.cc
@@ -309,10 +309,12 @@ static void
replace_scc_by_value (vec<gimple *> scc, tree replace_by)
{
// DEBUG
+ /*
if (scc.length () >= 5)
{
std::cerr << "Replacing SCC of length " << scc.length () << std::endl;
}
+ */
for (gimple *stmt : scc)
{
@@ -335,6 +337,30 @@ replace_scc_by_value (vec<gimple *> scc, tree replace_by)
}
}
+/* Remove all PHIs with zero uses. */
+
+static void
+remove_zero_uses_phis ()
+{
+ basic_block bb;
+ FOR_EACH_BB_FN (bb, cfun)
+ {
+ gphi_iterator pi;
+ for (pi = gsi_start_phis (bb); !gsi_end_p (pi);)
+ {
+ gphi *phi = pi.phi ();
+ tree ssa_name = gimple_phi_result (phi);
+ if (has_zero_uses (ssa_name))
+ {
+ /* Note that remove_phi_node() also frees SSA name. */
+ remove_phi_node (&pi, true);
+ }
+ else
+ gsi_next (&pi);
+ }
+ }
+}
+
/* Apply Braun et al.'s algorithm on a given set of statements. Treat copy
statements as PHI functions with a single argument.
Main function of this pass. */
@@ -427,6 +453,8 @@ sccp_propagate (auto_vec<gimple *> ©_stmts)
scc.release ();
}
+
+ remove_zero_uses_phis ();
}
/* Return all statements in cfun that may be useful. */
@@ -515,8 +543,39 @@ unsigned
pass_sccp::execute (function *)
{
init_sccp ();
+
+ // DEBUG
+ /*
+ std::cerr << "Before:" << std::endl;
+ basic_block bb;
+ FOR_EACH_BB_FN (bb, cfun)
+ {
+ gphi_iterator pi;
+ for (pi = gsi_start_phis (bb); !gsi_end_p (pi); gsi_next (&pi))
+ {
+ gphi *phi = pi.phi ();
+ debug_gimple_stmt (phi);
+ }
+ }
+ */
+
auto_vec<gimple *> stmts = get_all_may_generate_useful_copy ();
sccp_propagate (stmts);
+
+ // DEBUG
+ /*
+ std::cerr << "After:" << std::endl;
+ FOR_EACH_BB_FN (bb, cfun)
+ {
+ gphi_iterator pi;
+ for (pi = gsi_start_phis (bb); !gsi_end_p (pi); gsi_next (&pi))
+ {
+ gphi *phi = pi.phi ();
+ debug_gimple_stmt (phi);
+ }
+ }
+ */
+
finalize_sccp ();
return 0;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-15 10:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-15 10:25 [gcc(refs/users/pheeck/heads/sccp)] fixed crashing on 20090917-1.c 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).