diff options
author | krebbel <krebbel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-12-22 14:50:29 +0000 |
---|---|---|
committer | krebbel <krebbel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-12-22 14:50:29 +0000 |
commit | de048324059a2d7863b34d783d2ac819dd9509e9 (patch) | |
tree | b224567ef58decaaa51a7eba54c6eee97a6dd51a | |
parent | a39f57635df6ce3bf595f747a30d252acc2dff51 (diff) | |
download | gcc-de048324059a2d7863b34d783d2ac819dd9509e9.tar.gz |
varasm: Propagate litpool decl alignment to generated RTX.
When pushing a value into the literal pool the resulting decl might
get a higher alignment than the original expression depending on how a
target defines CONSTANT_ALIGNMENT. Generating an RTX for the constant
pool access we currently use the alignment from the original
expression. Changed with the attached patch.
This fixes a GCC 6 regression for S/390. For arrays of string
constants as in the attached testcase encode_section_info is not able
to figure out that the constant pool slot is already properly aligned
since the mem_align field in the rtx is not set properly.
gcc/ChangeLog:
2016-12-22 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* varasm.c (build_constant_desc): Use the alignment of the var
decl instead of the original expression.
gcc/testsuite/ChangeLog:
2016-12-22 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* gcc.target/s390/litpool-str-1.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243888 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/s390/litpool-str-1.c | 22 | ||||
-rw-r--r-- | gcc/varasm.c | 4 |
4 files changed, 35 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f3f3816f457..64f7b88d3ad 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-12-22 Andreas Krebbel <krebbel@linux.vnet.ibm.com> + + * varasm.c (build_constant_desc): Use the alignment of the var + decl instead of the original expression. + 2016-12-22 Dominik Vogt <vogt@linux.vnet.ibm.com> * config/s390/s390-c.c (s390_cpu_cpp_builtins_internal): Define diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1532f18651c..368f7eaceb1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-12-22 Andreas Krebbel <krebbel@linux.vnet.ibm.com> + + * gcc.target/s390/litpool-str-1.c: New test. + 2016-12-22 Dominik Vogt <vogt@linux.vnet.ibm.com> * gcc.target/s390/md/setmem_long-1.c: Use "s390_useable_hw". diff --git a/gcc/testsuite/gcc.target/s390/litpool-str-1.c b/gcc/testsuite/gcc.target/s390/litpool-str-1.c new file mode 100644 index 00000000000..cd921d2a565 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/litpool-str-1.c @@ -0,0 +1,22 @@ +/* Make sure strings are recognized as being accessible through larl. + This requires the symbol ref alignment properly propagated to + encode_section_info. */ + +/* { dg-do compile } */ +/* { dg-options "-march=z900 -O2 -fpic" } */ + + +extern void foo(const char*, const char*, const char*); + +void bar(int i) +{ + const char t1[10] = "test"; + const char t2[10] = "test2"; + const char t3[2][10] = { + "foofoofoo", + "barbarbar", + }; + foo(t1, t2, t3[i]); +} + +/* { dg-final { scan-assembler-not "GOTOFF" } } */ diff --git a/gcc/varasm.c b/gcc/varasm.c index 5b158472fc6..75d5ad6842d 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -3296,6 +3296,10 @@ build_constant_desc (tree exp) set_mem_attributes (rtl, exp, 1); set_mem_alias_set (rtl, 0); + /* Putting EXP into the literal pool might have imposed a different + alignment which should be visible in the RTX as well. */ + set_mem_align (rtl, DECL_ALIGN (decl)); + /* We cannot share RTX'es in pool entries. Mark this piece of RTL as required for unsharing. */ RTX_FLAG (rtl, used) = 1; |