From 6e646e4553694305c187f6c69d521f8e32557285 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 18 Feb 2020 22:28:16 -0500
Subject: [PATCH 22/31] FIXME: more WIP on canonicalization/purging

---
 gcc/analyzer/region-model.cc                       | 6 +-----
 gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-1a.c | 4 ++--
 gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-2.c  | 6 +++---
 gcc/testsuite/gcc.dg/analyzer/paths-4.c            | 4 ----
 gcc/testsuite/gcc.dg/analyzer/paths-6.c            | 2 +-
 5 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index 0e21b576c47..9acf7990d58 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -7071,17 +7071,13 @@ canonicalization::walk_ec_id (equiv_class_id ec_id)
 
   m_ec_id_map.put (ec_id, equiv_class_id::from_int (m_next_ec_id_int++));
 
-  // FIXME: also walk sids in ec? what order?
-#if 0
-  // TODO: get the sids, sort them somehow, then walk them?
+  /* Walk the sids in this EC.  FIXME: what order?  */
   const equiv_class &ec = ec_id.get_obj (*m_model.get_constraints ());
   unsigned var_idx;
   svalue_id *var_in_ec;
   FOR_EACH_VEC_ELT (ec.m_vars, var_idx, var_in_ec)
     walk_sid (*var_in_ec);
-#endif
 
-  const equiv_class &ec = ec_id.get_obj (*m_model.get_constraints ());
   if (!ec.m_cst_sid.null_p ())
     walk_sid (ec.m_cst_sid);
   else
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-1a.c b/gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-1a.c
index d47dfa8b2c0..5a4bd3c6282 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-1a.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-1a.c
@@ -169,8 +169,8 @@ int test_initial_flag (int n)
 
   result = do_stuff (ptr, n);
 
-  __analyzer_dump_exploded_nodes (0); /* { dg-warning "5 processed enodes" } */
-  // FIXME: why 5 here?
+  __analyzer_dump_exploded_nodes (0); /* { dg-warning "4 processed enodes" } */
+  // FIXME: why 4 here?
 
   if (n > 10)
     free (ptr); /* { dg-bogus "not on the heap" } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-2.c b/gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-2.c
index 89bd511549f..c879ce6e032 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-2.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-2.c
@@ -37,7 +37,7 @@ int test_repeated_predicate_1 (int n)
     result = sum;
   }
 
-  __analyzer_dump_exploded_nodes (0); /* { dg-warning "3 processed enodes" } */
+  __analyzer_dump_exploded_nodes (0); /* { dg-warning "4 processed enodes" } */
 
   if (n > 10)
     free (ptr); /* { dg-bogus "not on the heap" } */
@@ -69,7 +69,7 @@ int test_repeated_predicate_1a (int n)
     result = sum;
   }
 
-  __analyzer_dump_exploded_nodes (0); /* { dg-warning "3 processed enodes" } */
+  __analyzer_dump_exploded_nodes (0); /* { dg-warning "4 processed enodes" } */
 
   if (n > 10)
     free (ptr); /* { dg-bogus "not on the heap" } */
@@ -166,7 +166,7 @@ int test_pointer_comparison (int n)
     result = sum;
   }
 
-  __analyzer_dump_exploded_nodes (0); /* { dg-warning "3 processed enodes" } */
+  __analyzer_dump_exploded_nodes (0); /* { dg-warning "4 processed enodes" } */
 
   if (ptr != buf)
     free (ptr); /* { dg-bogus "not on the heap" } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/paths-4.c b/gcc/testsuite/gcc.dg/analyzer/paths-4.c
index 2f58763886c..1df4e632ef0 100644
--- a/gcc/testsuite/gcc.dg/analyzer/paths-4.c
+++ b/gcc/testsuite/gcc.dg/analyzer/paths-4.c
@@ -13,9 +13,7 @@ int test_1 (struct state *s)
   __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
   while (1)
     {
-      __analyzer_dump_exploded_nodes (0); /* { dg-warning "2 processed enodes" } */
       __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
-      /* TODO: why does the above need an extra stmt to merge state?  */
       do_stuff (s, s->mode);
     }
 }
@@ -25,9 +23,7 @@ int test_2 (struct state *s)
   __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
   while (1)
     {
-      __analyzer_dump_exploded_nodes (0); /* { dg-warning "3 processed enodes" } */
       __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
-      /* TODO: why does the above need an extra stmt to merge state?  */
       switch (s->mode)
 	{
 	case 0:
diff --git a/gcc/testsuite/gcc.dg/analyzer/paths-6.c b/gcc/testsuite/gcc.dg/analyzer/paths-6.c
index 8220b8eff82..3f07f2e422f 100644
--- a/gcc/testsuite/gcc.dg/analyzer/paths-6.c
+++ b/gcc/testsuite/gcc.dg/analyzer/paths-6.c
@@ -89,7 +89,7 @@ void test_3 (int i)
       break;
     }
 
-  __analyzer_dump_exploded_nodes (0); /* { dg-warning "2 processed enode" } */
+  __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
   __analyzer_eval (f == 3); /* { dg-warning "TRUE" } */
   __analyzer_eval (g == 4); /* { dg-warning "TRUE" } */
   __analyzer_eval (h == 5); /* { dg-warning "TRUE" } */
-- 
2.21.0

