]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR middle-end/49139 fix always_inline diagnostics
authorChristian Bruel <chrbr@gcc.gnu.org>
Tue, 21 Jun 2011 06:42:05 +0000 (08:42 +0200)
committerChristian Bruel <chrbr@gcc.gnu.org>
Tue, 21 Jun 2011 06:42:05 +0000 (08:42 +0200)
From-SVN: r175239

16 files changed:
gcc/cgraphunit.c
gcc/ipa-inline-transform.c
gcc/testsuite/g++.dg/ipa/devirt-7.C
gcc/testsuite/gcc.dg/20051201-1.c
gcc/testsuite/gcc.dg/always_inline.c
gcc/testsuite/gcc.dg/always_inline2.c
gcc/testsuite/gcc.dg/always_inline3.c
gcc/testsuite/gcc.dg/debug/pr41264-1.c
gcc/testsuite/gcc.dg/fail_always_inline.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/inline-22.c
gcc/testsuite/gcc.dg/lto/20090218-1_0.c
gcc/testsuite/gcc.dg/lto/20090218-1_1.c
gcc/testsuite/gcc.dg/torture/pta-structcopy-1.c
gcc/testsuite/gcc.dg/uninit-pred-5_a.c
gcc/testsuite/gcc.dg/uninit-pred-5_b.c
gcc/tree-inline.c

index 6683d2a5df375f62cec0792d94bdd90ca3ce11ed..de9bbe3edeb611a07d44e689fb1e15d4436f9058 100644 (file)
@@ -986,6 +986,14 @@ process_function_and_variable_attributes (struct cgraph_node *first,
          DECL_ATTRIBUTES (decl) = remove_attribute ("weakref",
                                                     DECL_ATTRIBUTES (decl));
        }
+
+      if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (decl))
+         && !DECL_DECLARED_INLINE_P (decl)
+         /* redefining extern inline function makes it DECL_UNINLINABLE.  */
+         && !DECL_UNINLINABLE (decl))
+       warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes,
+                   "always_inline function might not be inlinable");
+     
       process_common_attributes (decl);
     }
   for (vnode = varpool_nodes; vnode != first_var; vnode = vnode->next)
index 2e1375437d5b1a71c7475eed9526278a7c067343..39c0138956ed03f57510f4c922dc9f80486976c9 100644 (file)
@@ -348,8 +348,7 @@ inline_transform (struct cgraph_node *node)
 {
   unsigned int todo = 0;
   struct cgraph_edge *e;
-  bool inline_p = false;
-
   /* FIXME: Currently the pass manager is adding inline transform more than
      once to some clones.  This needs revisiting after WPA cleanups.  */
   if (cfun->after_inlining)
@@ -361,20 +360,17 @@ inline_transform (struct cgraph_node *node)
     save_inline_function_body (node);
 
   for (e = node->callees; e; e = e->next_callee)
+    cgraph_redirect_edge_call_stmt_to_callee (e);
+
+  timevar_push (TV_INTEGRATION);
+  if (node->callees)
     {
-      cgraph_redirect_edge_call_stmt_to_callee (e);
-      if (!e->inline_failed || warn_inline)
-        inline_p = true;
       /* Redirecting edges might lead to a need for vops to be recomputed.  */
       todo |= TODO_update_ssa_only_virtuals;
-    }
-
-  if (inline_p)
-    {
-      timevar_push (TV_INTEGRATION);
       todo = optimize_inline_calls (current_function_decl);
-      timevar_pop (TV_INTEGRATION);
     }
+  timevar_pop (TV_INTEGRATION);
+
   cfun->always_inline_functions_inlined = true;
   cfun->after_inlining = true;
   return todo | execute_fixup_cfg ();
index ac147b57599fb1adaa297de14c60ac97a7ee9586..1c59122303dc1b286ef7a571aa5c51c642302e5f 100644 (file)
@@ -56,7 +56,7 @@ int __attribute__ ((noinline,noclone)) get_input(void)
   return 1;
 }
 
