diff options
author | Segher Boessenkool <segher@kernel.crashing.org> | 2018-08-24 12:49:27 +0200 |
---|---|---|
committer | Segher Boessenkool <segher@gcc.gnu.org> | 2018-08-24 12:49:27 +0200 |
commit | 6a84c265a32e6f407cf6712040df65527ffcf445 (patch) | |
tree | 364aca4dbfe41c04f0e148cfaa6af3da73c1cd88 /gcc | |
parent | 19b293bfa70872c850f2d399fc2facf4687e76ee (diff) | |
download | gcc-6a84c265a32e6f407cf6712040df65527ffcf445.zip gcc-6a84c265a32e6f407cf6712040df65527ffcf445.tar.gz gcc-6a84c265a32e6f407cf6712040df65527ffcf445.tar.bz2 |
rs6000: Check that the base of a TOCREL is the TOC (PR86989)
There currently is nothing that prevents replacing the TOC_REGISTER in
a TOCREL unspec with something else, like a pseudo, or a memory ref.
This of course does not work. Fix that.
Tested on powerpc64-linux {-m32,-m64}; committing.
Segher
2018-08-24 Segher Boessenkool <segher@kernel.crashing.org>
PR target/86989
* config/rs6000/rs6000.c (toc_relative_expr_p): Check that the base is
the TOC register.
---
gcc/config/rs6000/rs6000.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index a967912..ed33912 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -7932,7 +7932,9 @@ toc_relative_expr_p (const_rtx op, bool strict, const_rtx *tocrel_base_ret,
*tocrel_offset_ret = tocrel_offset;
return (GET_CODE (tocrel_base) == UNSPEC
- && XINT (tocrel_base, 1) == UNSPEC_TOCREL);
+ && XINT (tocrel_base, 1) == UNSPEC_TOCREL
+ && REG_P (XVECEXP (tocrel_base, 0, 1))
+ && REGNO (XVECEXP (tocrel_base, 0, 1)) == TOC_REGISTER);
}
/* Return true if X is a constant pool address, and also for cmodel=medium
--
1.8.3.1
From-SVN: r263829
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7c757c0..08a0c08 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-08-24 Segher Boessenkool <segher@kernel.crashing.org> + + PR target/86989 + * config/rs6000/rs6000.c (toc_relative_expr_p): Check that the base is + the TOC register. + 2018-08-24 Aldy Hernandez <aldyh@redhat.com> PR 87073/bootstrap diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 252d197..ecaf071 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -7943,7 +7943,9 @@ toc_relative_expr_p (const_rtx op, bool strict, const_rtx *tocrel_base_ret, *tocrel_offset_ret = tocrel_offset; return (GET_CODE (tocrel_base) == UNSPEC - && XINT (tocrel_base, 1) == UNSPEC_TOCREL); + && XINT (tocrel_base, 1) == UNSPEC_TOCREL + && REG_P (XVECEXP (tocrel_base, 0, 1)) + && REGNO (XVECEXP (tocrel_base, 0, 1)) == TOC_REGISTER); } /* Return true if X is a constant pool address, and also for cmodel=medium |