From 6d8ccdbbb20cdff710cd6977165bde1d763f6a40 Mon Sep 17 00:00:00 2001
From: Jeff Law <law@gcc.gnu.org>
Date: Mon, 15 Dec 1997 00:05:04 -0700
Subject: [PATCH] Bring over changes from latest gcc-2.8 pre-release.

Mirror sched.c change into haifa-sched.c

From-SVN: r17097
---
 gcc/ChangeLog          |  7 +++++++
 gcc/ChangeLog.11       | 46 +++++++++++++++++++++++++++++++++++++++++-
 gcc/INSTALL            |  2 +-
 gcc/SERVICE            |  3 +--
 gcc/acconfig.h         |  3 +++
 gcc/collect2.c         | 16 +++++++--------
 gcc/config.in          |  3 +++
 gcc/config/i386/i386.h |  5 +++--
 gcc/crtstuff.c         | 14 ++++++-------
 gcc/except.c           |  4 ++--
 gcc/expr.c             | 11 ++++------
 gcc/frame.c            |  6 +++---
 gcc/frame.h            |  9 +++++++--
 gcc/function.c         |  4 ++--
 gcc/haifa-sched.c      |  9 +++++++--
 gcc/install.texi       |  2 +-
 gcc/pexecute.c         |  9 +++++----
 gcc/sched.c            | 11 ++++++++--
 18 files changed, 118 insertions(+), 46 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f5ef4cc331bc..76a30f9a014a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+Mon Dec 15 00:04:48 1997  Jeffrey A Law  (law@cygnus.com)
+
+        * haifa-sched.c (remove_dependencies): Set RTX_INTEGRATED_P on
+	dependency we delete.  Properly update prev for multiple consecutive
+	deletions.
+        (priority): Skip deleted dependence.
+
 Fri Dec 12 18:54:23 1997  Per Bothner  <bothner@cygnus.com>
 
 	* expr.c (expand_builtin):  Support BUILT_IN_FMOD - just call fmod.
