This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Use DISREGARD_INLINE_LIMITS_P even for C++ gnu_inline functions that were recently added
On Wed, Aug 29, 2007 at 10:43:30PM +0200, Richard Guenther wrote:
> On 8/29/07, Jakub Jelinek <jakub@redhat.com> wrote:
> > 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?
>
> Yes this makes sense, but is gnu_inline attribute really marking the
> function as GNU extern inline regardless of other storage class qualifiers?
> Like for example
>
> static inline __attribute__((gnu_inline)) int foo();
You are right. Here is a patch that sets DECL_DISREGARD_INLINE_LIMITS
in the C++ FE instead. Ok for trunk?
2007-08-30 Jakub Jelinek <jakub@redhat.com>
* decl.c (start_preparsed_function): Set
DECL_DISREGARD_INLINE_LIMITS for GNU_INLINE_P functions.
* gcc.dg/inline-24.c: New test.
* g++.dg/opt/inline11.C: New test.
--- gcc/cp/decl.c.jj 2007-08-28 18:03:19.000000000 +0200
+++ gcc/cp/decl.c 2007-08-30 13:33:25.000000000 +0200
@@ -10892,6 +10892,7 @@ start_preparsed_function (tree decl1, tr
DECL_EXTERNAL (decl1) = 1;
DECL_NOT_REALLY_EXTERN (decl1) = 0;
DECL_INTERFACE_KNOWN (decl1) = 1;
+ DECL_DISREGARD_INLINE_LIMITS (decl1) = 1;
}
if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl1))
--- gcc/testsuite/gcc.dg/inline-24.c.jj 2007-08-30 10:40:05.000000000 +0200
+++ gcc/testsuite/gcc.dg/inline-24.c 2007-08-30 10:40:05.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-30 10:40:05.000000000 +0200
+++ gcc/testsuite/g++.dg/opt/inline11.C 2007-08-30 10:40:05.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