re PR ipa/58332 (error: inlined_to pointer is set but no predecessors found)
authorJan Hubicka <jh@suse.cz>
Tue, 17 Sep 2013 17:45:00 +0000 (19:45 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Tue, 17 Sep 2013 17:45:00 +0000 (17:45 +0000)
PR middle-end/58332
* gcc.c-torture/compile/pr58332.c: New testcase.
* cif-code.def (FUNCTION_NOT_OPTIMIZED): New CIF code.
* ipa-inline.c (can_inline_edge_p): Do not downgrade
FUNCTION_NOT_OPTIMIZED.
* ipa-inline-analysis.c (compute_inline_parameters): Function
not optimized is not inlinable unless it is alwaysinline.
(inline_analyze_function): Force calls in not optimized
function not inlinable.

From-SVN: r202661

gcc/ChangeLog
gcc/cif-code.def
gcc/ipa-inline-analysis.c
gcc/ipa-inline.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr58332.c [new file with mode: 0644]

index 78f4cbc6ce7d05e06fa6c5fc0f61b4ba99e93b3e..616a3f9baf2927095f8709b5f381a6ebfe31d1b2 100644 (file)
        make_pass_early_warn_uninitialized): Move from tree-ssa.c
        * tree-ssa.h: Adjust prototypes
 
+2013-09-17  Jan Hubicka  <jh@suse.cz>
+
+       PR middle-end/58332
+       * cif-code.def (FUNCTION_NOT_OPTIMIZED): New CIF code.
+       * ipa-inline.c (can_inline_edge_p): Do not downgrade
+       FUNCTION_NOT_OPTIMIZED.
+       * ipa-inline-analysis.c (compute_inline_parameters): Function
+       not optimized is not inlinable unless it is alwaysinline.
+       (inline_analyze_function): Force calls in not optimized
+       function not inlinable.
+
 2013-09-17  Jan Hubicka  <jh@suse.cz>
 
        PR middle-end/58329
index d1c4941732532a6626786969cbb17f072a84a352..e71123dc6092cd3f1691d2d3dda8cc6d7a356030 100644 (file)
@@ -37,6 +37,9 @@ DEFCIFCODE(UNSPECIFIED , "")
    functions that have not been rejected for inlining yet.  */
 DEFCIFCODE(FUNCTION_NOT_CONSIDERED, N_("function not considered for inlining"))
 
+/* Caller is compiled with optimizations disabled.  */
+DEFCIFCODE(FUNCTION_NOT_OPTIMIZED, N_("caller is not optimized"))
+
 /* Inlining failed owing to unavailable function body.  */
 DEFCIFCODE(BODY_NOT_AVAILABLE, N_("function body not available"))
 
index eaf64d35853d0c3ac9239490cc150d26fd0f9b67..ba6221e41fdb86702ea5237a1b88f735ae510d6d 100644 (file)
@@ -2664,7 +2664,11 @@ compute_inline_parameters (struct cgraph_node *node, bool early)
   info->stack_frame_offset = 0;
 
   /* Can this function be inlined at all?  */
-  info->inlinable = tree_inlinable_function_p (node->symbol.decl);
+  if (!optimize && !lookup_attribute ("always_inline",
+                                     DECL_ATTRIBUTES (node->symbol.decl)))
+    info->inlinable = false;
+  else
+    info->inlinable = tree_inlinable_function_p (node->symbol.decl);
 
   /* Type attributes can use parameter indices to describe them.  */
   if (TYPE_ATTRIBUTES (TREE_TYPE (node->symbol.decl)))
@@ -3678,6 +3682,22 @@ inline_analyze_function (struct cgraph_node *node)
   if (optimize && !node->thunk.thunk_p)
     inline_indirect_intraprocedural_analysis (node);
   compute_inline_parameters (node, false);
+  if (!optimize)
+    {
+      struct cgraph_edge *e;
+      for (e = node->callees; e; e = e->next_callee)
+       {
+         if (e->inline_failed == CIF_FUNCTION_NOT_CONSIDERED)
+           e->inline_failed = CIF_FUNCTION_NOT_OPTIMIZED;
+         e->call_stmt_cannot_inline_p = true;
+       }
+      for (e = node->indirect_calls; e; e = e->next_callee)
+       {
+         if (e->inline_failed == CIF_FUNCTION_NOT_CONSIDERED)
+           e->inline_failed = CIF_FUNCTION_NOT_OPTIMIZED;
+         e->call_stmt_cannot_inline_p = true;
+       }
+    }
 
   pop_cfun ();
 }
index 266c048672850e47052741e1ed77c98c421ae3d1..3672e57e471776f48aee8f8043e73489d5b16e21 100644 (file)
@@ -275,7 +275,8 @@ can_inline_edge_p (struct cgraph_edge *e, bool report,
     }
   else if (e->call_stmt_cannot_inline_p)
     {
-      e->inline_failed = CIF_MISMATCHED_ARGUMENTS;
+      if (e->inline_failed != CIF_FUNCTION_NOT_OPTIMIZED)
+        e->inline_failed = CIF_MISMATCHED_ARGUMENTS;
       inlinable = false;
     }
   /* Don't inline if the functions have different EH personalities.  */
index d51c300bd1031a2cc49d820b452246af52ec9c6f..b36c03355cd36571b39e74ef3471ef05541125d1 100644 (file)
@@ -1,3 +1,8 @@
+2013-09-17  Jan Hubicka  <jh@suse.cz>
+
+       PR middle-end/58332
+       * gcc.c-torture/compile/pr58332.c: New testcase.
+
 2013-09-17  Jeff Law  <law@redhat.com>
 
        * gcc.c-torture/execute/pr58387.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr58332.c b/gcc/testsuite/gcc.c-torture/compile/pr58332.c
new file mode 100644 (file)
index 0000000..22c586c
--- /dev/null
@@ -0,0 +1,2 @@
+static inline int foo (int x) { return x + 1; }
+__attribute__ ((__optimize__ (0))) int bar (void) { return foo (100); }