And now with the patch.

On 18 September 2015 at 20:40, Manuel López-Ibáñez
<lopeziba...@gmail.com> wrote:
> In https://sourceware.org/ml/libc-alpha/2014-12/msg00300.html, we give a
> "called from here" note without actually having a location, which looks
> strange. I haven't been able to generate such a testcase. In this patch, we
> assert this cannot happen when checking and simply skip the extra note in
> release mode.
>
> Boot&tested on x86_64-linux-gnu
>
> OK?
>
>
> gcc/testsuite/ChangeLog:
>
> 2015-09-18  Manuel López-Ibáñez  <m...@gcc.gnu.org>
>
>     * gcc.target/i386/inline_error.c (int bar): Use dg-message for note.
>     * gcc.target/i386/pr57756.c (static __inline int caller): Likewise.
>     * gcc.target/i386/pr59789.c (f1): Likewise.
>     * gcc.target/i386/intrinsics_5.c (__m128i foo): Likewise.
>     * gcc.target/i386/intrinsics_6.c: Likewise.
>     * gcc.dg/winline-5.c (int t): Likewise.
>     * gcc.dg/winline-9.c (t): Likewise.
>     * gcc.dg/always_inline2.c (q): Likewise.
>     * gcc.dg/winline-2.c (inline int t): Likewise.
>     * gcc.dg/winline-6.c: Likewise.
>     * gcc.dg/winline-10.c (void g): Likewise.
>     * gcc.dg/pr49243.c (void parse): Likewise.
>     * gcc.dg/always_inline3.c (q2): Likewise.
>     * gcc.dg/winline-3.c: Likewise.
>     * gcc.dg/winline-7.c (inline void *t): Likewise.
>
> gcc/ChangeLog:
>
> 2015-09-18  Manuel López-Ibáñez  <m...@gcc.gnu.org>
>
>     * tree-inline.c (expand_call_inline): Use inform for extra note.
>     Do not give "called from here" with UNKNOWN_LOCATION.
Index: gcc/testsuite/gcc.target/i386/inline_error.c
===================================================================
--- gcc/testsuite/gcc.target/i386/inline_error.c        (revision 227880)
+++ gcc/testsuite/gcc.target/i386/inline_error.c        (working copy)
@@ -7,7 +7,7 @@ foo () /* { dg-error "inlining failed in
   return 0;
 }
 
 int bar()
 {
-  return foo (); /* { dg-error "called from here" } */
+  return foo (); /* { dg-message "called from here" } */
 }
