From 0cdc04e8d5b61d4de770b4474a6aa0351ed5b74a Mon Sep 17 00:00:00 2001
From: Steven Bosscher <stevenb.gcc@gmail.com>
Date: Fri, 30 May 2008 18:21:31 +0000
Subject: [PATCH] rs6000.c (rs6000_legitimize_address, [...]): Make sure an rtx
 is a SYMBOL_REF before calling get_pool_constant.

2008-05-30  Steven Bosscher  <stevenb.gcc@gmail.com>

        * config/rs6000/rs6000.c (rs6000_legitimize_address,
        rs6000_legitimize_reload_address, rs6000_emit_move): Make sure an
        rtx is a SYMBOL_REF before calling get_pool_constant.

From-SVN: r136216
---
 gcc/ChangeLog              | 6 ++++++
 gcc/config/rs6000/rs6000.c | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 82d24789424a..1a76fd3e7beb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2008-05-30  Steven Bosscher  <stevenb.gcc@gmail.com>
+
+	* config/rs6000/rs6000.c (rs6000_legitimize_address,
+	rs6000_legitimize_reload_address, rs6000_emit_move): Make sure an
+	rtx is a SYMBOL_REF before calling get_pool_constant.
+
 2008-05-30  Eric Botcazou  <ebotcazou@adacore.com>
 
 	* fold-const.c (fold_unary) <CASE_CONVERT>: Add ??? comment.
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 1eafc999fde4..f91225fe1c8c 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -3746,6 +3746,7 @@ rs6000_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
       return gen_rtx_LO_SUM (Pmode, reg, x);
     }
   else if (TARGET_TOC
+	   && GET_CODE (x) == SYMBOL_REF
 	   && constant_pool_expr_p (x)
 	   && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), Pmode))
     {
@@ -4191,6 +4192,7 @@ rs6000_legitimize_reload_address (rtx x, enum machine_mode mode,
     }
 
   if (TARGET_TOC
+      && GET_CODE (x) == SYMBOL_REF
       && constant_pool_expr_p (x)
       && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), mode))
     {
@@ -5041,6 +5043,7 @@ rs6000_emit_move (rtx dest, rtx source, enum machine_mode mode)
 	  operands[1] = force_const_mem (mode, operands[1]);
 
 	  if (TARGET_TOC
+	      && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
 	      && constant_pool_expr_p (XEXP (operands[1], 0))
 	      && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (
 			get_pool_constant (XEXP (operands[1], 0)),
@@ -12359,6 +12362,7 @@ print_operand_address (FILE *file, rtx x)
 
 	  minus = XEXP (contains_minus, 0);
 	  symref = XEXP (minus, 0);
+	  gcc_assert (GET_CODE (XEXP (minus, 1)) == SYMBOL_REF);
 	  XEXP (contains_minus, 0) = symref;
 	  if (TARGET_ELF)
 	    {
-- 
GitLab