public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: PATCH to C++ template inlining
@ 2003-03-06 13:25 Andreas Tobler
  2003-03-06 18:23 ` Andreas Tobler
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Tobler @ 2003-03-06 13:25 UTC (permalink / raw)
  To: jason; +Cc: gcc-patches, bkoz

Hi Jason,

I hope I didn't miss something.

This patch breaks the libstdc++ build on powerpc darwin. (Head)

2003-03-03  Jason Merrill  <jason@redhat.com>

	* tree-inline.c (find_builtin_longjmp_call): Save and restore
	lineno and input_filename.
	(find_alloca_call): Likewise.
	(inlinable_function_p): Run the langhook earlier.

cp/
	* decl.c (start_function): Clear DECL_NUM_STMTS.


I reverted the whole tree just before this patch and it builds. Updating
these two files makes the build break.
For break details see here:
http://gcc.gnu.org/ml/libstdc++/2003-03/msg00040.html

Also, if you need some further info, let me know. I can directly try with
a stage 2 build and test.

Thank you in advance,

Andreas


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH to C++ template inlining
  2003-03-06 13:25 PATCH to C++ template inlining Andreas Tobler
@ 2003-03-06 18:23 ` Andreas Tobler
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Tobler @ 2003-03-06 18:23 UTC (permalink / raw)
  To: jason; +Cc: gcc-patches, bkoz

Andreas Tobler wrote:
> Hi Jason,
> 
> I hope I didn't miss something. 
> 
> This patch breaks the libstdc++ build on powerpc darwin. (Head)
> 
> 2003-03-03  Jason Merrill  <jason@redhat.com>
> 
> 	* tree-inline.c (find_builtin_longjmp_call): Save and restore
> 	lineno and input_filename.
> 	(find_alloca_call): Likewise.
> 	(inlinable_function_p): Run the langhook earlier.
> 
> cp/
> 	* decl.c (start_function): Clear DECL_NUM_STMTS.
> 
> 
> I reverted the whole tree just before this patch and it builds. Updating
> these two files makes the build break. 
> For break details see here:
> http://gcc.gnu.org/ml/libstdc++/2003-03/msg00040.html
> 
> Also, if you need some further info, let me know. I can directly try with
> a stage 2 build and test.

@@ -1022,9 +1037,6 @@
  	}
      }

-  if (inlinable && (*lang_hooks.tree_inlining.cannot_inline_tree_fn) (&fn))
-    inlinable = 0;

Putting this line back to its old place works. Though I have no clue 
what's going wrong.

Thanks,

Andreas


^ permalink raw reply	[flat|nested] 3+ messages in thread

* PATCH to C++ template inlining
@ 2003-03-03 21:27 Jason Merrill
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Merrill @ 2003-03-03 21:27 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 876 bytes --]

While investigating optimization/9767, I noticed a couple of minor bugs
with the inlining heuristics and function templates:

1) We were double-counting statements in templates; DECL_NUM_STMTS for a
   template instantiation would be the value for the original template plus
   the value for the instantiated version.
2) If an inlining candidate had not been instantiated yet,
   inlinable_function_p would use the DECL_NUM_STMTS value for the
   template, which tends to be lower than the value for the instantiated
   function.

Fixed thus.  Booted and tested i686-pc-linux-gnu, applied to trunk.

2003-03-03  Jason Merrill  <jason@redhat.com>

	* tree-inline.c (find_builtin_longjmp_call): Save and restore
	lineno and input_filename.
	(find_alloca_call): Likewise.
	(inlinable_function_p): Run the langhook earlier.

cp/
	* decl.c (start_function): Clear DECL_NUM_STMTS.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 2328 bytes --]

*** ./gcc/cp/decl.c.~1~	Mon Mar  3 00:09:03 2003
--- ./gcc/cp/decl.c	Mon Mar  3 01:35:45 2003
*************** start_function (tree declspecs, tree dec
*** 13548,13553 ****
--- 13548,13556 ----
    /* Start the statement-tree, start the tree now.  */
    begin_stmt_tree (&DECL_SAVED_TREE (decl1));
  
+   /* Don't double-count statements in templates.  */
+   DECL_NUM_STMTS (decl1) = 0;
+ 
    /* Let the user know we're compiling this function.  */
    announce_function (decl1);
  
*** ./gcc/tree-inline.c.~1~	Mon Mar  3 00:08:54 2003
--- ./gcc/tree-inline.c	Mon Mar  3 14:45:17 2003
*************** static tree
*** 895,901 ****
  find_alloca_call (exp)
       tree exp;
  {
!   return walk_tree (&exp, find_alloca_call_1, NULL, NULL);
  }
  
  static tree
--- 895,906 ----
  find_alloca_call (exp)
       tree exp;
  {
!   int line = lineno;
!   const char *file = input_filename;
!   tree ret = walk_tree (&exp, find_alloca_call_1, NULL, NULL);
!   lineno = line;
!   input_filename = file;
!   return ret;
  }
  
  static tree
*************** static tree
*** 921,927 ****
  find_builtin_longjmp_call (exp)
       tree exp;
  {
!   return walk_tree (&exp, find_builtin_longjmp_call_1, NULL, NULL);
  }
  
  /* Returns nonzero if FN is a function that can be inlined into the
--- 926,937 ----
  find_builtin_longjmp_call (exp)
       tree exp;
  {
!   int line = lineno;
!   const char *file = input_filename;
!   tree ret = walk_tree (&exp, find_builtin_longjmp_call_1, NULL, NULL);
!   lineno = line;
!   input_filename = file;
!   return ret;
  }
  
  /* Returns nonzero if FN is a function that can be inlined into the
*************** inlinable_function_p (fn, id)
*** 942,947 ****
--- 952,962 ----
    if (DECL_UNINLINABLE (fn))
      return 0;
  
+   /* Check this now so that we instantiate C++ templates before reading
+      DECL_NUM_STMTS.  */
+   if ((*lang_hooks.tree_inlining.cannot_inline_tree_fn) (&fn))
+     return 0;
+ 
    /* Assume it is not inlinable.  */
    inlinable = 0;
         
*************** inlinable_function_p (fn, id)
*** 1022,1030 ****
  	}
      }
  
-   if (inlinable && (*lang_hooks.tree_inlining.cannot_inline_tree_fn) (&fn))
-     inlinable = 0;
- 
    /* If we don't have the function body available, we can't inline
       it.  */
    if (! DECL_SAVED_TREE (fn))
--- 1037,1042 ----

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-03-06 18:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-06 13:25 PATCH to C++ template inlining Andreas Tobler
2003-03-06 18:23 ` Andreas Tobler
  -- strict thread matches above, loose matches on Subject: below --
2003-03-03 21:27 Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).