diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-07-29 14:00:43 +0200 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2016-07-29 12:00:43 +0000 |
commit | 673a107a4003834ec3d6e8f413bda3c13b6062e7 (patch) | |
tree | 403f2bdea676b39e3c28c39a2297523e8092bf21 /gcc | |
parent | a5b5c8b62494c0089bfc60ad5dfeae4e7f4c6690 (diff) | |
download | gcc-673a107a4003834ec3d6e8f413bda3c13b6062e7.zip gcc-673a107a4003834ec3d6e8f413bda3c13b6062e7.tar.gz gcc-673a107a4003834ec3d6e8f413bda3c13b6062e7.tar.bz2 |
re PR c/71969 (Wrong setting of DECL_DISREGARD_INLINE_LIMITS in the C FE)
PR c/71969
* c-decl.c (finish_function): Only set DECL_DISREGARD_INLINE_LIMITS
on GNU extern inline functions.
* gcc.dg/alias-11.c (add_cfi, new_cfi): Change __inline__ to
static __inline__.
* gcc.dg/pr71969-1.c: New test.
* gcc.dg/pr71969-2.c: New test.
* gcc.dg/pr71969-3.c: New test.
From-SVN: r238862
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/alias-11.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr71969-1.c | 37 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr71969-2.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr71969-3.c | 38 |
7 files changed, 118 insertions, 3 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index a47b8a3..d512a3d 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2016-07-29 Jakub Jelinek <jakub@redhat.com> + + PR c/71969 + * c-decl.c (finish_function): Only set DECL_DISREGARD_INLINE_LIMITS + on GNU extern inline functions. + 2016-07-29 Marek Polacek <polacek@redhat.com> PR c/71583 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 41aabeb..f2773c5 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -9262,7 +9262,9 @@ finish_function (void) /* For GNU C extern inline functions disregard inline limits. */ if (DECL_EXTERNAL (fndecl) - && DECL_DECLARED_INLINE_P (fndecl)) + && DECL_DECLARED_INLINE_P (fndecl) + && (flag_gnu89_inline + || lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (fndecl)))) DECL_DISREGARD_INLINE_LIMITS (fndecl) = 1; /* Genericize before inlining. Delay genericizing nested functions diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c1df9e9..1bc34b9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2016-07-29 Jakub Jelinek <jakub@redhat.com> + + PR c/71969 + * gcc.dg/alias-11.c (add_cfi, new_cfi): Change __inline__ to + static __inline__. + * gcc.dg/pr71969-1.c: New test. + * gcc.dg/pr71969-2.c: New test. + * gcc.dg/pr71969-3.c: New test. + 2016-07-29 Marek Polacek <polacek@redhat.com> PR c/71574 diff --git a/gcc/testsuite/gcc.dg/alias-11.c b/gcc/testsuite/gcc.dg/alias-11.c index 36175d7..7629c6c 100644 --- a/gcc/testsuite/gcc.dg/alias-11.c +++ b/gcc/testsuite/gcc.dg/alias-11.c @@ -24,7 +24,7 @@ dw_cfi_node *cie_cfi_head; unsigned fde_table_in_use; dw_fde_node *fde_table; -__inline__ void +static __inline__ void add_cfi (dw_cfi_node **list_head, dw_cfi_node *cfi) { dw_cfi_node **p; @@ -35,7 +35,7 @@ add_cfi (dw_cfi_node **list_head, dw_cfi_node *cfi) *p = cfi; } -__inline__ struct dw_cfi_struct * +static __inline__ struct dw_cfi_struct * new_cfi (void) { dw_cfi_node *cfi = (dw_cfi_node *) malloc (sizeof (dw_cfi_node)); diff --git a/gcc/testsuite/gcc.dg/pr71969-1.c b/gcc/testsuite/gcc.dg/pr71969-1.c new file mode 100644 index 0000000..a39b05e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr71969-1.c @@ -0,0 +1,37 @@ +/* PR c/71969 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fno-gnu89-inline -O2 -fdump-tree-einline-details" } */ + +volatile int v; +#define S v++; +#define S10 S S S S S S S S S S +#define S100 S10 S10 S10 S10 S10 S10 S10 S10 S10 S10 + +extern inline void +foo (void) { S100 } + +inline void +bar (void) { S100 } + +static inline void +baz (void) { S100 } + +int +main () +{ + foo (); + foo (); + foo (); + foo (); + bar (); + bar (); + bar (); + bar (); + baz (); + baz (); + baz (); + baz (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "will not early inline" 12 "einline" } } */ diff --git a/gcc/testsuite/gcc.dg/pr71969-2.c b/gcc/testsuite/gcc.dg/pr71969-2.c new file mode 100644 index 0000000..f434fd0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr71969-2.c @@ -0,0 +1,23 @@ +/* PR c/71969 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fno-gnu89-inline -O2 -fdump-tree-einline-details" } */ + +volatile int v; +#define S v++; +#define S10 S S S S S S S S S S +#define S100 S10 S10 S10 S10 S10 S10 S10 S10 S10 S10 + +extern inline __attribute__((gnu_inline)) void +foo (void) { S100 } + +int +main () +{ + foo (); + foo (); + foo (); + foo (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "Inlining foo into main" 4 "einline" } } */ diff --git a/gcc/testsuite/gcc.dg/pr71969-3.c b/gcc/testsuite/gcc.dg/pr71969-3.c new file mode 100644 index 0000000..583d89d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr71969-3.c @@ -0,0 +1,38 @@ +/* PR c/71969 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -fgnu89-inline -O2 -fdump-tree-einline-details" } */ + +volatile int v; +#define S v++; +#define S10 S S S S S S S S S S +#define S100 S10 S10 S10 S10 S10 S10 S10 S10 S10 S10 + +extern inline void +foo (void) { S100 } + +inline void +bar (void) { S100 } + +static inline void +baz (void) { S100 } + +int +main () +{ + foo (); + foo (); + foo (); + foo (); + bar (); + bar (); + bar (); + bar (); + baz (); + baz (); + baz (); + baz (); + return 0; +} + +/* { dg-final { scan-tree-dump-times "will not early inline" 8 "einline" } } */ +/* { dg-final { scan-tree-dump-times "Inlining foo into main" 4 "einline" } } */ |