diff --git a/gcc/ChangeLog.11 b/gcc/ChangeLog.11
index 8620152be4d3..748764fa33a2 100644
--- a/gcc/ChangeLog.11
+++ b/gcc/ChangeLog.11
@@ -1,8 +1,52 @@
-Fri Dec 12 08:01:44 1997  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
+Sun Dec 14 06:49:05 1997  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
+
+	* Version 2.8.0 released.
+
+	* expr.c (expand_expr, case PLACEHOLDER_EXPR): Use placeholder_list 
+	expression in preference to any other if correct type.
+
+	* i386.h (INITIAL_ELIMINATION_OFFSET): Correctly test for PIC
+	register used.
+
+Sat Dec 13 06:11:32 1997  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
+
+	* frame.h (__register_frame_info_table): Fix typo in declaration.
+
+Fri Dec 12 07:55:18 1997  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
+
+	* function.c (purge_addressof_1): For (mem (address (mem ...)),
+	when collapsing, preserve mode of outer MEM.
+
+	* frame.c (__register_frame_info): Renamed from __register_frame.
+	(__register_frame_info_table, __deregister_frame_info): Similarly.
+	* frame.h (__{,de}register_frame_info): Likewise.
+	(__register_frame_info_table): New declaration.
+	* crtstuff.c (__do_global_dtors{,_aux}): Rename __deregister_frame.
+	(frame_dummy, __do_global_ctors): Likewise for __register_frame.
+	* collect2.c (write_c_file_{stat,glob}): Rename __register_frame
+	to __register_frame_info and similarly for __deregister_frame and
+	__register_frame_table.
+
+	* sched.c (remove_dependencies): Set RTX_INTEGRATED_P on dependency
+	we delete.  Properly update prev for multiple consecutive deletions.
+	(priority): Skip deleted dependence.
 
 	* integrate.c (initialize_for_inline): In DECL_RTL of a PARM_DECL,
 	look inside a (mem (addressof (mem ...))).
 
+Fri Dec 12 05:49:58 1997  Paul Eggert  <eggert@twinsun.com>
+
+	* collect2.c (write_c_file_glob):
+	Allocate initial frame object in static storage and pass its address.
+
+Thu Dec 11 18:01:31 1997  Philippe De Muyter  <phdm@macqel.be>
+
+	* acconfig.h (NEED_DECLARATION_GETENV): Define slot added.
+
+Thu Dec 11 17:54:23 1997  Paul Eggert  <eggert@twinsun.com>
+
+	* crtstuff.c (__do_global_ctors): Fix typo in last change.
+
 Wed Dec 10 18:38:28 1997  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
  
         * libgcc2.c (__bb_exit_func): Fix test of return value of fopen.
diff --git a/gcc/INSTALL b/gcc/INSTALL
index 595bc1df33b3..60fabf131b79 100644
--- a/gcc/INSTALL
+++ b/gcc/INSTALL
@@ -164,7 +164,7 @@ and includes all the necessary compilation tools and libraries.
           `--nfp' currently has no effect, though perhaps there are
           other systems where it could usefully make a difference.
 
-    `--enable-objcthreads=TYPE'
+    `--enable-threads=TYPE'
           Certain systems, notably Linux-based GNU systems, can't be
           relied on to supply a threads facility for the Objective C
           runtime and so will default to single-threaded runtime.  They
diff --git a/gcc/SERVICE b/gcc/SERVICE
index c146eb2226a9..46441675fd07 100644
--- a/gcc/SERVICE
+++ b/gcc/SERVICE
@@ -693,8 +693,7 @@ My rate varies greatly between $25-$40/hour, depending on the circumstances.
 Rates for non-profit organizations are substantially lower, and possibly free.
 
 Please note that I have no interest in working with any Micro$oft related
-products.  I will accept work that involves other non-free, non-Micro$oft
-software, but I would want the primary focus of the work to be contributing
+products!  I want the primary focus of my work to be contributing
 to the free software community.
 
 Updated: 1997-12-04
diff --git a/gcc/acconfig.h b/gcc/acconfig.h
index 2b6c1442c971..41c0cf8b1d61 100644
--- a/gcc/acconfig.h
+++ b/gcc/acconfig.h
@@ -18,4 +18,7 @@
 
 /* Whether rindex must be declared even if <stdlib.h> is included.  */
 #undef NEED_DECLARATION_RINDEX
+
+/* Whether getenv must be declared even if <stdlib.h> is included.  */
+#undef NEED_DECLARATION_GETENV
 @TOP@
diff --git a/gcc/collect2.c b/gcc/collect2.c
index a79f7a849f9a..88547cb4f61b 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -1790,16 +1790,16 @@ write_c_file_stat (stream, name)
       fprintf (stream, "  struct object *next;\n");
       fprintf (stream, "};\n");
 
-      fprintf (stream, "extern void __register_frame_table (void *, struct object *);\n");
-      fprintf (stream, "extern void __deregister_frame (void *);\n");
+      fprintf (stream, "extern void __register_frame_info_table (void *, struct object *);\n");
+      fprintf (stream, "extern void __deregister_frame_info (void *);\n");
 
       fprintf (stream, "static void reg_frame () {\n");
       fprintf (stream, "\tstatic struct object ob;\n");
-      fprintf (stream, "\t__register_frame_table (frame_table, &ob);\n");
+      fprintf (stream, "\t__register_frame_info_table (frame_table, &ob);\n");
       fprintf (stream, "\t}\n");
 
       fprintf (stream, "static void dereg_frame () {\n");
-      fprintf (stream, "\t__deregister_frame (frame_table);\n");
+      fprintf (stream, "\t__deregister_frame_info (frame_table);\n");
       fprintf (stream, "\t}\n");
     }
 
@@ -1876,16 +1876,16 @@ write_c_file_glob (stream, name)
       fprintf (stream, "  struct object *next;\n");
       fprintf (stream, "};\n");
 
-      fprintf (stream, "extern void __register_frame_table (void *, struct object *);\n");
-      fprintf (stream, "extern void __deregister_frame (void *);\n");
+      fprintf (stream, "extern void __register_frame_info_table (void *, struct object *);\n");
+      fprintf (stream, "extern void __deregister_frame_info (void *);\n");
 
       fprintf (stream, "static void reg_frame () {\n");
       fprintf (stream, "\tstatic struct object ob;\n");
-      fprintf (stream, "\t__register_frame_table (frame_table, &ob);\n");
+      fprintf (stream, "\t__register_frame_info_table (frame_table, &ob);\n");
       fprintf (stream, "\t}\n");
 
       fprintf (stream, "static void dereg_frame () {\n");
-      fprintf (stream, "\t__deregister_frame (frame_table);\n");
+      fprintf (stream, "\t__deregister_frame_info (frame_table);\n");
       fprintf (stream, "\t}\n");
     }
 
diff --git a/gcc/config.in b/gcc/config.in
index e535674f3d7b..92d4ca095fe7 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -20,6 +20,9 @@
 /* Whether rindex must be declared even if <stdlib.h> is included.  */
 #undef NEED_DECLARATION_RINDEX
 
+/* Whether getenv must be declared even if <stdlib.h> is included.  */
+#undef NEED_DECLARATION_GETENV
+
 /* Define if you have the ANSI C header files.  */
 #undef STDC_HEADERS
 
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 9bfef4e98b2c..6fb08a120d2d 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -1524,8 +1524,9 @@ do {						\
 									\
       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)		\
 	if ((regs_ever_live[regno] && ! call_used_regs[regno])		\
-	    || (current_function_uses_pic_offset_table			\
-		&& regno == PIC_OFFSET_TABLE_REGNUM))			\
+	    || ((current_function_uses_pic_offset_table			\
+		 || current_function_uses_const_pool)			\
+		&& flag_pic && regno == PIC_OFFSET_TABLE_REGNUM))	\
 	  offset += 4;							\
 									\
       (OFFSET) = offset + get_frame_size ();				\
diff --git a/gcc/crtstuff.c b/gcc/crtstuff.c
index 50964a800505..3f3643f6b8de 100644
--- a/gcc/crtstuff.c
+++ b/gcc/crtstuff.c
@@ -142,7 +142,7 @@ __do_global_dtors_aux ()
     }
 
 #ifdef EH_FRAME_SECTION_ASM_OP
-  __deregister_frame (__EH_FRAME_BEGIN__);
+  __deregister_frame_info (__EH_FRAME_BEGIN__);
 #endif
   completed = 1;
 }
@@ -162,15 +162,15 @@ fini_dummy ()
 }
 
 #ifdef EH_FRAME_SECTION_ASM_OP
-/* Stick a call to __register_frame into the .init section.  For some reason
-   calls with no arguments work more reliably in .init, so stick the call
-   in another function.  */
+/* Stick a call to __register_frame_info into the .init section.  For some
+   reason calls with no arguments work more reliably in .init, so stick the
+   call in another function.  */
 
 static void
 frame_dummy ()
 {
   static struct object object;
-  __register_frame (__EH_FRAME_BEGIN__, &object);
+  __register_frame_info (__EH_FRAME_BEGIN__, &object);
 }
 
 static void
@@ -254,7 +254,7 @@ __do_global_dtors ()
     (*p) ();
 
 #ifdef EH_FRAME_SECTION_ASM_OP
-  __deregister_frame (__EH_FRAME_BEGIN__);
+  __deregister_frame_info (__EH_FRAME_BEGIN__);
 #endif
 }
 #endif
@@ -395,7 +395,7 @@ __do_global_ctors ()
   func_ptr *p;
 #ifdef EH_FRAME_SECTION_ASM_OP
   static struct object object;
-  __register_frame (__EH_FRAME_BEGIN__, &object);
+  __register_frame_info (__EH_FRAME_BEGIN__, &object);
 #endif
   for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
     (*p) ();
diff --git a/gcc/except.c b/gcc/except.c
index c0db69f87eb3..e2a591447c0b 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -97,9 +97,9 @@ Boston, MA 02111-1307, USA.  */
    On targets that support crtstuff.c, the unwind information
    is stored in a section named .eh_frame and the information for the
    entire shared object or program is registered with a call to
-   __register_frame.  On other targets, the information for each
+   __register_frame_info.  On other targets, the information for each
    translation unit is registered from the file generated by collect2.
-   __register_frame is defined in frame.c, and is responsible for
+   __register_frame_info is defined in frame.c, and is responsible for
    recording all of the unwind regions into one list (which is kept in a
    static variable named unwind_table_list).
 
diff --git a/gcc/expr.c b/gcc/expr.c
index 8f46449caf41..339f3e2b420c 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -5293,7 +5293,7 @@ expand_expr (exp, target, tmode, modifier)
 	tree placeholder_expr;
 
 	/* If there is an object on the head of the placeholder list,
-	   see if some object in it's references is of type TYPE.  For
+	   see if some object in its references is of type TYPE.  For
 	   further information, see tree.def.  */
 	for (placeholder_expr = placeholder_list;
 	     placeholder_expr != 0;
@@ -5310,9 +5310,9 @@ expand_expr (exp, target, tmode, modifier)
 		 == need_type))
 	      object = TREE_PURPOSE (placeholder_expr);
 
-	    /* Find the innermost reference that is of the type we want.  */
+	    /* Find the outermost reference that is of the type we want.  */
 	    for (elt = TREE_PURPOSE (placeholder_expr);
-		 elt != 0
+		 elt != 0 && object == 0
 		 && (TREE_CODE_CLASS (TREE_CODE (elt)) == 'r'
 		     || TREE_CODE_CLASS (TREE_CODE (elt)) == '1'
 		     || TREE_CODE_CLASS (TREE_CODE (elt)) == '2'
@@ -5323,10 +5323,7 @@ expand_expr (exp, target, tmode, modifier)
 	      if (TREE_CODE_CLASS (TREE_CODE (elt)) == 'r'
 		  && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (elt, 0)))
 		      == need_type))
-		{
-		  object = TREE_OPERAND (elt, 0);
-		  break;
-		}
+		object = TREE_OPERAND (elt, 0);
 
 	    if (object != 0)
 	      {
diff --git a/gcc/frame.c b/gcc/frame.c
index 296e6a9456d1..ca107b081d3b 100644
--- a/gcc/frame.c
+++ b/gcc/frame.c
@@ -512,7 +512,7 @@ execute_cfa_insn (void *p, struct frame_state_internal *state,
 /* Called from crtbegin.o to register the unwind info for an object.  */
 
 void
-__register_frame (void *begin, struct object *ob)
+__register_frame_info (void *begin, struct object *ob)
 {
   ob->fde_begin = begin;
 
@@ -533,7 +533,7 @@ __register_frame (void *begin, struct object *ob)
    collect2.  */
 
 void
-__register_frame_table (void *begin, struct object *ob)
+__register_frame_info_table (void *begin, struct object *ob)
 {
   ob->fde_begin = begin;
   ob->fde_array = begin;
@@ -552,7 +552,7 @@ __register_frame_table (void *begin, struct object *ob)
 /* Called from crtend.o to deregister the unwind info for an object.  */
 
 void
-__deregister_frame (void *begin)
+__deregister_frame_info (void *begin)
 {
   struct object **p;
 
diff --git a/gcc/frame.h b/gcc/frame.h
index c1cc7028c2dd..7fa40d7af480 100644
--- a/gcc/frame.h
+++ b/gcc/frame.h
@@ -37,11 +37,16 @@ struct object {
 /* Called either from crtbegin.o or a static constructor to register the
    unwind info for an object or translation unit, respectively.  */
 
-extern void __register_frame (void *, struct object *);
+extern void __register_frame_info (void *, struct object *);
+
+/* Similar, but BEGIN is actually a pointer to a table of unwind entries
+   for different translation units.  Called from the file generated by
+   collect2.  */
+extern void __register_frame_info_table (void *, struct object *);
 
 /* Called from crtend.o to deregister the unwind info for an object.  */
 
-extern void __deregister_frame (void *);
+extern void __deregister_frame_info (void *);
 
 /* Called from __throw to find the registers to restore for a given
    PC_TARGET.  The caller should allocate a local variable of `struct
diff --git a/gcc/function.c b/gcc/function.c
index d13724fea346..2759b80fde08 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -2739,8 +2739,8 @@ purge_addressof_1 (loc, insn, force)
   else if (code == MEM && GET_CODE (XEXP (x, 0)) == ADDRESSOF && ! force)
     {
       rtx sub = XEXP (XEXP (x, 0), 0);
-      if (GET_CODE (sub) != REG)
-	sub = copy_rtx (sub);
+      if (GET_CODE (sub) == MEM)
+	sub = gen_rtx (MEM, GET_MODE (x), copy_rtx (XEXP (sub, 0)));
       if (GET_CODE (sub) == REG && GET_MODE (x) != GET_MODE (sub))
 	{
 	  if (! BYTES_BIG_ENDIAN && ! WORDS_BIG_ENDIAN)
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index ab8fbc2d7696..b2545a2ace74 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -884,17 +884,19 @@ remove_dependence (insn, elem)
   rtx prev, link;
   int found = 0;
 
-  for (prev = 0, link = LOG_LINKS (insn); link;
-       prev = link, link = XEXP (link, 1))
+  for (prev = 0, link = LOG_LINKS (insn); link; link = XEXP (link, 1))
     {
       if (XEXP (link, 0) == elem)
 	{
+	  RTX_INTEGRATED_P (link) = 1;
 	  if (prev)
 	    XEXP (prev, 1) = XEXP (link, 1);
 	  else
 	    LOG_LINKS (insn) = XEXP (link, 1);
 	  found = 1;
 	}
+      else
+	prev = link;
     }
 
   if (!found)
@@ -3210,6 +3212,9 @@ priority (insn)
 	    rtx next;
 	    int next_priority;
 
+	    if (RTX_INTEGRATED_P (link))
+	      continue;
+
 	    next = XEXP (link, 0);
 
 	    /* critical path is meaningful in block boundaries only */
diff --git a/gcc/install.texi b/gcc/install.texi
index bb60f0aa70fa..b879850d4036 100644
--- a/gcc/install.texi
+++ b/gcc/install.texi
@@ -191,7 +191,7 @@ will print out whether the Haifa scheduler is enabled when it is run.
 
 @cindex Objective C threads
 @cindex threads, Objective C
-@item --enable-objcthreads=@var{type}
+@item --enable-threads=@var{type}
 Certain systems, notably Linux-based GNU systems, can't be relied on to
 supply a threads facility for the Objective C runtime and so will
 default to single-threaded runtime.  They may, however, have a library
diff --git a/gcc/pexecute.c b/gcc/pexecute.c
index 9f80cb05b39a..7f1ac4021eb8 100644
--- a/gcc/pexecute.c
+++ b/gcc/pexecute.c
@@ -236,7 +236,7 @@ extern int _spawnvp ();
 /* This is a kludge to get around the Microsoft C spawn functions' propensity
    to remove the outermost set of double quotes from all arguments.  */
 
-const char * const *
+char * const *
 fix_argv (argvec)
      char **argvec;
 {
@@ -267,7 +267,7 @@ fix_argv (argvec)
         argvec[i] = temp;
       }
 
-  return (const char * const *) argvec;
+  return (char * const *) argvec;
 }
 
 #endif /* ! defined (__CYGWIN32__) */
@@ -278,7 +278,8 @@ pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
      char * const *argv;
      const char *this_pname;
      const char *temp_base;
-     char **errmsg_fmt, **errmsg_arg;
+     char **errmsg_fmt;
+     const char **errmsg_arg;
      int flags;
 {
   int pid;
@@ -286,7 +287,7 @@ pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
   if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE)
     abort ();
   pid = (flags & PEXECUTE_SEARCH ? _spawnvp : _spawnv)
-    (_P_NOWAIT, program, fix_argv(argv));
+    (_P_NOWAIT, program, fix_argv (argv));
   if (pid == -1)
     {
       *errmsg_fmt = install_error_msg;
diff --git a/gcc/sched.c b/gcc/sched.c
index a06044e2d295..b7aa75de1eb1 100644
--- a/gcc/sched.c
+++ b/gcc/sched.c
@@ -431,17 +431,19 @@ remove_dependence (insn, elem)
   rtx prev, link;
   int found = 0;
 
-  for (prev = 0, link = LOG_LINKS (insn); link;
-       prev = link, link = XEXP (link, 1))
+  for (prev = 0, link = LOG_LINKS (insn); link; link = XEXP (link, 1))
     {
       if (XEXP (link, 0) == elem)
 	{
+	  RTX_INTEGRATED_P (link) = 1;
 	  if (prev)
 	    XEXP (prev, 1) = XEXP (link, 1);
 	  else
 	    LOG_LINKS (insn) = XEXP (link, 1);
 	  found = 1;
 	}
+      else
+	prev = link;
     }
 
   if (! found)
@@ -919,6 +921,11 @@ priority (insn)
 	{
 	  rtx x = XEXP (prev, 0);
 
+	  /* If this was a duplicate of a dependence we already deleted,
+	     ignore it.  */
+	  if (RTX_INTEGRATED_P (prev))
+	    continue;
+
 	  /* A dependence pointing to a note or deleted insn is always
 	     obsolete, because sched_analyze_insn will have created any
 	     necessary new dependences which replace it.  Notes and deleted
-- 
GitLab