-int __attribute__ ((always_inline))
+int inline __attribute__ ((always_inline))
 A::middleman_1 (int i)
 {
   return this->foo (i);
index 8e77986296e1371c7365f5b8ade1e65fc12add2b..bc8e7926be04eda82467d6d09a6b5877feed35b4 100644 (file)
@@ -2,7 +2,7 @@
    tree_flow_call_edges_add.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O1 -fprofile-generate" } */
+/* { dg-options "-O1 -fprofile-generate -Wno-attributes" } */
 
 static __attribute__ ((always_inline)) void 
 baz ()
index 08119f1a254cef93b3a7d39f3b3f7946cecac3a4..482a0a2b46c6509422ad18fa33c1d0e05821bb56 100644 (file)
@@ -1,8 +1,8 @@
 /* { dg-do compile } */
-/* { dg-options "-Winline -O2" } */
+/* { dg-options "-O2" } */
 #include <stdarg.h>
 inline __attribute__ ((always_inline)) void
-e(int t, ...) /* { dg-message "sorry\[^\n\]*variable argument" "" } */
+e(int t, ...) /* { dg-error "variable argument lists" } */
 {
   va_list q;
   va_start (q, t);
index c65df24ea601e6bf7130dca20b9c6a9991701990..4f1634e13488d7c838f01621bda1939302f01441 100644 (file)
@@ -1,8 +1,8 @@
 /* { dg-do compile } */
-/* { dg-options "-Winline -O2" } */
-inline __attribute__ ((always_inline)) void t(void); /* { dg-message "sorry\[^\n\]*body not available" "" } */
+/* { dg-options "-O2" } */
+inline __attribute__ ((always_inline)) void t(void); /* { dg-error "body not available" } */
 void
 q(void)
 {
-  t();                                 /* { dg-message "sorry\[^\n\]*called from here" "" } */
+  t();                                 /* { dg-error "called from here" } */
 }
index 97c80aa521718375e201998408045220799734a5..80ea314741b9310bf84de209b19835b4305b2b77 100644 (file)
@@ -1,11 +1,11 @@
 /* { dg-do compile } */
-/* { dg-options "-Winline -O2" } */
+/* { dg-options "-O2" } */
 int do_something_evil (void);
 inline __attribute__ ((always_inline)) void
-q2(void) /* { dg-message "sorry\[^\n\]*recursive" "" } */
+q2(void) /* { dg-error "recursive inlining" } */
 {
   if (do_something_evil ())
     return;
-  q2();                        /* { dg-message "sorry\[^\n\]*called from here" "" } */
+  q2();                        /* { dg-error "called from here" } */
   q2(); /* With -O2 we don't warn here, it is eliminated by tail recursion.  */
 }
index 34bdcfe20474888a572e322895f3cc55ffb7d839..7d03e51ae37ae71760289ad2e196a1567e61ca18 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-options "-Wno-attributes" } */
 
 #if (__SIZEOF_INT__ <= 2)      
 typedef unsigned long hashval_t;
diff --git a/gcc/testsuite/gcc.dg/fail_always_inline.c b/gcc/testsuite/gcc.dg/fail_always_inline.c
new file mode 100644 (file)
index 0000000..4b196ac
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+
+extern __attribute__ ((always_inline)) void
+ bar() { } /* { dg-warning "function might not be inlinable" } */
+
+void
+f()
+{
+  bar(); 
+}
+
index 6d790f97402304a40fc5da445cd8282681b4b6ff..1785e1ce6d5f49b6f3e3e5a452eaa9ae887d9467 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-funit-at-a-time" } */
+/* { dg-options "-funit-at-a-time -Wno-attributes" } */
 /* Verify we can inline without a complete prototype and with promoted
    arguments.  See also PR32492.  */
 __attribute__((always_inline)) void f1() {}
index 1dc9ee0854071162d26bddfbb2e764abebf3a24c..750c2027510c53d5eb2762520967936140cce215 100644 (file)
@@ -1,4 +1,4 @@
-void set_mem_alias_set ()  __attribute__ ((always_inline));
+void inline set_mem_alias_set ()  __attribute__ ((always_inline));
 void emit_push_insn () {
   set_mem_alias_set ();
 }
index 33d4fb000f31683372fbf1db4dc2ad21ce691237..7db2c85e4cec7a716c1b682c9cd7549205eadf15 100644 (file)
@@ -4,6 +4,6 @@ int main(void)
 }
 static void  __attribute__ ((noinline)) get_mem_attrs () {
 }
-void  __attribute__ ((always_inline)) set_mem_alias_set () {
+void  inline __attribute__ ((always_inline)) set_mem_alias_set () {
   get_mem_attrs ();
 }
index 5dc041b0eddbbd312d4111415ef54ca449299d1d..97e8946da544d5056f4b71e63defaf07e76434ea 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-fdump-tree-ealias" } */
+/* { dg-options "-fdump-tree-ealias -Wno-attributes" } */
 /* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
 
 struct X
index 845f3c46124a0952cba75fa7df199b7203278ef1..7fa0b253fb13e10c00357fd418bf75a9dbd76e24 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-Wuninitialized -O2" } */
+/* { dg-options "-Wuninitialized -Wno-attributes -O2" } */
 
 int g;
 int bar();
index 13f1e31f805fb97035a1edbeb0f6c9e06ec32fe7..9760fa8a5c8c950a6f75c730095753325b7a7616 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-Wuninitialized -O2" } */
+/* { dg-options "-Wuninitialized -Wno-attributes -O2" } */
 
 int g;
 int bar();
index dc3288b5b37e778b34d61811ac49fbe2cd32423c..c8b9f4c19da34c728185d8e19869f3fc8de5b527 100644 (file)
@@ -3192,7 +3192,7 @@ tree_inlinable_function_p (tree fn)
         As a bonus we can now give more details about the reason why a
         function is not inlinable.  */
       if (always_inline)
-       sorry (inline_forbidden_reason, fn);
+       error (inline_forbidden_reason, fn);
       else if (do_warning)
        warning (OPT_Winline, inline_forbidden_reason, fn);
 
@@ -3742,11 +3742,13 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
 
       if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn))
          /* Avoid warnings during early inline pass. */
-         && cgraph_global_info_ready)
+         && cgraph_global_info_ready
+         /* PR 20090218-1_0.c. Body can be provided by another module. */
+         && (reason != CIF_BODY_NOT_AVAILABLE || !flag_generate_lto))
        {
-         sorry ("inlining failed in call to %q+F: %s", fn,
-                _(cgraph_inline_failed_string (reason)));
-         sorry ("called from here");
+         error ("inlining failed in call to always_inline %q+F: %s", fn,
+                cgraph_inline_failed_string (reason));
+         error ("called from here");
        }
       else if (warn_inline
               && DECL_DECLARED_INLINE_P (fn)