]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ipa-cp: Fix constant dumping
authorMartin Jambor <mjambor@suse.cz>
Thu, 14 Nov 2024 13:42:27 +0000 (14:42 +0100)
committerMartin Jambor <jamborm@gcc.gnu.org>
Thu, 14 Nov 2024 13:42:59 +0000 (14:42 +0100)
Commit gcc-14-5368-ge0787da2633 removed an overloaded variant of
function print_ipcp_constant_value for tree constants.  That did not
break build because the other overloaded variant for polymorphic
contexts-has a parameter which is constructible from a tree, but it
prints polymorphic contexts, not tree constants, so we in dumps we got
things like:

  param [0]: VARIABLE
       ctxs: VARIABLE
       Bits: value = 0x0, mask = 0xfffffffffffffffc
       [prange] struct S * [1, +INF] MASK 0xfffffffffffffffc VALUE 0x0
      ref offset 0:     nothing known [scc: 1, from: 1(1.000000)] [loc_time: 0, loc_size: 0, prop_time: 0, prop_size: 0]
      ref offset 32:     nothing known [scc: 2, from: 1(1.000000)] [loc_time: 0, loc_size: 0, prop_time: 0, prop_size: 0]
      ref offset 64:     nothing known [scc: 3, from: 1(1.000000)] [loc_time: 0, loc_size: 0, prop_time: 0, prop_size: 0]

instead of:

  param [0]: VARIABLE
       ctxs: VARIABLE
       Bits: value = 0x0, mask = 0xfffffffffffffffc
       [prange] struct S * [1, +INF] MASK 0xfffffffffffffffc VALUE 0x0
      ref offset 0: 1 [scc: 1, from: 1(1.000000)] [loc_time: 0, loc_size: 0, prop_time: 0, prop_size: 0]
      ref offset 32: 64 [scc: 2, from: 1(1.000000)] [loc_time: 0, loc_size: 0, prop_time: 0, prop_size: 0]
      ref offset 64: 32 [scc: 3, from: 1(1.000000)] [loc_time: 0, loc_size: 0, prop_time: 0, prop_size: 0]

This commit re-adds the needed overloaded variant though it uses the
printing function added in the aforementioned commit instead of
printing it itself.

gcc/ChangeLog:

2024-11-13  Martin Jambor  <mjambor@suse.cz>

* ipa-prop.h (ipa_print_constant_value): Declare.
* ipa-prop.cc (ipa_print_constant_value): Make public.
* ipa-cp.cc (print_ipcp_constant_value): Re-add this overloaded
function for printing tree constants.

gcc/testsuite/ChangeLog:

2024-11-14  Martin Jambor  <mjambor@suse.cz>

* gcc.dg/ipa/ipcp-agg-1.c: Add a scan dump for a constant value in
the latice dump.

gcc/ipa-cp.cc
gcc/ipa-prop.cc
gcc/ipa-prop.h
gcc/testsuite/gcc.dg/ipa/ipcp-agg-1.c

index 212d9ccbbfe0664f6d83b30f30fd86a54150528e..fb65ec0c6a621ffb68d7f19fc6da4c1650e9ef86 100644 (file)
@@ -225,7 +225,17 @@ values_equal_for_ipcp_p (tree x, tree y)
     return operand_equal_p (x, y, 0);
 }
 
-/* Print V which is extracted from a value in a lattice to F.  */
+/* Print V which is extracted from a value in a lattice to F.  This overloaded
+   function is used to print tree constants.  */
+
+static void
+print_ipcp_constant_value (FILE * f, tree v)
+{
+  ipa_print_constant_value (f, v);
+}
+
+/* Print V which is extracted from a value in a lattice to F.  This overloaded
+   function is used to print constant polymorphic call contexts.  */
 
 static void
 print_ipcp_constant_value (FILE * f, ipa_polymorphic_call_context v)
index 599181d0a94318f6c261b09cc20ef410fa37b016..fd18f847e46008d1c5b618073e34e1914ac191dc 100644 (file)
@@ -413,7 +413,7 @@ ipa_initialize_node_params (struct cgraph_node *node)
 
 /* Print VAL which is extracted from a jump function to F.  */
 
-static void
+void
 ipa_print_constant_value (FILE *f, tree val)
 {
   print_generic_expr (f, val);
index 7a05c169c421d326067e6c546de408b17eb19748..a9ef3fe3aa605c51cfd3784fae51135e56074fe1 100644 (file)
@@ -1179,6 +1179,7 @@ ipcp_get_transformation_summary (cgraph_node *node)
 
 /* Function formal parameters related computations.  */
 void ipa_initialize_node_params (struct cgraph_node *node);
+void ipa_print_constant_value (FILE *f, tree val);
 bool ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
                                        vec<cgraph_edge *> *new_edges);
 
index 8cfc18799fae1f0c85c4f0fce881953a2f1ee7cc..15f6286e54bc364a456e123ffc530e36584a15a1 100644 (file)
@@ -30,6 +30,7 @@ entry (void)
   foo (&s);
 }
 
+/* { dg-final { scan-ipa-dump "ref offset\[^\n\r\]*: 64\[^\n\r\]*scc:" "cp" } } */
 /* { dg-final { scan-ipa-dump "Creating a specialized node of foo.*for all known contexts" "cp" } } */
 /* { dg-final { scan-ipa-dump-times "Aggregate replacements:" 2 "cp" } } */
 /* { dg-final { scan-tree-dump-not "->c;" "optimized" } } */