This fixes PR51012 - a few more places where we need to update
non-inlinable state when discovering new direct edges.

Bootstrap and regtest pending on x86_64-unknown-linux-gnu.

Richard.

2011-11-08  Richard Guenther  <rguent...@suse.de>

        PR tree-optimization/51012
        * ipa-prop.c (update_indirect_edges_after_inlining): Fixup
        non-inlinable state.
        * cgraph.c (cgraph_make_edge_direct): Likewise.

        * gcc.dg/pr51012-1.c: New testcase.
        * gcc.dg/pr51012-2.c: Likewise.

Index: gcc/ipa-prop.c
===================================================================
*** gcc/ipa-prop.c      (revision 181154)
--- gcc/ipa-prop.c      (working copy)
*************** update_indirect_edges_after_inlining (st
*** 1905,1910 ****
--- 1905,1917 ----
        if (new_direct_edge)
        {
          new_direct_edge->indirect_inlining_edge = 1;
+         if (new_direct_edge->call_stmt
+             && !gimple_check_call_matching_types (new_direct_edge->call_stmt,
+                                                   
new_direct_edge->callee->decl))
+           {
+             gimple_call_set_cannot_inline (new_direct_edge->call_stmt, true);
+             new_direct_edge->call_stmt_cannot_inline_p = true;
+           }
          if (new_edges)
            {
              VEC_safe_push (cgraph_edge_p, heap, *new_edges,
Index: gcc/cgraph.c
===================================================================
*** gcc/cgraph.c        (revision 181154)
--- gcc/cgraph.c        (working copy)
*************** cgraph_make_edge_direct (struct cgraph_e
*** 1184,1189 ****
--- 1184,1196 ----
    /* Insert to callers list of the new callee.  */
    cgraph_set_edge_callee (edge, callee);
  
+   if (edge->call_stmt
+       && !gimple_check_call_matching_types (edge->call_stmt, callee->decl))
+     {
+       gimple_call_set_cannot_inline (edge->call_stmt, true);
+       edge->call_stmt_cannot_inline_p = true;
+     }
+ 
    /* We need to re-determine the inlining status of the edge.  */
    initialize_inline_failed (edge);
  }
Index: gcc/testsuite/gcc.dg/pr51012-1.c
===================================================================
*** gcc/testsuite/gcc.dg/pr51012-1.c    (revision 0)
--- gcc/testsuite/gcc.dg/pr51012-1.c    (revision 0)
***************
*** 0 ****
--- 1,17 ----
+ /* { dg-do compile }  */
+ /* { dg-options "-O2 -fno-early-inlining -fno-ipa-cp" } */
+ 
+ float baz (void)
+ {
+   return 0;
+ }
+ 
+ static inline int bar (int (*ibaz) (void))
+ {
+   return ibaz ();
+ }
+ 
+ void foo (void)
+ {
+   bar((int (*)(void))baz);
+ }
Index: gcc/testsuite/gcc.dg/pr51012-2.c
===================================================================
*** gcc/testsuite/gcc.dg/pr51012-2.c    (revision 0)
--- gcc/testsuite/gcc.dg/pr51012-2.c    (revision 0)
***************
*** 0 ****
--- 1,17 ----
+ /* { dg-do compile }  */
+ /* { dg-options "-O2 -fno-early-inlining" } */
+ 
+ float baz (void)
+ {
+   return 0;
+ }
+ 
+ static inline int bar (int (*ibaz) (void))
+ {
+   return ibaz ();
+ }
+ 
+ void foo (void)
+ {
+   bar((int (*)(void))baz);
+ }

Reply via email to