public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/29198] New: Incorrect reference to __thread array with -fPIC -O2 on x86
@ 2006-09-24 5:21 ian at airs dot com
2006-09-24 5:29 ` [Bug target/29198] [4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: ian at airs dot com @ 2006-09-24 5:21 UTC (permalink / raw)
To: gcc-bugs
I compiled this C code with current mainline with -fPIC -O2 on x86 GNU/Linux:
extern int f2 (int, int, int, int);
struct s { char b[4]; };
__thread struct s a[2];
void 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);
a[0].b[i] = tot;
}
}
The resulting assembler file had this in it:
movl a@GOT(%ebx), %ecx
But a is declared with __thread. This should instead be something like:
leal a@TLSGD(,%ebx,1), %eax
call ___tls_get_addr@PLT
In the real code there are other references to a, which leads to a linker
error:
`a' accessed both as normal and thread local symbol
I believe the bug is in legitimize_address or in legitimize_pic_address in
config/i386/i386.c. legitimize_address gets called with
(plus:SI (reg/v:SI 64 [ i ])
(symbol_ref:SI ("a") [flags 0x8] <var_decl 0xb7c630b0 a>))
When it sees a symbol as the right-hand operand of a PLUS, it calls
legitimize_pic_address. That returns an UNSPEC_GOT. Somewhere along the way,
it needs to call legitimize_tls_address.
--
Summary: Incorrect reference to __thread array with -fPIC -O2 on
x86
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ian at airs dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29198
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/29198] [4.0/4.1/4.2 Regression] Incorrect reference to __thread array with -fPIC -O2 on x86
2006-09-24 5:21 [Bug target/29198] New: Incorrect reference to __thread array with -fPIC -O2 on x86 ian at airs dot com
@ 2006-09-24 5:29 ` pinskia at gcc dot gnu dot org
2006-09-24 5:31 ` pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-24 5:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-09-24 05:29 -------
Confirmed, this testcase worked in 3.4.0 but that might just mean this is a
latent bug.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |wrong-code
Known to fail| |4.0.0 4.1.0 4.2.0
Known to work| |3.4.0
Last reconfirmed|0000-00-00 00:00:00 |2006-09-24 05:29:30
date| |
Summary|Incorrect reference to |[4.0/4.1/4.2 Regression]
|__thread array with -fPIC - |Incorrect reference to
|O2 on x86 |__thread array with -fPIC -
| |O2 on x86
Target Milestone|--- |4.0.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29198
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/29198] [4.0/4.1/4.2 Regression] Incorrect reference to __thread array with -fPIC -O2 on x86
2006-09-24 5:21 [Bug target/29198] New: Incorrect reference to __thread array with -fPIC -O2 on x86 ian at airs dot com
2006-09-24 5:29 ` [Bug target/29198] [4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
@ 2006-09-24 5:31 ` pinskia at gcc dot gnu dot org
2006-09-24 5:34 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-24 5:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2006-09-24 05:31 -------
I should note that -fno-ivopts causes to produce the correct result for this
testcase. I am going to try to find a testcase that fails even with 3.4.0.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29198
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/29198] [4.0/4.1/4.2 Regression] Incorrect reference to __thread array with -fPIC -O2 on x86
2006-09-24 5:21 [Bug target/29198] New: Incorrect reference to __thread array with -fPIC -O2 on x86 ian at airs dot com
2006-09-24 5:29 ` [Bug target/29198] [4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
2006-09-24 5:31 ` pinskia at gcc dot gnu dot org
@ 2006-09-24 5:34 ` pinskia at gcc dot gnu dot org
2006-09-29 11:30 ` jakub at gcc dot gnu dot org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-24 5:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2006-09-24 05:34 -------
Here is a testcase which shows this is a latent bug:
extern int f2 (int, int, int, int);
struct s { char b[4]; };
__thread struct s a[2];
void 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);
*(&a[0].b[0] + i) = tot;
}
}
------
But since the orginal testcase worked in 3.4.0, this should be still marked as
a regression, IV-OPTs is causing the latent bug to show up.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29198
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/29198] [4.0/4.1/4.2 Regression] Incorrect reference to __thread array with -fPIC -O2 on x86
2006-09-24 5:21 [Bug target/29198] New: Incorrect reference to __thread array with -fPIC -O2 on x86 ian at airs dot com
` (2 preceding siblings ...)
2006-09-24 5:34 ` pinskia at gcc dot gnu dot org
@ 2006-09-29 11:30 ` jakub at gcc dot gnu dot org
2006-10-01 22:59 ` mmitchel at gcc dot gnu dot org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-09-29 11:30 UTC (permalink / raw)
To: gcc-bugs
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jakub at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2006-09-24 05:29:30 |2006-09-29 11:29:51
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29198
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/29198] [4.0/4.1/4.2 Regression] Incorrect reference to __thread array with -fPIC -O2 on x86
2006-09-24 5:21 [Bug target/29198] New: Incorrect reference to __thread array with -fPIC -O2 on x86 ian at airs dot com
` (3 preceding siblings ...)
2006-09-29 11:30 ` jakub at gcc dot gnu dot org
@ 2006-10-01 22:59 ` mmitchel at gcc dot gnu dot org
2006-10-06 7:25 ` jakub at gcc dot gnu dot org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-10-01 22:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from mmitchel at gcc dot gnu dot org 2006-10-01 22:59 -------
I'm marking this P2, rather than P1, because the use of TLS structures seems a
bit of a corner-case. Feel free to lobby to make this a P1.
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29198
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/29198] [4.0/4.1/4.2 Regression] Incorrect reference to __thread array with -fPIC -O2 on x86
2006-09-24 5:21 [Bug target/29198] New: Incorrect reference to __thread array with -fPIC -O2 on x86 ian at airs dot com
` (4 preceding siblings ...)
2006-10-01 22:59 ` mmitchel at gcc dot gnu dot org
@ 2006-10-06 7:25 ` jakub at gcc dot gnu dot org
2006-10-06 7:36 ` jakub at gcc dot gnu dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-10-06 7:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jakub at gcc dot gnu dot org 2006-10-06 07:25 -------
Subject: Bug 29198
Author: jakub
Date: Fri Oct 6 07:25:02 2006
New Revision: 117483
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117483
Log:
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.
Added:
trunk/gcc/testsuite/gcc.dg/tls/opt-12.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/i386/i386.c
trunk/gcc/config/i386/predicates.md
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29198
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/29198] [4.0/4.1/4.2 Regression] Incorrect reference to __thread array with -fPIC -O2 on x86
2006-09-24 5:21 [Bug target/29198] New: Incorrect reference to __thread array with -fPIC -O2 on x86 ian at airs dot com
` (5 preceding siblings ...)
2006-10-06 7:25 ` jakub at gcc dot gnu dot org
@ 2006-10-06 7:36 ` jakub at gcc dot gnu dot org
2006-10-06 7:41 ` [Bug target/29198] [4.0 " jakub at gcc dot gnu dot org
2007-02-03 20:22 ` gdr at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-10-06 7:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jakub at gcc dot gnu dot org 2006-10-06 07:35 -------
Subject: Bug 29198
Author: jakub
Date: Fri Oct 6 07:35:45 2006
New Revision: 117486
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117486
Log:
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.
Added:
branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/tls/opt-12.c
Modified:
branches/gcc-4_1-branch/gcc/ChangeLog
branches/gcc-4_1-branch/gcc/config/i386/i386.c
branches/gcc-4_1-branch/gcc/config/i386/predicates.md
branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29198
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/29198] [4.0 Regression] Incorrect reference to __thread array with -fPIC -O2 on x86
2006-09-24 5:21 [Bug target/29198] New: Incorrect reference to __thread array with -fPIC -O2 on x86 ian at airs dot com
` (6 preceding siblings ...)
2006-10-06 7:36 ` jakub at gcc dot gnu dot org
@ 2006-10-06 7:41 ` jakub at gcc dot gnu dot org
2007-02-03 20:22 ` gdr at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-10-06 7:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jakub at gcc dot gnu dot org 2006-10-06 07:41 -------
Fixed on the trunk and on 4.1 branch.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail|4.0.0 4.1.0 4.2.0 |4.0.0 4.1.0 4.1.1
Known to work|3.4.0 |3.4.0 4.1.2 4.2.0
Summary|[4.0/4.1/4.2 Regression] |[4.0 Regression] Incorrect
|Incorrect reference to |reference to __thread array
|__thread array with -fPIC - |with -fPIC -O2 on x86
|O2 on x86 |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29198
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/29198] [4.0 Regression] Incorrect reference to __thread array with -fPIC -O2 on x86
2006-09-24 5:21 [Bug target/29198] New: Incorrect reference to __thread array with -fPIC -O2 on x86 ian at airs dot com
` (7 preceding siblings ...)
2006-10-06 7:41 ` [Bug target/29198] [4.0 " jakub at gcc dot gnu dot org
@ 2007-02-03 20:22 ` gdr at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: gdr at gcc dot gnu dot org @ 2007-02-03 20:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from gdr at gcc dot gnu dot org 2007-02-03 20:22 -------
Fixed in GCC-4.1.2.
--
gdr at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29198
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-02-03 20:22 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-24 5:21 [Bug target/29198] New: Incorrect reference to __thread array with -fPIC -O2 on x86 ian at airs dot com
2006-09-24 5:29 ` [Bug target/29198] [4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
2006-09-24 5:31 ` pinskia at gcc dot gnu dot org
2006-09-24 5:34 ` pinskia at gcc dot gnu dot org
2006-09-29 11:30 ` jakub at gcc dot gnu dot org
2006-10-01 22:59 ` mmitchel at gcc dot gnu dot org
2006-10-06 7:25 ` jakub at gcc dot gnu dot org
2006-10-06 7:36 ` jakub at gcc dot gnu dot org
2006-10-06 7:41 ` [Bug target/29198] [4.0 " jakub at gcc dot gnu dot org
2007-02-03 20:22 ` gdr at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).