cgraph: Avoid segfault when attempting to dump NULL clone_info
authorMartin Jambor <mjambor@suse.cz>
Thu, 12 Nov 2020 18:56:07 +0000 (19:56 +0100)
committerMartin Jambor <mjambor@suse.cz>
Thu, 12 Nov 2020 18:56:22 +0000 (19:56 +0100)
cgraph_node::materialize_clone segfaulted when I tried compiling
Tramp3D with -fdump-ipa-all because there was no clone_info - IPA-CP
created a clone only for an aggregate constant, adding a note to its
transformation summary but not creating any tree_map nor
param_adjustements.

Fixed with the following obvious extra checks which has passed
bootstrap and testing on x86_64-linux.

gcc/ChangeLog:

2020-11-12  Martin Jambor  <mjambor@suse.cz>

* cgraphclones.c (cgraph_node::materialize_clone): Check that clone
info is not NULL before attempting to dump it.

gcc/cgraphclones.c

index 2e69689025aa4c0cc78fbb6ec4dc7ee7ec486aef..2bf9baf9cc8cd62ce136fae7a760eb99f2470e29 100644 (file)
@@ -1107,7 +1107,7 @@ cgraph_node::materialize_clone ()
       fprintf (symtab->dump_file, "cloning %s to %s\n",
               clone_of->dump_name (),
               dump_name ());
-      if (info->tree_map)
+      if (info && info->tree_map)
         {
          fprintf (symtab->dump_file, "    replace map:");
          for (unsigned int i = 0;
@@ -1123,7 +1123,7 @@ cgraph_node::materialize_clone ()
            }
          fprintf (symtab->dump_file, "\n");
        }
-      if (info->param_adjustments)
+      if (info && info->param_adjustments)
        info->param_adjustments->dump (symtab->dump_file);
     }
   clear_stmts_in_references ();