Makefile.in (calls.o, [...]): Depend on cgraph.h

* 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.

	* gcc.dg/i386-local2.c: New.

From-SVN: r63868
This commit is contained in:
Jan Hubicka 2003-03-05 23:19:33 +01:00 committed by Jan Hubicka
parent 0eb933a0d0
commit b255a03659
10 changed files with 104 additions and 5 deletions

View File

@ -1,3 +1,19 @@
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

View File

@ -1438,7 +1438,7 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_
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)
@ -1489,7 +1489,7 @@ builtins.o : builtins.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(T
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
@ -1671,7 +1671,7 @@ reorg.o : reorg.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) condition
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

View File

@ -41,6 +41,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#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
@ -2668,9 +2669,9 @@ mark_constant_function ()
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;
}

View File

@ -37,6 +37,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#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.
@ -798,8 +799,14 @@ flags_from_decl_or_type (exp)
/* ??? 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;
@ -2344,6 +2351,12 @@ expand_call (exp, target, ignore)
/* 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);
@ -2630,6 +2643,8 @@ expand_call (exp, target, ignore)
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;

View File

@ -204,6 +204,22 @@ cgraph_global_info (decl)
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. */

View File

@ -42,6 +42,15 @@ struct cgraph_global_info
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. */
@ -74,6 +83,7 @@ struct cgraph_node
bool output;
struct cgraph_local_info local;
struct cgraph_global_info global;
struct cgraph_rtl_info rtl;
};
struct cgraph_edge
@ -95,6 +105,7 @@ struct cgraph_node *cgraph_node PARAMS ((tree decl));
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));

View File

@ -378,6 +378,8 @@ struct function GTY(())
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;

View File

@ -1,3 +1,7 @@
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.

View File

@ -0,0 +1,23 @@
/* { 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 ()
{
}

View File

@ -75,6 +75,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "cfglayout.h"
#include "cfgloop.h"
#include "hosthooks.h"
#include "cgraph.h"
#if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
#include "dwarf2out.h"
@ -3772,6 +3773,16 @@ rest_of_compilation (decl)
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