This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][LTO] Fix PR43218 (again)


This fixes PR43218 for non (former) -flto.  We need to mark edges
as non-inlineable that have non-conforming ABI - for now just detect
mismatching return types (as we do elsewhere).

Bootstrap and regtest pending, ok if that succeeds?

Thanks,
Richard.

2010-11-24  Richard Guenther  <rguenther@suse.de>

	PR lto/43218
	* lto-symtab.c (lto_cgraph_replace_node): Mark edges with
	conflicting function signatures as non-inlineable.

	* gcc.dg/lto/20100423-1_0.c: Enable for all LTO modes.

Index: gcc/lto-symtab.c
===================================================================
*** gcc/lto-symtab.c	(revision 167115)
--- gcc/lto-symtab.c	(working copy)
*************** lto_cgraph_replace_node (struct cgraph_n
*** 210,215 ****
--- 210,216 ----
  {
    struct cgraph_edge *e, *next;
    bool no_aliases_please = false;
+   bool compatible_p;
  
    if (cgraph_dump_file)
      {
*************** lto_cgraph_replace_node (struct cgraph_n
*** 240,249 ****
--- 241,259 ----
      }
  
    /* Redirect all incoming edges.  */
+   compatible_p
+     = gimple_types_compatible_p (TREE_TYPE (TREE_TYPE (prevailing_node->decl)),
+ 				 TREE_TYPE (TREE_TYPE (node->decl)), GTC_DIAG);
    for (e = node->callers; e; e = next)
      {
        next = e->next_caller;
        cgraph_redirect_edge_callee (e, prevailing_node);
+       /* If there is a mismatch between the supposed callee return type and
+ 	 the real one do not attempt to inline this function.
+ 	 ???  We really need a way to match function signatures for ABI
+ 	 compatibility and perform related promotions at inlining time.  */
+       if (!compatible_p)
+ 	e->call_stmt_cannot_inline_p = 1;
      }
    /* Redirect incomming references.  */
    ipa_clone_refering (prevailing_node, NULL, &node->ref_list);
Index: gcc/testsuite/gcc.dg/lto/20100423-1_0.c
===================================================================
*** gcc/testsuite/gcc.dg/lto/20100423-1_0.c	(revision 167115)
--- gcc/testsuite/gcc.dg/lto/20100423-1_0.c	(working copy)
***************
*** 1,5 ****
  /* { dg-lto-do run } */
- /* { dg-lto-options {{-O2 -flto -flto-partition=none}} } */
  
  struct bar {int x;};
  extern struct bar foo(void);
--- 1,4 ----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]