From: Jan Hubicka Date: Fri, 5 Oct 2012 11:43:38 +0000 (+0200) Subject: re PR c/33763 (Bogus inlining failed in call to `xxx': redefined extern inline functi... X-Git-Tag: misc/gccgo-go1_1_2~396 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfc61b40d43b722b8a57868ae2df92c345684ec9;p=thirdparty%2Fgcc.git re PR c/33763 (Bogus inlining failed in call to `xxx': redefined extern inline functions are not considered for inlining) PR tree-optimization/33763 * tree-inline.c (expand_call_inline): Silently ignore always_inline attribute for redefined extern inline functions. * c-c++-common/pr33763.c: New test. From-SVN: r192119 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e9df431a20d9..93a143e1b9cf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2012-10-05 Jan Hubicka + Jakub Jelinek + + PR tree-optimization/33763 + * tree-inline.c (expand_call_inline): Silently ignore always_inline + attribute for redefined extern inline functions. + 2012-10-04 Jan Hubicka * tree-vectorizer.h (vect_estimate_min_profitable_iters): Remove. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 84d7e86e83f3..2ee908b70869 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2012-10-05 Jakub Jelinek + PR tree-optimization/33763 + * c-c++-common/pr33763.c: New test. + PR tree-optimization/54810 * gcc.dg/tree-ssa/vrp85.c: New test. diff --git a/gcc/testsuite/c-c++-common/pr33763.c b/gcc/testsuite/c-c++-common/pr33763.c new file mode 100644 index 000000000000..dbdfa77fc3d0 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr33763.c @@ -0,0 +1,60 @@ +/* PR tree-optimization/33763 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef struct +{ + void *a; + void *b; +} T; +extern void *foo (const char *, const char *); +extern void *bar (void *, const char *, T); +extern int baz (const char *, int); + +extern inline __attribute__ ((always_inline, gnu_inline)) int +baz (const char *x, int y) +{ + return 2; +} + +int +baz (const char *x, int y) +{ + return 1; +} + +int xa, xb; + +static void * +inl (const char *x, const char *y) +{ + T t = { &xa, &xb }; + int *f = (int *) __builtin_malloc (sizeof (int)); + const char *z; + int o = 0; + void *r = 0; + + for (z = y; *z; z++) + { + if (*z == 'r') + o |= 1; + if (*z == 'w') + o |= 2; + } + if (o == 1) + *f = baz (x, 0); + if (o == 2) + *f = baz (x, 1); + if (o == 3) + *f = baz (x, 2); + + if (o && *f > 0) + r = bar (f, "w", t); + return r; +} + +void * +foo (const char *x, const char *y) +{ + return inl (x, y); +} diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index a585c0b88dc7..d6fbf50dae96 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3814,6 +3814,12 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) goto egress; if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) + /* For extern inline functions that get redefined we always + silently ignored always_inline flag. Better behaviour would + be to be able to keep both bodies and use extern inline body + for inlining, but we can't do that because frontends overwrite + the body. */ + && !cg_edge->callee->local.redefined_extern_inline /* Avoid warnings during early inline pass. */ && cgraph_global_info_ready /* PR 20090218-1_0.c. Body can be provided by another module. */