On Fri, Jun 14, 2013 at 1:43 AM, Richard Biener
<richard.guent...@gmail.com> wrote:
> On Fri, Jun 14, 2013 at 4:52 AM, Sriraman Tallam <tmsri...@google.com> wrote:
>> On Thu, Jun 13, 2013 at 12:40 PM, Jan Hubicka <hubi...@ucw.cz> wrote:
>>>>       * tree-inline.c (expand_call_inline): Allow the error to be flagged
>>>>       in early inline pass.
>>>>       * ipa-inline.c (inline_always_inline_functions): Pretend 
>>>> always_inline
>>>>       functions are inlined during failures to flag an error.
>>>>       * gcc.target/i386/inline_error.c: New test.
>>
>>> This patch is OK if it passes testing.
>>
>> Two tests gcc.c-torture/compile/pr43791.c and pr44043.c are failing
>> because of always_inline functions being present that cannot be
>> inlined and the compiler is now generating error messages. I will fix
>> them and resend the patch.
>
> Quick look - pr43791.c is not expected to work at -O0, so skip -O0
> for example by guarding the whole thing with #if __OPTIMIZED__ > 0.
> Similar for pr44043.c.

Seems like __OPTIMIZED__ is not defined in my config, dont know why. I
see other tests checking for __OPTIMIZED.

I fixed these two tests by adding a dg-prune-output at the end. Is
that reasonable? I have attached the patch with all tests passing now.

Thanks
Sri

>
> That we didn't error at -O0 before is a bug.  Eventually I was suggesting
> to error if we end up outputting the body of an always_inline function,
> that is, any uses remain (including indirect calls or address-takens which
> is where we do not error right now).
>
> Richard.
>
>> Thanks
>> Sri
>>
>>> Thanks for your patience!
>>
>>
>>
>>>
>>> Honza
        * tree-inline.c (expand_call_inline): Allow the error to be flagged
        in early inline pass.
        * ipa-inline.c (inline_always_inline_functions): Pretend always_inline
        functions are inlined during failures to flag an error.
        * gcc.target/i386/inline_error.c: New test.
        * gcc.c-torture/compile/pr44043.c: Fix test to expect an error.
        * gcc.c-torture/compile/pr43791.c: Fix test to expect an error.

Index: tree-inline.c
===================================================================
--- tree-inline.c       (revision 200034)
+++ tree-inline.c       (working copy)
@@ -3905,8 +3905,6 @@ 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
-         /* 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))
        {
Index: ipa-inline.c
===================================================================
--- ipa-inline.c        (revision 200034)
+++ ipa-inline.c        (working copy)
@@ -1911,7 +1911,15 @@ inline_always_inline_functions (struct cgraph_node
        }
 
       if (!can_early_inline_edge_p (e))
-       continue;
+       {
+         /* Set inlined to true if the callee is marked "always_inline" but
+            is not inlinable.  This will allow flagging an error later in
+            expand_call_inline in tree-inline.c.  */
+         if (lookup_attribute ("always_inline",
+                                DECL_ATTRIBUTES (callee->symbol.decl)) != NULL)
+           inlined = true;
+         continue;
+       }
 
       if (dump_file)
        fprintf (dump_file, "  Inlining %s into %s (always_inline).\n",
Index: testsuite/gcc.target/i386/inline_error.c
===================================================================
--- testsuite/gcc.target/i386/inline_error.c    (revision 0)
+++ testsuite/gcc.target/i386/inline_error.c    (revision 0)
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -mno-popcnt" } */
+
+inline int __attribute__ ((__gnu_inline__, __always_inline__, 
target("popcnt")))
+foo () /* { dg-error "inlining failed in call to always_inline .* target 
specific option mismatch" } */
+{
+  return 0;
+}
+
+int bar()
+{
+  return foo (); /* { dg-error "called from here" } */
+}
Index: testsuite/gcc.c-torture/compile/pr44043.c
===================================================================
--- testsuite/gcc.c-torture/compile/pr44043.c   (revision 200034)
+++ testsuite/gcc.c-torture/compile/pr44043.c   (working copy)
@@ -85,3 +85,5 @@ 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 200034)
+++ testsuite/gcc.c-torture/compile/pr43791.c   (working copy)
@@ -1,3 +1,4 @@
+
 int owner();
 int clear();
 
@@ -6,16 +7,16 @@ static void fixup() {
 }
 
 inline __attribute__ ((always_inline))
-void slowtrylock(void) {
+void slowtrylock(void) { /*  dg-error "inlining failed"  */
      if (owner())
          fixup();
 }
 
 void fasttrylock(void (*slowfn)()) {
-     slowfn();
+     slowfn();  /*  dg-error "called from here"   */
 }
 
 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)" } */

Reply via email to