This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
-finline-functions vs -fpic
On Fri, Aug 30, 2002 at 06:43:25PM -0700, Geoff Keating wrote:
> > The inliner will use it in a moment as well. There's an outstanding
> > bug wrt -O3 that inlines functions that it shouldn't.
>
> FYI, I tried to fix this the obvious way,
[...]
> (and equivalently for C++) but this doesn't allow globally-visible
> functions to be inlined when not -fpic on x86. Possibly this means
> binds_local_p is wrong on x86.
Nope. The decl isn't properly constructed yet. In particular,
DECL_EXTERNAL is still set, and won't be cleared until start_function.
I thought about moving where we set DECL_INLINE, or changing where
we set DECL_EXTERNAL, but the former didn't seem particularly clean,
and the later made me nervous.
The following, however, makes me happy. I'll fix up the C++ front
end similarly in a moment.
r~
* c-objc-common.c: Include target.h.
(c_cannot_inline_tree_fn): Don't auto-inline functions that
don't bind locally. Factor setting DECL_UNINLINABLE.
* Makefile.in (c-objc-common.o): Update.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.939
diff -c -p -d -r1.939 Makefile.in
*** Makefile.in 22 Aug 2002 04:29:34 -0000 1.939
--- Makefile.in 31 Aug 2002 02:21:22 -0000
*************** c-lex.o : c-lex.c $(CONFIG_H) $(SYSTEM_H
*** 1190,1196 ****
c-objc-common.o : c-objc-common.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \
$(C_TREE_H) $(RTL_H) insn-config.h integrate.h $(EXPR_H) $(C_TREE_H) \
flags.h toplev.h tree-inline.h diagnostic.h integrate.h $(VARRAY_H) \
! langhooks.h $(GGC_H) gt-c-objc-common.h
c-aux-info.o : c-aux-info.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) \
flags.h toplev.h
c-convert.o : c-convert.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) flags.h toplev.h \
--- 1190,1196 ----
c-objc-common.o : c-objc-common.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \
$(C_TREE_H) $(RTL_H) insn-config.h integrate.h $(EXPR_H) $(C_TREE_H) \
flags.h toplev.h tree-inline.h diagnostic.h integrate.h $(VARRAY_H) \
! langhooks.h $(GGC_H) gt-c-objc-common.h $(TARGET_H)
c-aux-info.o : c-aux-info.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) \
flags.h toplev.h
c-convert.o : c-convert.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) flags.h toplev.h \
Index: c-objc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-objc-common.c,v
retrieving revision 1.15
diff -c -p -d -r1.15 c-objc-common.c
*** c-objc-common.c 16 Jul 2002 02:16:31 -0000 1.15
--- c-objc-common.c 31 Aug 2002 02:21:22 -0000
*************** Software Foundation, 59 Temple Place - S
*** 34,39 ****
--- 34,40 ----
#include "varray.h"
#include "ggc.h"
#include "langhooks.h"
+ #include "target.h"
static bool c_tree_printer PARAMS ((output_buffer *, text_info *));
static tree inline_forbidden_p PARAMS ((tree *, int *, void *));
*************** c_cannot_inline_tree_fn (fnp)
*** 150,160 ****
&& lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
return 1;
if (! function_attribute_inlinable_p (fn))
! {
! DECL_UNINLINABLE (fn) = 1;
! return 1;
! }
/* If a function has pending sizes, we must not defer its
compilation, and we can't inline it as a tree. */
--- 151,163 ----
&& lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
return 1;
+ /* Don't auto-inline anything that might not be bound within
+ this unit of translation. */
+ if (!DECL_DECLARED_INLINE_P (fn) && !(*targetm.binds_local_p) (fn))
+ goto cannot_inline;
+
if (! function_attribute_inlinable_p (fn))
! goto cannot_inline;
/* If a function has pending sizes, we must not defer its
compilation, and we can't inline it as a tree. */
*************** c_cannot_inline_tree_fn (fnp)
*** 164,173 ****
put_pending_sizes (t);
if (t)
! {
! DECL_UNINLINABLE (fn) = 1;
! return 1;
! }
}
if (DECL_CONTEXT (fn))
--- 167,173 ----
put_pending_sizes (t);
if (t)
! goto cannot_inline;
}
if (DECL_CONTEXT (fn))
*************** c_cannot_inline_tree_fn (fnp)
*** 175,184 ****
/* If a nested function has pending sizes, we may have already
saved them. */
if (DECL_LANG_SPECIFIC (fn)->pending_sizes)
! {
! DECL_UNINLINABLE (fn) = 1;
! return 1;
! }
}
else
{
--- 175,181 ----
/* If a nested function has pending sizes, we may have already
saved them. */
if (DECL_LANG_SPECIFIC (fn)->pending_sizes)
! goto cannot_inline;
}
else
{
*************** c_cannot_inline_tree_fn (fnp)
*** 201,212 ****
}
if (walk_tree (&DECL_SAVED_TREE (fn), inline_forbidden_p, fn, NULL))
! {
! DECL_UNINLINABLE (fn) = 1;
! return 1;
! }
return 0;
}
/* Called from check_global_declarations. */
--- 198,210 ----
}
if (walk_tree (&DECL_SAVED_TREE (fn), inline_forbidden_p, fn, NULL))
! goto cannot_inline;
return 0;
+
+ cannot_inline:
+ DECL_UNINLINABLE (fn) = 1;
+ return 1;
}
/* Called from check_global_declarations. */