+Wed Mar 5 23:16:57 CET 2003 Jan Hubicka <jh@suse.cz>
+
+ * Makefile.in (calls.o, toplev.o alias.o): Depend on cgraph.h
+ * alias.c: Include cgraph.h
+ (mark_constant_function): Use cgraph_rtl_info.
+ * calls.c: Include cgraph.h
+ (flags_from_decl_or_type): Use cgraph_rtl_info to find pure and const
+ calls.
+ (expand_call): Use cgraph_rtl_info to set preferred stack boundary.
+ * cgraph.c (cgraph_rtl_info): New function.
+ * cgraph.h (cgraph_rtl_info): Declare
+ (cgraph_rtl_info): Likewise.
+ * function.h (struct function): Add recursive_call_emit.
+ * toplev.c: Include cgraph.h.
+ (rest_of_compilation): Set preferred_incoming_stack_boundary.
+
2003-03-05 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300.c (output_simode_bld): Clear the
graph.h $(LOOP_H) except.h $(REGS_H) $(TIMEVAR_H) $(lang_options_files) \
ssa.h $(PARAMS_H) $(TM_P_H) reload.h dwarf2asm.h $(TARGET_H) \
langhooks.h insn-flags.h options.h cfglayout.h real.h cfgloop.h \
- hosthooks.h $(LANGHOOKS_DEF_H)
+ hosthooks.h $(LANGHOOKS_DEF_H) cgraph.h
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
-DTARGET_NAME=\"$(target_alias)\" \
-c $(srcdir)/toplev.c $(OUTPUT_OPTION)
except.h $(TM_P_H) $(PREDICT_H) libfuncs.h real.h langhooks.h
calls.o : calls.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) flags.h \
$(EXPR_H) langhooks.h $(TARGET_H) \
- libfuncs.h $(REGS_H) toplev.h output.h function.h $(TIMEVAR_H) $(TM_P_H)
+ libfuncs.h $(REGS_H) toplev.h output.h function.h $(TIMEVAR_H) $(TM_P_H) cgraph.h
expmed.o : expmed.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \
flags.h insn-config.h $(EXPR_H) $(OPTABS_H) $(RECOG_H) real.h \
toplev.h $(TM_P_H) langhooks.h
alias.o : alias.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) flags.h \
hard-reg-set.h $(BASIC_BLOCK_H) $(REGS_H) toplev.h output.h $(EXPR_H) \
$(GGC_H) function.h cselib.h $(TREE_H) $(TM_P_H) langhooks.h $(TARGET_H) \
- gt-alias.h $(TIMEVAR_H)
+ gt-alias.h $(TIMEVAR_H) cgraph.h
regmove.o : regmove.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) insn-config.h \
$(RECOG_H) output.h $(REGS_H) hard-reg-set.h flags.h function.h \
$(EXPR_H) $(BASIC_BLOCK_H) toplev.h $(TM_P_H) except.h reload.h
#include "langhooks.h"
#include "timevar.h"
#include "target.h"
+#include "cgraph.h"
/* The alias sets assigned to MEMs assist the back-end in determining
which MEMs can alias which other MEMs. In general, two MEMs in
if (insn)
;
else if (nonlocal_memory_referenced)
- DECL_IS_PURE (current_function_decl) = 1;
+ cgraph_rtl_info (current_function_decl)->pure_function = 1;
else
- TREE_READONLY (current_function_decl) = 1;
+ cgraph_rtl_info (current_function_decl)->const_function = 1;
}
\f
#include "sbitmap.h"
#include "langhooks.h"
#include "target.h"
+#include "cgraph.h"
/* Decide whether a function's arguments should be processed
from first to last or from last to first.
/* ??? We can't set IS_MALLOC for function types? */
if (DECL_P (exp))
{
+ struct cgraph_rtl_info *i = cgraph_rtl_info (exp);
type = TREE_TYPE (exp);
+ if (i && i->pure_function)
+ flags |= ECF_PURE | ECF_LIBCALL_BLOCK;
+ if (i && i->const_function)
+ flags |= ECF_CONST | ECF_LIBCALL_BLOCK;
+
/* The function exp may have the `malloc' attribute. */
if (DECL_P (exp) && DECL_IS_MALLOC (exp))
flags |= ECF_MALLOC;
/* Figure out the amount to which the stack should be aligned. */
preferred_stack_boundary = PREFERRED_STACK_BOUNDARY;
+ if (fndecl)
+ {
+ struct cgraph_rtl_info *i = cgraph_rtl_info (fndecl);
+ if (i && i->preferred_incoming_stack_boundary)
+ preferred_stack_boundary = i->preferred_incoming_stack_boundary;
+ }
/* Operand 0 is a pointer-to-function; get the type of the function. */
funtype = TREE_TYPE (addr);
if (cfun->preferred_stack_boundary < preferred_stack_boundary
&& fndecl != current_function_decl)
cfun->preferred_stack_boundary = preferred_stack_boundary;
+ if (fndecl == current_function_decl)
+ cfun->recursive_call_emit = true;
preferred_unit_stack_boundary = preferred_stack_boundary / BITS_PER_UNIT;
return &node->global;
}
+/* Return local info for the compiled function. */
+
+struct cgraph_rtl_info *
+cgraph_rtl_info (decl)
+ tree decl;
+{
+ struct cgraph_node *node;
+ if (TREE_CODE (decl) != FUNCTION_DECL)
+ abort ();
+ node = cgraph_node (decl);
+ if (decl != current_function_decl
+ && !TREE_ASM_WRITTEN (node->decl))
+ return NULL;
+ return &node->rtl;
+}
+
/* Dump the callgraph. */
int dummy;
};
+/* Information about the function that is propagated by the RTL backend.
+ Available only for functions that has been already assembled. */
+
+struct cgraph_rtl_info
+{
+ bool const_function, pure_function;
+ int preferred_incoming_stack_boundary;
+};
+
/* The cgraph data strutcture.
Each function decl has assigned cgraph_node listing calees and callers. */
bool output;
struct cgraph_local_info local;
struct cgraph_global_info global;
+ struct cgraph_rtl_info rtl;
};
struct cgraph_edge
bool cgraph_calls_p PARAMS ((tree, tree));
struct cgraph_local_info *cgraph_local_info PARAMS ((tree));
struct cgraph_global_info *cgraph_global_info PARAMS ((tree));
+struct cgraph_rtl_info *cgraph_rtl_info PARAMS ((tree));
/* In cgraphunit.c */
void cgraph_finalize_function PARAMS ((tree, tree));
int stack_alignment_needed;
/* Preferred alignment of the end of stack frame. */
int preferred_stack_boundary;
+ /* Set when the call to function itself has been emit. */
+ bool recursive_call_emit;
/* Language-specific code can use this to store whatever it likes. */
struct language_function * language;
+Wed Mar 5 23:18:11 CET 2003 Jan Hubicka <jh@suse.cz>
+
+ * gcc.dg/i386-local2.c: New.
+
2003-03-05 Mark Mitchell <mark@codesourcery.com>
* g++.dg/abi/layout3.C: New test.
--- /dev/null
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -funit-at-a-time -fomit-frame-pointer" } */
+/* { dg-final { scan-assembler-not "sub.*[re]sp" } } */
+
+static __attribute__ ((noinline)) q ();
+int a;
+
+/* This function should not require any stack manipulation
+ for preferred stack bounday. */
+void
+e ()
+{
+ if (a)
+ {
+ e ();
+ a--;
+ }
+ q ();
+}
+
+static __attribute__ ((noinline)) q ()
+{
+}
#include "cfglayout.h"
#include "cfgloop.h"
#include "hosthooks.h"
+#include "cgraph.h"
#if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
#include "dwarf2out.h"
timevar_pop (TV_FINAL);
+ if ((*targetm.binds_local_p) (current_function_decl))
+ {
+ int pref = cfun->preferred_stack_boundary;
+ if (cfun->recursive_call_emit
+ && cfun->stack_alignment_needed > cfun->preferred_stack_boundary)
+ pref = cfun->stack_alignment_needed;
+ cgraph_rtl_info (current_function_decl)->preferred_incoming_stack_boundary
+ = pref;
+ }
+
/* Make sure volatile mem refs aren't considered valid operands for
arithmetic insns. We must call this here if this is a nested inline
function, since the above code leaves us in the init_recog state