> This patch:
> 
> > ef0752d323b5a250caf1b972354f3749382c8dce is the first bad commit
> > commit ef0752d323b5a250caf1b972354f3749382c8dce
> > Author: hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
> > Date:   Mon Nov 4 14:07:09 2019 +0000
> > 
> >             * cgraphclones.c (cgraph_node::create_version_clone): Do not
> >             duplicate summaries.
> >             * ipa-fnsummary.c (ipa_fn_summary_alloc): Allocate size summary
> >             first.
> >             (ipa_fn_summary_t::duplicate): Use get instead of get_create to
> >             access call summaries.
> >             (dump_ipa_call_summary): Be ready for missing edge summaries.
> >             (analyze_function_body): Use get instead of get_create to access
> >             edge summary.
> >             (estimate_calls_size_and_time): Do not access summaries of
> >             inlined edges; sanity check they are missing.
> >             (ipa_call_context::estimate_size_and_time): Use get instead
> >             of get_create to access node summary.
> >             (inline_update_callee_summaries): Do not update depth of
> >             inlined edge.
> >             (ipa_merge_fn_summary_after_inlining): Remove inline edge from
> >             growth caches.
> >             (ipa_merge_fn_summary_after_inlining): Use get instead
> >             of get_create.
> >             * ipa-fnsummary.h (ipa_remove_from_growth_caches): Declare.
> >             * ipa-inline-analyssi.c (edge_growth_cache): Turn to
> >             fast summary.
> >             (initialize_growth_caches): Update.
> >             (do_estimate_edge_time): Remove redundant copy of context.
> >             (ipa_remove_from_growth_caches): New function.
> >             * ipa-inline.c (flatten_function): Update overall summary
> >             only when optimizing.
> >             (inline_to_all_callers): Update overall summary of function
> >             inlined to.
> >             * ipa-inline.h (edge_growth_cache): Turn to fast summary.
> >             * symbol-summary.h (call_summary_base): Set 
> > m_initialize_when_cloning
> >             to false.
> >     
> >     
> >     git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@277780 
> > 138bc75d-0d04-0410-961f-82ee72b054a4
> 
> Causes the attached code to segfault with -O2:

This ICE is about flatten attribute being used on external function.
Flattening there does not make much sense.  I wonder if we should warn
on attribute being ignored, but perhaps we don't want to since it does
make sense to keep prototype and definition same.  I suppose the author
wanted to flatten the function in some other module.

Honza

        * ipa-inline.c (ipa_inline): Check that function is defined before
        flattening.
        * gcc.c-torture/compile/flatten.c: New testcase.
Index: ipa-inline.c
===================================================================
--- ipa-inline.c        (revision 278124)
+++ ipa-inline.c        (working copy)
@@ -2564,8 +2564,9 @@ ipa_inline (void)
   for (i = nnodes - 1, j = i; i >= 0; i--)
     {
       node = order[i];
-      if (lookup_attribute ("flatten",
-                           DECL_ATTRIBUTES (node->decl)) != NULL)
+      if (node->definition
+         && lookup_attribute ("flatten",
+                              DECL_ATTRIBUTES (node->decl)) != NULL)
        order[j--] = order[i];
     }
 
Index: testsuite/gcc.c-torture/compile/flatten.c
===================================================================
--- testsuite/gcc.c-torture/compile/flatten.c   (nonexistent)
+++ testsuite/gcc.c-torture/compile/flatten.c   (working copy)
@@ -0,0 +1,5 @@
+int you_shall_not_flatten_me () __attribute__ ((flatten));
+main()
+{
+  you_shall_not_flatten_me ();
+}

Reply via email to