]> gcc.gnu.org Git - gcc.git/commitdiff
Makefile.in (calls.o, [...]): Depend on cgraph.h
authorJan Hubicka <jh@suse.cz>
Wed, 5 Mar 2003 22:19:33 +0000 (23:19 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 5 Mar 2003 22:19:33 +0000 (22:19 +0000)
* 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

gcc/ChangeLog
gcc/Makefile.in
gcc/alias.c
gcc/calls.c
gcc/cgraph.c
gcc/cgraph.h
gcc/function.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/i386-local2.c [new file with mode: 0644]
gcc/toplev.c

index ebfb2ca6e6cec251925334b97d97643f9c7a919f..e3e5cb49af15e7684066a2198aecb7744b48391f 100644 (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
index 36c43c3aeb11fbb8c2c6180ac17109da14a4dab1..f4c3ba54e71d2c372b44f588a2f5afeb61dad774 100644 (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
index 9be3aa05534d86ef733582e43463cef8c5e12cdb..f1b0530b443ac7b15e5071f557b8c81a7c85d673 100644 (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;
 }
 \f
 
index 57470b2cebc043f2e010c62f105684bb70b484da..509a689b0950cb4702c16d8effe063642be354fd 100644 (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;
 
index d947eb9991072d2590ac5613f4a346c1b849ad98..185a97b56519780517f81a7b7926782ac86420f3 100644 (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.  */
 
index 4404fb8b838742a5cced70f368deee1c0a5e3f38..6c8c8afece01fb1327372d9f4cbf8cdeb264acf4 100644 (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));
index 5d4258ffe5b7fc18b248eacb6248bff00cacbb32..6a6977e742f0ffc45cdbd8a0278924aa908f1bff 100644 (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;
index 27e03459967c7f66a00c8f7caaefce6037635619..646ed6fd4c9b530f71857e42b43de3a103b0d861 100644 (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.
diff --git a/gcc/testsuite/gcc.dg/i386-local2.c b/gcc/testsuite/gcc.dg/i386-local2.c
new file mode 100644 (file)
index 0000000..89ef87e
--- /dev/null
@@ -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 ()
+{
+}
index 2dbdf4f8c95cc0a9aaf8ae73a75e0ca70e29c955..085641897344c87451c6a05116afa7413a008405 100644 (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
This page took 0.098212 seconds and 5 git commands to generate.