Hi!

dump_passes pushes a dummy function for which it evaluates the gates
and checks whether the pass is enabled or disabled.
Unfortunately, if any -fdisable-*-*/-fenable-*-* options were seen,
we ICE during is_pass_explicitly_enabled_or_disabled because slot
is non-NULL then and the code will do:
  cgraph_uid = func ? cgraph_node::get (func)->get_uid () : 0;
but the dummy function doesn't have a cgraph node.

So, either we need to create and then remove a cgraph node for the dummy
function like the following patch, or function.c would need to export the
in_dummy_function flag (or have some way to query that flag from other TUs)
and we'd need to check it in is_pass_explicitly_enabled_or_disabled.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2020-02-25  Jakub Jelinek  <ja...@redhat.com>

        PR middle-end/93874
        * passes.c (pass_manager::dump_passes): Create a cgraph node for the
        dummy function and remove it at the end.

        * gcc.dg/pr93874.c: New test.

--- gcc/passes.c.jj     2020-01-12 11:54:36.693409184 +0100
+++ gcc/passes.c        2020-02-24 10:34:24.081281789 +0100
@@ -950,6 +950,7 @@ void
 pass_manager::dump_passes () const
 {
   push_dummy_function (true);
+  cgraph_node *node = cgraph_node::get_create (current_function_decl);
 
   create_pass_tab ();
 
@@ -959,6 +960,7 @@ pass_manager::dump_passes () const
   dump_pass_list (all_late_ipa_passes, 1);
   dump_pass_list (all_passes, 1);
 
+  node->remove ();
   pop_dummy_function ();
 }
 
--- gcc/testsuite/gcc.dg/pr93874.c.jj   2020-02-24 10:39:43.417514220 +0100
+++ gcc/testsuite/gcc.dg/pr93874.c      2020-02-24 10:41:26.506976191 +0100
@@ -0,0 +1,6 @@
+/* PR middle-end/93874 */
+/* { dg-do compile } */
+/* { dg-options "-fdisable-tree-dse3 -fdump-passes" } */
+/* { dg-prune-output ".*" } */
+
+int i;

        Jakub

Reply via email to