diff options
author | Claudiu Zissulescu <claziss@gmail.com> | 2019-11-11 15:40:09 +0000 |
---|---|---|
committer | Claudiu Zissulescu <claziss@gcc.gnu.org> | 2019-11-11 16:40:09 +0100 |
commit | 3a6dd06b6ce8be29cdcfd0b3a0c5e6c66767095e (patch) | |
tree | d2c6f9613e5f0c63d11504626c807694ee3fa4ac /gcc | |
parent | e22c2220273615294dc7fb11867267ca92694358 (diff) | |
download | gcc-3a6dd06b6ce8be29cdcfd0b3a0c5e6c66767095e.zip gcc-3a6dd06b6ce8be29cdcfd0b3a0c5e6c66767095e.tar.gz gcc-3a6dd06b6ce8be29cdcfd0b3a0c5e6c66767095e.tar.bz2 |
[ARC] Fix legitimize pic address.
There are cases when an pic address gets complicated, and it needs to
be resolved via force_reg function found in
prepare_move_operands. When this happens, we need to disambiguate the
pic address and re-legitimize it.
gcc/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* config/arc/arc.c (arc_legitimize_pic_address): Consider UNSPECs
as well, if interesting recover the symbol and re-legitimize the
pic address.
gcc/testsuite/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* gcc.target/arc/pic-2.c: New file.
From-SVN: r278056
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/config/arc/arc.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/arc/pic-2.c | 23 |
4 files changed, 49 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9595b76..ff62a22 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-11-11 Claudiu Zissulescu <claziss@gmail.com> + + * config/arc/arc.c (arc_legitimize_pic_address): Consider UNSPECs + as well, if interesting recover the symbol and re-legitimize the + pic address. + 2019-11-11 Martin Liska <mliska@suse.cz> * dbgcnt.def (DEBUG_COUNTER): Sort counters diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index e8f4133..c2d38dd 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -6219,6 +6219,22 @@ arc_legitimize_pic_address (rtx addr) switch (GET_CODE (addr)) { + case UNSPEC: + /* Can be one or our GOT or GOTOFFPC unspecs. This situation + happens when an address is not a legitimate constant and we + need the resolve it via force_reg in + prepare_move_operands. */ + switch (XINT (addr, 1)) + { + case ARC_UNSPEC_GOT: + case ARC_UNSPEC_GOTOFFPC: + /* Recover the symbol ref. */ + addr = XVECEXP (addr, 0, 0); + break; + default: + return addr; + } + /* Fall through. */ case SYMBOL_REF: /* TLS symbols are handled in different place. */ if (SYMBOL_REF_TLS_MODEL (addr)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ebdf611..06d9851 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-11-11 Claudiu Zissulescu <claziss@gmail.com> + + * gcc.target/arc/pic-2.c: New file. + 2019-11-11 Tobias Burnus <tobias@codesourcery.com> Mark Eggleston <mark.eggleston@codethink.com> diff --git a/gcc/testsuite/gcc.target/arc/pic-2.c b/gcc/testsuite/gcc.target/arc/pic-2.c new file mode 100644 index 0000000..4b0e171 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/pic-2.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-skip-if "PIC not available for ARC6xx" { arc6xx } } */ +/* { dg-options "-mno-sdata -O2 -fpic -fno-builtin" } */ + +/* Check if we resolve correctly complex PIC addresses. */ + +char *foo (unsigned size) +{ + static char buf[32]; + register int i; + + if (size > 31) + size = 31; + + for (i = 0; i < size; i++) + { + buf[i] = ' '; + } + buf[size] = '\0'; + return buf; +} + +/* { dg-final { scan-assembler "@buf.\[0-9\]\+@pcl-1" } } */ |