This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
tree inline bug and fix
- From: Alexey Starovoytov <alexey dot starovoytov at sun dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 3 Nov 2003 18:57:19 -0800 (PST)
- Subject: tree inline bug and fix
Hi,
I believe there is a bug in the function "inline_forbidden_p"
in the file "c-objc-common.c":
switch (TREE_CODE (node))
{
case CALL_EXPR:
t = get_callee_fndecl (node);
if (! t)
break;
/* We cannot inline functions that call setjmp. */
if (setjmp_call_p (t))
return node;
switch (DECL_FUNCTION_CODE (t))
{
/* We cannot inline functions that take a variable number of
arguments. */
case BUILT_IN_VA_START:
case BUILT_IN_STDARG_START:
It is possible that function declaration 't' has a non-zero
DECL_FUNCTION_CODE (t) field and 't' is not a BUILT_IN function.
(In other words t->decl.u1.f != 0 and t->decl.built_in_class == 0)
Therefore during tree inline optimization some regular functions may not
be inlined due to incorrect check for BUILT_IN_*
So the result of inline optimization can be different depending on what
platform you running and what flags were used to build GCC compiler,
though generated code will be correct.
The possible fix could be:
switch (TREE_CODE (node))
{
case CALL_EXPR:
t = get_callee_fndecl (node);
if (! t)
break;
/* We cannot inline functions that call setjmp. */
if (setjmp_call_p (t))
return node;
if (DECL_BUILT_IN (t))
switch (DECL_FUNCTION_CODE (t))
{
/* We cannot inline functions that take a variable number of
arguments. */
case BUILT_IN_VA_START:
case BUILT_IN_STDARG_START:
Regards,
Alexey.
*** c-objc-common.c Fri May 2 12:52:02 2003
--- c-objc-common.c.new Mon Nov 3 18:44:28 2003
*************** inline_forbidden_p (nodep, walk_subtrees
*** 88,109 ****
if (setjmp_call_p (t))
return node;
! switch (DECL_FUNCTION_CODE (t))
! {
! /* We cannot inline functions that take a variable number of
! arguments. */
! case BUILT_IN_VA_START:
! case BUILT_IN_STDARG_START:
#if 0
! /* Functions that need information about the address of the
! caller can't (shouldn't?) be inlined. */
! case BUILT_IN_RETURN_ADDRESS:
#endif
! return node;
! default:
! break;
! }
break;
--- 88,110 ----
if (setjmp_call_p (t))
return node;
! if (DECL_BUILT_IN (t))
! switch (DECL_FUNCTION_CODE (t))
! {
! /* We cannot inline functions that take a variable number of
! arguments. */
! case BUILT_IN_VA_START:
! case BUILT_IN_STDARG_START:
#if 0
! /* Functions that need information about the address of the
! caller can't (shouldn't?) be inlined. */
! case BUILT_IN_RETURN_ADDRESS:
#endif
! return node;
! default:
! break;
! }
break;