OSDN Git Service

2010-04-23 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 23 Apr 2010 15:18:24 +0000 (15:18 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 23 Apr 2010 15:18:24 +0000 (15:18 +0000)
PR lto/43455
* tree-inline.c (tree_can_inline_p): Also check compatibility
of return types.

* gcc.dg/lto/20100423-1_0.c: New testcase.
* gcc.dg/lto/20100423-1_1.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158669 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/lto/20100423-1_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/20100423-1_1.c [new file with mode: 0644]
gcc/tree-inline.c

index 45ff41d..586f1e6 100644 (file)
@@ -1,3 +1,9 @@
+2010-04-23  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/43455
+       * tree-inline.c (tree_can_inline_p): Also check compatibility
+       of return types.
+
 2010-04-23  Martin Jambor  <mjambor@suse.cz>
 
        PR tree-optimization/43846
index 9dccbad..28b1201 100644 (file)
@@ -1,3 +1,9 @@
+2010-04-23  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/43455
+       * gcc.dg/lto/20100423-1_0.c: New testcase.
+       * gcc.dg/lto/20100423-1_1.c: Likewise.
+
 2010-04-23  Martin Jambor  <mjambor@suse.cz>
 
        PR tree-optimization/43846
diff --git a/gcc/testsuite/gcc.dg/lto/20100423-1_0.c b/gcc/testsuite/gcc.dg/lto/20100423-1_0.c
new file mode 100644 (file)
index 0000000..58456d4
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-lto-do run } */
+/* { dg-lto-options {{-O2 -flto}} } */
+
+struct bar {int x;};
+extern struct bar foo(void);
+int main()
+{
+  struct bar x=foo();
+  return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20100423-1_1.c b/gcc/testsuite/gcc.dg/lto/20100423-1_1.c
new file mode 100644 (file)
index 0000000..8b159d2
--- /dev/null
@@ -0,0 +1,7 @@
+typedef struct{int x;} bar;
+bar foo (void)
+{
+  bar x;
+  return x;
+}
+
index 1d3008b..59661a7 100644 (file)
@@ -5082,7 +5082,7 @@ tree_can_inline_p (struct cgraph_edge *e)
        return false;
     }
 #endif
-  tree caller, callee;
+  tree caller, callee, lhs;
 
   caller = e->caller->decl;
   callee = e->callee->decl;
@@ -5108,8 +5108,16 @@ tree_can_inline_p (struct cgraph_edge *e)
       return false;
     }
 
+  /* Do not inline calls where we cannot triviall work around mismatches
+     in argument or return types.  */
   if (e->call_stmt
-      && !gimple_check_call_args (e->call_stmt))
+      && ((DECL_RESULT (callee)
+          && !DECL_BY_REFERENCE (DECL_RESULT (callee))
+          && (lhs = gimple_call_lhs (e->call_stmt)) != NULL_TREE
+          && !useless_type_conversion_p (TREE_TYPE (DECL_RESULT (callee)),
+                                         TREE_TYPE (lhs))
+          && !fold_convertible_p (TREE_TYPE (DECL_RESULT (callee)), lhs))
+         || !gimple_check_call_args (e->call_stmt)))
     {
       e->inline_failed = CIF_MISMATCHED_ARGUMENTS;
       gimple_call_set_cannot_inline (e->call_stmt, true);