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] Use DISREGARD_INLINE_LIMITS_P even for C++ gnu_inline functions that were recently added


On Tue, Aug 28, 2007 at 11:09:14AM +0200, Richard Guenther wrote:
> 2007-08-27  Richard Guenther  <rguenther@suse.de>
> 
> 	* tree.h (DECL_DISREGARD_INLINE_LIMITS): New.
...

IMHO we should use the same for C++ gnu_inline functions,
they are supposed to work the same as C gnu_inline functions
as much as possible...

Ok for trunk?

2007-08-29  Jakub Jelinek  <jakub@redhat.com>

	* c-common.c (handle_gnu_inline_attribute): Set
	DECL_DISREGARD_INLINE_LIMITS.

	* gcc.dg/inline-24.c: New test.
	* g++.dg/opt/inline11.C: New test.

--- gcc/c-common.c.jj	2007-08-28 11:38:37.000000000 +0200
+++ gcc/c-common.c	2007-08-29 18:50:30.000000000 +0200
@@ -4888,8 +4888,9 @@ handle_gnu_inline_attribute (tree *node,
 {
   if (TREE_CODE (*node) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (*node))
     {
-      /* Do nothing else, just set the attribute.  We'll get at
-	 it later with lookup_attribute.  */
+      /* Set the attribute and mark it for disregarding inline
+	 limits.  */
+      DECL_DISREGARD_INLINE_LIMITS (*node) = 1;
     }
   else
     {
--- gcc/testsuite/gcc.dg/inline-24.c.jj	2007-08-29 19:10:17.000000000 +0200
+++ gcc/testsuite/gcc.dg/inline-24.c	2007-08-29 19:09:53.000000000 +0200
@@ -0,0 +1,28 @@
+/* Verify that gnu_inline inlines disregard inlining limits.  */
+/* { dg-do link } */
+/* { dg-options "-O2" } */
+
+extern int foo (int);
+extern int baz (int);
+
+extern inline __attribute__((gnu_inline))
+int foo (int x)
+{
+  int i;
+  if (!__builtin_constant_p (x))
+    {
+#define B(n) baz (1##n) + baz (2##n) + baz (3##n) \
+	     + baz (4##n) + baz (5##n) + baz (6##n)
+#define C(n) B(1##n) + B(2##n) + B(3##n) + B(4##n) + B(5##n) + B(6##n)
+#define D(n) C(1##n) + C(2##n) + C(3##n) + C(4##n) + C(5##n) + C(6##n)
+      return D(0) + D(1) + D(2) + D(3) + D(4)
+	     + D(5) + D(6) + D(7) + D(8) + D(9);
+    }
+  return 0;
+}
+
+int
+main (void)
+{
+  return foo (0);
+}
--- gcc/testsuite/g++.dg/opt/inline11.C.jj	2007-08-29 19:11:10.000000000 +0200
+++ gcc/testsuite/g++.dg/opt/inline11.C	2007-08-29 19:09:53.000000000 +0200
@@ -0,0 +1,28 @@
+/* Verify that gnu_inline inlines disregard inlining limits.  */
+/* { dg-do link } */
+/* { dg-options "-O2" } */
+
+extern int foo (int);
+extern int baz (int);
+
+extern inline __attribute__((gnu_inline))
+int foo (int x)
+{
+  int i;
+  if (!__builtin_constant_p (x))
+    {
+#define B(n) baz (1##n) + baz (2##n) + baz (3##n) \
+	     + baz (4##n) + baz (5##n) + baz (6##n)
+#define C(n) B(1##n) + B(2##n) + B(3##n) + B(4##n) + B(5##n) + B(6##n)
+#define D(n) C(1##n) + C(2##n) + C(3##n) + C(4##n) + C(5##n) + C(6##n)
+      return D(0) + D(1) + D(2) + D(3) + D(4)
+	     + D(5) + D(6) + D(7) + D(8) + D(9);
+    }
+  return 0;
+}
+
+int
+main (void)
+{
+  return foo (0);
+}


	Jakub


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