diff mbox

Fix for PR57698

Message ID CAAs8Hmztr1MrX-RgK+wdqOF-v76jNxNguXTYYO6k6NwFY+RO1Q@mail.gmail.com
State New
Headers show

Commit Message

Sriraman Tallam July 12, 2013, 10:16 p.m. UTC
Patch attached to fix this: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57698

Here is what is going on. In rev. 200179, this change to tree-inline.c


Seems like the right fix to me. Ok?  The whole patch with test case
included is attached.

Thanks
Sri
* tree-inline.c (expand_call_inline): Emit errors during
	early_inlining only if optimization is not turned on.
	* gcc.c-torture/compile/pr57698.c: New test.
	* gcc.c-torture/compile/pr43791.c: Remove prune output
	directive.
	* gcc.c-torture/compile/pr44043.c: Ditto.

Index: testsuite/gcc.c-torture/compile/pr57698.c
===================================================================
--- testsuite/gcc.c-torture/compile/pr57698.c	(revision 0)
+++ testsuite/gcc.c-torture/compile/pr57698.c	(revision 0)
@@ -0,0 +1,19 @@
+typedef int (*IsAcceptableThis) (const int );
+inline int
+fn1 (IsAcceptableThis p1)
+{
+    p1 (0);
+    return 0;
+}
+
+__attribute__ ((always_inline))
+inline int fn2 (const int a)
+{
+    return 0;
+}
+
+void
+fn3 ()
+{
+    fn1 (fn2);
+}
Index: testsuite/gcc.c-torture/compile/pr44043.c
===================================================================
--- testsuite/gcc.c-torture/compile/pr44043.c	(revision 200912)
+++ testsuite/gcc.c-torture/compile/pr44043.c	(working copy)
@@ -85,5 +85,3 @@ int raw_sendmsg(struct sock *sk, struct msghdr *ms
 {
   raw_send_hdrinc(sk, msg->msg_iov, len, (void *)0, msg->msg_flags);
 }
-
-/* { dg-prune-output "(inlining failed in call to always_inline.*indirect function call with a yet undetermined callee|called from here)" } */
Index: testsuite/gcc.c-torture/compile/pr43791.c
===================================================================
--- testsuite/gcc.c-torture/compile/pr43791.c	(revision 200912)
+++ testsuite/gcc.c-torture/compile/pr43791.c	(working copy)
@@ -18,5 +18,3 @@ void fasttrylock(void (*slowfn)()) {
 void trylock(void) {
      fasttrylock(slowtrylock);
 }
-
-/* { dg-prune-output "(inlining failed in call to always_inline.*indirect function call with a yet undetermined callee|called from here)" } */
Index: tree-inline.c
===================================================================
--- tree-inline.c	(revision 200912)
+++ tree-inline.c	(working copy)
@@ -3905,6 +3905,10 @@ expand_call_inline (basic_block bb, gimple stmt, c
 	     for inlining, but we can't do that because frontends overwrite
 	     the body.  */
 	  && !cg_edge->callee->local.redefined_extern_inline
+	  /* During early inline pass, report only when optimization is
+	     not turned on.  */
+	  && (cgraph_global_info_ready
+	      || !optimize)
 	  /* PR 20090218-1_0.c. Body can be provided by another module. */
 	  && (reason != CIF_BODY_NOT_AVAILABLE || !flag_generate_lto))
 	{

Comments

H.J. Lu Jan. 13, 2014, 4:28 p.m. UTC | #1
On Fri, Jul 12, 2013 at 3:16 PM, Sriraman Tallam <tmsriram@google.com> wrote:
> Patch attached to fix this: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57698
>
> Here is what is going on. In rev. 200179, this change to tree-inline.c
>
> Index: tree-inline.c
> ===================================================================
> --- tree-inline.c       (revision 200178)
> +++ tree-inline.c       (revision 200179)
> @@ -3905,8 +3905,6 @@
>              for inlining, but we can't do that because frontends overwrite
>              the body.  */
>           && !cg_edge->callee->local.redefined_extern_inline
> -         /* Avoid warnings during early inline pass. */
> -         && cgraph_global_info_ready
>           /* PR 20090218-1_0.c. Body can be provided by another module. */
>           && (reason != CIF_BODY_NOT_AVAILABLE || !flag_generate_lto))
>         {
>
> made inline failure errors during early inlining reportable.  Now,
> this function is called when the early_inliner calls
> optimize_inline_calls.  The reason for the failure,
> CIF_INDIRECT_UNKNOWN_CALL, should not be reported because it is not a
> valid reason,(see can_inline_edge_p in ipa-inline.c for the list of
> reasons we intend to report) but it gets reported because of the above
> change.
>
>
> The reported bug happens only when optimization is turned on as the
> early inliner pass invokes incremental inlining which calls
> optimize_inline_calls and triggers the above failure.
>
> So, the fix is then as simple as:
>
> Index: tree-inline.c
> ===================================================================
> --- tree-inline.c       (revision 200912)
> +++ tree-inline.c       (working copy)
> @@ -3905,6 +3905,10 @@ expand_call_inline (basic_block bb, gimple stmt, c
>              for inlining, but we can't do that because frontends overwrite
>              the body.  */
>           && !cg_edge->callee->local.redefined_extern_inline
> +         /* During early inline pass, report only when optimization is
> +            not turned on.  */
> +         && (cgraph_global_info_ready
> +             || !optimize)
>           /* PR 20090218-1_0.c. Body can be provided by another module. */
>           && (reason != CIF_BODY_NOT_AVAILABLE || !flag_generate_lto))
>         {
>
> Seems like the right fix to me. Ok?  The whole patch with test case
> included is attached.
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59789
diff mbox

Patch

Index: tree-inline.c
===================================================================
--- tree-inline.c       (revision 200178)
+++ tree-inline.c       (revision 200179)
@@ -3905,8 +3905,6 @@ 
             for inlining, but we can't do that because frontends overwrite
             the body.  */
          && !cg_edge->callee->local.redefined_extern_inline
-         /* Avoid warnings during early inline pass. */
-         && cgraph_global_info_ready
          /* PR 20090218-1_0.c. Body can be provided by another module. */
          && (reason != CIF_BODY_NOT_AVAILABLE || !flag_generate_lto))
        {

made inline failure errors during early inlining reportable.  Now,
this function is called when the early_inliner calls
optimize_inline_calls.  The reason for the failure,
CIF_INDIRECT_UNKNOWN_CALL, should not be reported because it is not a
valid reason,(see can_inline_edge_p in ipa-inline.c for the list of
reasons we intend to report) but it gets reported because of the above
change.


The reported bug happens only when optimization is turned on as the
early inliner pass invokes incremental inlining which calls
optimize_inline_calls and triggers the above failure.

So, the fix is then as simple as:

Index: tree-inline.c
===================================================================
--- tree-inline.c       (revision 200912)
+++ tree-inline.c       (working copy)
@@ -3905,6 +3905,10 @@  expand_call_inline (basic_block bb, gimple stmt, c
             for inlining, but we can't do that because frontends overwrite
             the body.  */
          && !cg_edge->callee->local.redefined_extern_inline
+         /* During early inline pass, report only when optimization is
+            not turned on.  */
+         && (cgraph_global_info_ready
+             || !optimize)
          /* PR 20090218-1_0.c. Body can be provided by another module. */
          && (reason != CIF_BODY_NOT_AVAILABLE || !flag_generate_lto))
        {