From: Jakub Jelinek Date: Fri, 20 Aug 2010 18:49:46 +0000 (+0200) Subject: re PR middle-end/44974 (Function with attribute noreturn omits a call to another... X-Git-Tag: releases/gcc-4.6.0~4903 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=994fc9abdde826d0b843b48e8ef1627295c3ae25;p=thirdparty%2Fgcc.git re PR middle-end/44974 (Function with attribute noreturn omits a call to another function with noreturn) PR middle-end/44974 * builtins.c (expand_builtin): Don't optimize away calls to DECL_LOOPING_CONST_OR_PURE_P builtins. * gcc.dg/pr44974.c: New test. From-SVN: r163415 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 367480517486..1cfd27ef8fd1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-08-20 Jakub Jelinek + + PR middle-end/44974 + * builtins.c (expand_builtin): Don't optimize away + calls to DECL_LOOPING_CONST_OR_PURE_P builtins. + 2010-08-20 Uros Bizjak * config/i386/i386.md (ashift RSP splitter): Remove splitter. diff --git a/gcc/builtins.c b/gcc/builtins.c index 9a79adbece27..e8974e1bbc22 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -5770,7 +5770,8 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, none of its arguments are volatile, we can avoid expanding the built-in call and just evaluate the arguments for side-effects. */ if (target == const0_rtx - && (DECL_PURE_P (fndecl) || TREE_READONLY (fndecl))) + && (DECL_PURE_P (fndecl) || TREE_READONLY (fndecl)) + && !DECL_LOOPING_CONST_OR_PURE_P (fndecl)) { bool volatilep = false; tree arg; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0c1b613c7df1..358033100158 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2010-08-20 Jakub Jelinek + PR middle-end/44974 + * gcc.dg/pr44974.c: New test. + PR rtl-optimization/45353 * gcc.dg/pr45353.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr44974.c b/gcc/testsuite/gcc.dg/pr44974.c new file mode 100644 index 000000000000..14e43ece3c2d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr44974.c @@ -0,0 +1,23 @@ +/* PR middle-end/44974 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-optimize-sibling-calls" } */ + +extern void foo (int status) __attribute__ ((__noreturn__)); +extern void bar (int status) __attribute__ ((__noreturn__)); +extern void _Exit (int status) __attribute__ ((__noreturn__)); + +void +foo (int status) +{ + _Exit (status); +} + +void +_Exit (int status) +{ + bar (status); +} + +/* { dg-final { scan-assembler "call\[^\n\]*_Exit" { target i?86-*-* x86_64-*-* ia64-*-* sparc*-*-* } } } */ +/* { dg-final { scan-assembler "bl\[^\n\]*_Exit" { target powerpc*-*-* } } } */ +/* { dg-final { scan-assembler "brasl\[^\n\]*_Exit" { target { s390*-*-* && lp64 } } } } */