This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/12953] New: tree inline bug and fix
- From: "alexey dot starovoytov at sun dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Nov 2003 22:01:57 -0000
- Subject: [Bug optimization/12953] New: tree inline bug and fix
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12953
Summary: tree inline bug and fix
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: alexey dot starovoytov at sun dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
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;