diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-04-05 22:10:13 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2005-04-05 22:10:13 +0200 |
commit | 4b2841117bd44ef5b9179c02151a507dc1bd23f5 (patch) | |
tree | d987044d0ed96299195ed52d4533e2376afd67de /gcc | |
parent | cae064e7982fb1a9f7e2fd8208e83199786aa39c (diff) | |
download | gcc-4b2841117bd44ef5b9179c02151a507dc1bd23f5.zip gcc-4b2841117bd44ef5b9179c02151a507dc1bd23f5.tar.gz gcc-4b2841117bd44ef5b9179c02151a507dc1bd23f5.tar.bz2 |
re PR tree-optimization/20076 (__builtin_return(__builtin_apply()) inlined incorrectly)
PR tree-optimization/20076
* tree-inline.c (inline_forbidden_p_1): Prevent inlining functions
that call __builtin_return or __builtin_apply_args.
* gcc.dg/builtin-apply4.c: New test.
From-SVN: r97653
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/builtin-apply4.c | 30 | ||||
-rw-r--r-- | gcc/tree-inline.c | 11 |
4 files changed, 50 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8b51e09..f903467 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-04-05 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/20076 + * tree-inline.c (inline_forbidden_p_1): Prevent inlining functions + that call __builtin_return or __builtin_apply_args. + 2005-04-05 Andrew MacLeod <amacleod@redhat.com> * lambda-code.c (lambda_loopnest_to_gcc_loopnest): Use update_stmt. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e9a68b3..79bfe23 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2005-04-05 Jakub Jelinek <jakub@redhat.com> + PR tree-optimization/20076 + * gcc.dg/builtin-apply4.c: New test. + PR preprocessor/19475 * gcc.dg/cpp/macspace1.c: New test. * gcc.dg/cpp/macspace2.c: New test. diff --git a/gcc/testsuite/gcc.dg/builtin-apply4.c b/gcc/testsuite/gcc.dg/builtin-apply4.c new file mode 100644 index 0000000..289694e --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtin-apply4.c @@ -0,0 +1,30 @@ +/* PR tree-optimization/20076 */ +/* { dg-options "-O2" } */ +/* { dg-do run } */ + +extern void abort (void); + +double +foo (int arg) +{ + if (arg != 116) + abort(); + return arg + 1; +} + +inline double +bar (int arg) +{ + foo (arg); + __builtin_return (__builtin_apply ((void (*) ()) foo, + __builtin_apply_args (), 16)); +} + +int +main (int argc, char **argv) +{ + if (bar (116) != 117.0) + abort (); + + return 0; +} diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 59a2d72..efa6e31 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1017,6 +1017,17 @@ inline_forbidden_p_1 (tree *nodep, int *walk_subtrees ATTRIBUTE_UNUSED, "it uses non-local goto"); return node; + case BUILT_IN_RETURN: + case BUILT_IN_APPLY_ARGS: + /* If a __builtin_apply_args caller would be inlined, + it would be saving arguments of the function it has + been inlined into. Similarly __builtin_return would + return from the function the inline has been inlined into. */ + inline_forbidden_reason + = N_("%Jfunction %qF can never be inlined because " + "it uses __builtin_return or __builtin_apply_args"); + return node; + default: break; } |