diff options
author | Jakub Jelinek <jakub@redhat.com> | 2006-10-06 09:25:02 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2006-10-06 09:25:02 +0200 |
commit | c1a46941d41c8f3de4b9eb2f4bb95eaa99fb7146 (patch) | |
tree | 06aa32ae359e2b332fbb0a1059962011090120d6 /gcc | |
parent | 9eccb94dff81cd39b3c29086f3b83fa058b92f0c (diff) | |
download | gcc-c1a46941d41c8f3de4b9eb2f4bb95eaa99fb7146.zip gcc-c1a46941d41c8f3de4b9eb2f4bb95eaa99fb7146.tar.gz gcc-c1a46941d41c8f3de4b9eb2f4bb95eaa99fb7146.tar.bz2 |
re PR target/29198 (Incorrect reference to __thread array with -fPIC -O2 on x86)
PR target/29198
* config/i386/i386.c (legitimize_pic_address): Reject TLS symbols.
* config/i386/predicates.md (local_symbolic_operand): Likewise.
* gcc.dg/tls/opt-12.c: New test.
From-SVN: r117483
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 2 | ||||
-rw-r--r-- | gcc/config/i386/predicates.md | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tls/opt-12.c | 50 |
5 files changed, 61 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3eaecfe..59bafde 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2006-10-06 Jakub Jelinek <jakub@redhat.com> + PR target/29198 + * config/i386/i386.c (legitimize_pic_address): Reject TLS symbols. + * config/i386/predicates.md (local_symbolic_operand): Likewise. + PR c/29091 * varasm.c (output_constant): If TREE_VECTOR_CST_ELTS chain is shorter than the number of vector elements fill the rest with zeros. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index cdbd0c6..287163e 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -6623,7 +6623,7 @@ legitimize_pic_address (rtx orig, rtx reg) new = reg; } } - else if (GET_CODE (addr) == SYMBOL_REF) + else if (GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_TLS_MODEL (addr) == 0) { if (TARGET_64BIT) { diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index 457f556..5201191 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -447,6 +447,9 @@ if (GET_CODE (op) != SYMBOL_REF) return 0; + if (SYMBOL_REF_TLS_MODEL (op) != 0) + return 0; + if (SYMBOL_REF_LOCAL_P (op)) return 1; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ce15a0f..5027cb4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2006-10-06 Jakub Jelinek <jakub@redhat.com> + PR target/29198 + * gcc.dg/tls/opt-12.c: New test. + PR fortran/28415 * gfortran.dg/save_2.f90: New test. diff --git a/gcc/testsuite/gcc.dg/tls/opt-12.c b/gcc/testsuite/gcc.dg/tls/opt-12.c new file mode 100644 index 0000000..7c6e734 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tls/opt-12.c @@ -0,0 +1,50 @@ +/* PR target/29198 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fpic" } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-require-effective-target fpic } */ + +extern void abort (void); + +int f2 (int, int, int, int); +struct s { char b[4]; }; +__thread struct s thra[2]; + +void +__attribute__((noinline)) +f1 (int a1, int a2) +{ + int i, j; + for (i = 0; i < 4; i++) + { + int tot = 0; + for (j = 0; j < 4; j++) + tot += f2 (a1, a2, i, j); + *(&thra[0].b[0] + i) = tot; + } +} + +int +__attribute__((noinline)) +f2 (int a, int b, int c, int d) +{ + return a + b + c + d; +} + +int +main (void) +{ + f1 (0, 0); + if (thra[0].b[0] != 6 + || thra[0].b[1] != 10 + || thra[0].b[2] != 14 + || thra[0].b[3] != 18) + abort (); + f1 (2, 3); + if (thra[0].b[0] != 26 + || thra[0].b[1] != 30 + || thra[0].b[2] != 34 + || thra[0].b[3] != 38) + abort (); + return 0; +} |