Index: gcc/testsuite/gcc.target/i386/pr57756.c
===================================================================
--- gcc/testsuite/gcc.target/i386/pr57756.c     (revision 227880)
+++ gcc/testsuite/gcc.target/i386/pr57756.c     (working copy)
@@ -9,11 +9,11 @@ __inline int callee () /* { dg-error "in
 }
 
 __attribute__((target("sse")))
 static __inline int caller ()
 {
-  return callee(); /* { dg-error "called from here" }  */
+  return callee(); /* { dg-message "called from here" }  */
 }
 
 int main ()
 {
   return caller();
Index: gcc/testsuite/gcc.target/i386/pr59789.c
===================================================================
--- gcc/testsuite/gcc.target/i386/pr59789.c     (revision 227880)
+++ gcc/testsuite/gcc.target/i386/pr59789.c     (working copy)
@@ -16,7 +16,7 @@ _mm_set_epi32 (int __q3, int __q2, int _
 
 
 __m128i
 f1(void)
 { /* { dg-message "warning: SSE vector return without SSE enabled changes the 
ABI" } */
-  return _mm_set_epi32 (0, 0, 0, 0); /* { dg-error "called from here" } */
+  return _mm_set_epi32 (0, 0, 0, 0); /* { dg-message "called from here" } */
 }
Index: gcc/testsuite/gcc.target/i386/intrinsics_5.c
===================================================================
--- gcc/testsuite/gcc.target/i386/intrinsics_5.c        (revision 227880)
+++ gcc/testsuite/gcc.target/i386/intrinsics_5.c        (working copy)
@@ -8,9 +8,9 @@
 
 #include <smmintrin.h>
 
 __m128i foo(__m128i *V)
 {
-    return _mm_stream_load_si128(V); /* { dg-error "called from here" } */
+    return _mm_stream_load_si128(V); /* { dg-message "called from here" } */
 }
 
 /* { dg-prune-output ".*inlining failed.*" }  */
Index: gcc/testsuite/gcc.target/i386/intrinsics_6.c
===================================================================
--- gcc/testsuite/gcc.target/i386/intrinsics_6.c        (revision 227880)
+++ gcc/testsuite/gcc.target/i386/intrinsics_6.c        (working copy)
@@ -8,9 +8,9 @@
 
 #include <smmintrin.h>
 
 __m128i foo(__m128i *V)
 {
-    return _mm_stream_load_si128(V); /* { dg-error "called from here" } */
+    return _mm_stream_load_si128(V); /* { dg-message "called from here" } */
 }
 
 /* { dg-prune-output ".*inlining failed.*" }  */
Index: gcc/testsuite/gcc.dg/winline-5.c
===================================================================
--- gcc/testsuite/gcc.dg/winline-5.c    (revision 227880)
+++ gcc/testsuite/gcc.dg/winline-5.c    (working copy)
@@ -15,7 +15,7 @@ inline int q(void) /* { dg-warning "inli
        big();
        big();
 }
 int t (void)
 {
-       return q ();             /* { dg-warning "called from here" } */
+       return q ();             /* { dg-message "called from here" } */
 }
Index: gcc/testsuite/gcc.dg/winline-9.c
===================================================================
--- gcc/testsuite/gcc.dg/winline-9.c    (revision 227880)
+++ gcc/testsuite/gcc.dg/winline-9.c    (working copy)
@@ -20,7 +20,7 @@ int
 t()
 {
   if (a)
     aa();
   if (b)
-    bb();                      /* { dg-warning "called from here" "" } */
+    bb();                      /* { dg-message "called from here" "" } */
 }
Index: gcc/testsuite/gcc.dg/always_inline2.c
===================================================================
--- gcc/testsuite/gcc.dg/always_inline2.c       (revision 227880)
+++ gcc/testsuite/gcc.dg/always_inline2.c       (working copy)
@@ -2,7 +2,7 @@
 /* { dg-options "-O2 -fgnu89-inline" } */
 inline __attribute__ ((always_inline)) void t(void); /* { dg-error "body not 
available" } */
 void
 q(void)
 {
-  t();                                 /* { dg-error "called from here" } */
+  t();                                 /* { dg-message "called from here" } */
 }
Index: gcc/testsuite/gcc.dg/winline-2.c
===================================================================
--- gcc/testsuite/gcc.dg/winline-2.c    (revision 227880)
+++ gcc/testsuite/gcc.dg/winline-2.c    (working copy)
@@ -2,7 +2,7 @@
 /* { dg-options "-Winline -O2 -fgnu89-inline" } */
 
 inline int q(void);             /* { dg-warning "body not available" "" } */
 inline int t(void)
 {
-       return q();              /* { dg-warning "called from here" "" } */
+       return q();              /* { dg-message "called from here" "" } */
 }
Index: gcc/testsuite/gcc.dg/winline-6.c
===================================================================
--- gcc/testsuite/gcc.dg/winline-6.c    (revision 227880)
+++ gcc/testsuite/gcc.dg/winline-6.c    (working copy)
@@ -15,7 +15,7 @@ inline int q(void) /* { dg-warning "larg
        big();
        big();
 }
 inline int t (void)
 {
-       return q () + 1;         /* { dg-warning "called from here" } */
+       return q () + 1;         /* { dg-message "called from here" } */
 }
Index: gcc/testsuite/gcc.dg/winline-10.c
===================================================================
--- gcc/testsuite/gcc.dg/winline-10.c   (revision 227880)
+++ gcc/testsuite/gcc.dg/winline-10.c   (working copy)
@@ -9,9 +9,9 @@ inline void f (x)       /* { dg-warning "inlin
   asm ("");
 }
 
 void g (struct s x)
 {
-  f (x);               /* { dg-warning "called from here" "" } */
+  f (x);               /* { dg-message "called from here" "" } */
 }
 
 void f (int x);                /* { dg-warning "follows non-prototype 
definition" } */
Index: gcc/testsuite/gcc.dg/pr49243.c
===================================================================
--- gcc/testsuite/gcc.dg/pr49243.c      (revision 227880)
+++ gcc/testsuite/gcc.dg/pr49243.c      (working copy)
@@ -18,8 +18,8 @@ static inline int wrapper(const char **s
 }
 
 void parse(const char *data)
 {
     const char *s = data;
-    if (!(wrapper(&s) == -1 && (s - data) == 1)) /* { dg-warning "called from 
here" } */
+    if (!(wrapper(&s) == -1 && (s - data) == 1)) /* { dg-message "called from 
here" } */
        __builtin_abort();
 }
