diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-03-05 22:19:33 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-03-05 22:19:33 +0000 |
commit | 28992b23bc88821d83d650703beb1102a3303586 (patch) | |
tree | 6d8310470c10ca87b4dc63ecaa076fb112326f11 | |
parent | 7d3e46b8b1d7211b092d0e853a8fbae20e3b9b0a (diff) | |
download | gcc-28992b23bc88821d83d650703beb1102a3303586.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63868 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 16 | ||||
-rw-r--r-- | gcc/Makefile.in | 6 | ||||
-rw-r--r-- | gcc/alias.c | 5 | ||||
-rw-r--r-- | gcc/calls.c | 15 | ||||
-rw-r--r-- | gcc/cgraph.c | 16 | ||||
-rw-r--r-- | gcc/cgraph.h | 11 | ||||
-rw-r--r-- | gcc/function.h | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/i386-local2.c | 23 | ||||
-rw-r--r-- | gcc/toplev.c | 11 |
10 files changed, 104 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ebfb2ca6e6c..e3e5cb49af1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 36c43c3aeb1..f4c3ba54e71 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -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 diff --git a/gcc/alias.c b/gcc/alias.c index 9be3aa05534..f1b0530b443 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -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; } diff --git a/gcc/calls.c b/gcc/calls.c index 57470b2cebc..509a689b095 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -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; diff --git a/gcc/cgraph.c b/gcc/cgraph.c index d947eb99910..185a97b5651 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -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. */ diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 4404fb8b838..6c8c8afece0 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -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)); diff --git a/gcc/function.h b/gcc/function.h index 5d4258ffe5b..6a6977e742f 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 27e03459967..646ed6fd4c9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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. diff --git a/gcc/testsuite/gcc.dg/i386-local2.c b/gcc/testsuite/gcc.dg/i386-local2.c new file mode 100644 index 00000000000..89ef87e4755 --- /dev/null +++ b/gcc/testsuite/gcc.dg/i386-local2.c @@ -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 () +{ +} diff --git a/gcc/toplev.c b/gcc/toplev.c index 2dbdf4f8c95..08564189734 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -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 |