commit 9b3a8400aeb43ad9ce0c753dc8fecac9db304da3
Author: Olivier Hainque <hainque@adacore.com>
Date:   Tue Mar 22 18:37:27 2016 +0100

    initial port from 4.9

diff --git a/gcc/alias.c b/gcc/alias.c
index 753e1af..09a709f 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -3241,9 +3241,12 @@ init_alias_analysis (void)
      insn chain until after reload has completed.  Thus,
      there is no sense wasting time checking if INSN is in
      the prologue/epilogue until after reload has completed.  */
-  bool could_be_prologue_epilogue = ((targetm.have_prologue ()
-				      || targetm.have_epilogue ())
-				     && reload_completed);
+
+  bool could_be_prologue = (targetm.have_prologue ()
+			    && reload_completed);
+
+  bool could_be_epilogue = (targetm.have_epilogue ()
+			    && reload_completed);
 
   pass = 0;
   do
@@ -3283,8 +3286,19 @@ init_alias_analysis (void)
 		{
 		  rtx note, set;
 
-		  if (could_be_prologue_epilogue
-		      && prologue_epilogue_contains (insn))
+		  /* Skip prologue instructions threaded onto the insn chain
+		     after reload, which bring nothing of interest to alias
+		     analysis within the function's body.  */
+		  if (could_be_prologue
+		      && prologue_contains (insn))
+		    continue;
+
+		  /* Likewise for epilogue instructions, except for possible
+		     needs within the epilogue sequence itself.  */
+		  if (could_be_epilogue
+		      && epilogue_contains (insn)
+		      && (!targetm.epilogue_aliases ()
+			  || RTX_FRAME_RELATED_P (insn)))
 		    continue;
 
 		  /* If this insn has a noalias note, process it,  Otherwise,
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index fd4b7cc..cf5ca42 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -1712,6 +1712,11 @@ static const struct attribute_spec rs6000_attribute_table[] =
 #define TARGET_ASM_OUTPUT_DWARF_DTPREL rs6000_output_dwarf_dtprel
 #endif
 
+/* Our stack_tie mechanism requires visibility on intermediate
+   base register computations in the epilogue.  */
+#undef TARGET_EPILOGUE_ALIASES
+#define  TARGET_EPILOGUE_ALIASES  hook_bool_void_true
+
 /* Use a 32-bit anchor range.  This leads to sequences like:
 
 	addis	tmp,anchor,high
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 745910f..20c17f6 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -11289,6 +11289,16 @@ or when the back end is in a partially-initialized state.
 outside of any function scope.
 @end deftypefn
 
+@deftypefn {Target Hook} bool TARGET_EPILOGUE_ALIASES (void)
+This target hook should return @code{true} if the target needs
+alias analysis to look into operations performed by epilogue instructions
+*not* marked @code{RTX_FRAME_RELATED_P}.
+This needs only be redefined by targets which use precise memory references
+with specially assigned alias sets instead of a strong blockage to prevent
+the move of register restores past the stack frame release.
+Default return value is @code{false}.
+@end deftypefn
+
 @defmac TARGET_OBJECT_SUFFIX
 Define this macro to be a C string representing the suffix for object
 files on your target machine.  If you do not define this macro, GCC will
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index f31c763..b4b6b1a 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -8039,6 +8039,8 @@ to by @var{ce_info}.
 
 @hook TARGET_SET_CURRENT_FUNCTION
 
+@hook TARGET_EPILOGUE_ALIASES
+
 @defmac TARGET_OBJECT_SUFFIX
 Define this macro to be a C string representing the suffix for object
 files on your target machine.  If you do not define this macro, GCC will
diff --git a/gcc/function.c b/gcc/function.c
index 1ac8e26..f025f21 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -5743,14 +5743,28 @@ contains (const_rtx insn, hash_table<insn_cache_hasher> *hash)
   return hash->find (const_cast<rtx> (insn)) != NULL;
 }
 
-int
+/* Whether INSN is part of the function's prologue sequence.  */
+
+bool
+prologue_contains (const_rtx insn)
+{
+  return contains (insn, prologue_insn_hash);
+}
+
+/* Whether INSN is part of the function's epilogue sequence.  */
+
+bool
+epilogue_contains (const_rtx insn)
+{
+  return contains (insn, epilogue_insn_hash);
+}
+
+/* Whether INSN is part of the function's prologue or epilogue sequence.  */
+
+bool
 prologue_epilogue_contains (const_rtx insn)
 {
-  if (contains (insn, prologue_insn_hash))
-    return 1;
-  if (contains (insn, epilogue_insn_hash))
-    return 1;
-  return 0;
+  return prologue_contains (insn) || epilogue_contains (insn);
 }
 
 /* Insert use of return register before the end of BB.  */
diff --git a/gcc/function.h b/gcc/function.h
index 501ef68..81d9e50 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -628,7 +628,9 @@ extern void clobber_return_register (void);
 extern void expand_function_end (void);
 extern rtx get_arg_pointer_save_area (void);
 extern void maybe_copy_prologue_epilogue_insn (rtx, rtx);
-extern int prologue_epilogue_contains (const_rtx);
+extern bool prologue_contains (const_rtx);
+extern bool epilogue_contains (const_rtx);
+extern bool prologue_epilogue_contains (const_rtx);
 extern void emit_return_into_block (bool simple_p, basic_block bb);
 extern void set_return_jump_label (rtx_insn *);
 extern bool active_insn_between (rtx_insn *head, rtx_insn *tail);
diff --git a/gcc/target.def b/gcc/target.def
index 20f2b32..9276858 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -3417,6 +3417,19 @@ move would be greater than that of a library call.",
         enum by_pieces_operation op, bool speed_p),
  default_use_by_pieces_infrastructure_p)
 
+/* Return true if a function must have and use a frame pointer.  */
+DEFHOOK
+(epilogue_aliases,
+ "This target hook should return @code{true} if the target needs\n"
+ "alias analysis to look into operations performed by epilogue instructions\n"
+ "*not* marked @code{RTX_FRAME_RELATED_P}.\n"
+ "This needs only be redefined by targets which use precise memory references\n"
+ "with specially assigned alias sets instead of a strong blockage to prevent\n"
+ "the move of register restores past the stack frame release.\n"
+ "Default return value is @code{false}.",
+ bool, (void),
+ hook_bool_void_false)
+
 DEFHOOK
 (optab_supported_p,
  "Return true if the optimizers should use optab @var{op} with\n\