Index: gcc/testsuite/gcc.dg/always_inline3.c
===================================================================
--- gcc/testsuite/gcc.dg/always_inline3.c       (revision 227880)
+++ gcc/testsuite/gcc.dg/always_inline3.c       (working copy)
@@ -4,8 +4,8 @@ int do_something_evil (void);
 inline __attribute__ ((always_inline)) void
 q2(void) /* { dg-error "recursive inlining" } */
 {
   if (do_something_evil ())
     return;
-  q2();                        /* { dg-error "called from here" } */
+  q2();                        /* { dg-message "called from here" } */
   q2(); /* With -O2 we don't warn here, it is eliminated by tail recursion.  */
 }
Index: gcc/testsuite/gcc.dg/winline-3.c
===================================================================
--- gcc/testsuite/gcc.dg/winline-3.c    (revision 227880)
+++ gcc/testsuite/gcc.dg/winline-3.c    (working copy)
@@ -15,7 +15,7 @@ inline int q(void) /* { dg-warning "max-
        big();
        big();
 }
 inline int t (void)
 {
-       return q ();             /* { dg-warning "called from here" "" } */
+       return q ();             /* { dg-message "called from here" "" } */
 }
Index: gcc/testsuite/gcc.dg/winline-7.c
===================================================================
--- gcc/testsuite/gcc.dg/winline-7.c    (revision 227880)
+++ gcc/testsuite/gcc.dg/winline-7.c    (working copy)
@@ -9,7 +9,7 @@ inline void *q (void) /* { dg-warning "(
 {
        return alloca (10);
 }
 inline void *t (void)
 {
-       return q ();             /* { dg-warning "called from here" } */
+       return q ();             /* { dg-message "called from here" } */
 }
Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c   (revision 227880)
+++ gcc/tree-inline.c   (working copy)
@@ -4452,11 +4452,14 @@ expand_call_inline (basic_block bb, gimp
          /* PR 20090218-1_0.c. Body can be provided by another module. */
          && (reason != CIF_BODY_NOT_AVAILABLE || !flag_generate_lto))
        {
          error ("inlining failed in call to always_inline %q+F: %s", fn,
                 cgraph_inline_failed_string (reason));
-         error ("called from here");
+         if (input_location != UNKNOWN_LOCATION)
+           /* ??? Use gimple_location (stmt) instead ? */
+           inform (input_location, "called from here");
+         gcc_checking_assert (input_location != UNKNOWN_LOCATION);
        }
       else if (warn_inline
               && DECL_DECLARED_INLINE_P (fn)
               && !DECL_NO_INLINE_WARNING_P (fn)
               && !DECL_IN_SYSTEM_HEADER (fn)
@@ -4465,13 +4468,19 @@ expand_call_inline (basic_block bb, gimp
               /* Do not warn about not inlined recursive calls.  */
               && !cg_edge->recursive_p ()
               /* Avoid warnings during early inline pass. */
               && symtab->global_info_ready)
        {
-         warning (OPT_Winline, "inlining failed in call to %q+F: %s",
-                  fn, _(cgraph_inline_failed_string (reason)));
-         warning (OPT_Winline, "called from here");
+         /* FIXME: input_location should never be UNKNOWN_LOCATION
+            here, but it seems it can happen:
+            https://sourceware.org/ml/libc-alpha/2014-12/msg00300.html  */
+         if (warning (OPT_Winline, "inlining failed in call to %q+F: %s",
+                      fn, _(cgraph_inline_failed_string (reason)))
+             && input_location != UNKNOWN_LOCATION)
+           /* ??? Use gimple_location (stmt) instead ? */
+           inform (input_location, "called from here");
+         gcc_checking_assert (input_location != UNKNOWN_LOCATION);
        }
       goto egress;
     }
   fn = cg_edge->callee->decl;
   cg_edge->callee->get_untransformed_body ();
@@ -4532,10 +4541,11 @@ expand_call_inline (basic_block bb, gimp
      not refer to them in any way to not break GC for locations.  */
   if (gimple_block (stmt))
     {
       id->block = make_node (BLOCK);
       BLOCK_ABSTRACT_ORIGIN (id->block) = fn;
+      /* FIXME: gimple_location (stmt) ?  */
       BLOCK_SOURCE_LOCATION (id->block) = LOCATION_LOCUS (input_location);
       prepend_lexical_block (gimple_block (stmt), id->block);
     }
 
   /* Local declarations will be replaced by their equivalents in this

Reply via email to