public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/38287] New: wrong-code with -O2 -fPIC on sparc-linux-gnu
@ 2008-11-27 13:06 debian-gcc at lists dot debian dot org
2008-11-27 21:15 ` [Bug target/38287] [4.1/4.2/4.3 regression] segfault at -O2 -fPIC -mcpu=v8 ebotcazou at gcc dot gnu dot org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2008-11-27 13:06 UTC (permalink / raw)
To: gcc-bugs
[forwarded from http://bugs.debian.org/506713]
seen with 4.1, 4.2, 4.3 branches, not on the trunk
Functions compiled for SPARC with both -O2 and -fPIC options, which
return structures and require global data, may have incorrect code
generated for them.
The following example is based on Qt 3, which is affected by this bug
(see #490999). The code should of course print "1 + 1 = 2" but when
compiled for SPARC with -O2 -fPIC it prints "1 + 1 = 0" (or may crash).
The first two instructions generated for QTime::addMSecs() are a save
using %sp and a load relative to %sp which depends on the *old* value of
%sp.
This example appears to be compiled correctly if I remove either option
or reduce the value of MSECS_PER_DAY such that it can be an immediate
constant.
Ben.
#include <iostream>
class QTime
{
public:
explicit QTime(int ms = 0) : ds(ms) {}
static QTime currentTime() { return QTime(); }
QTime addMSecs(int ms) const;
int msecs() const { return ds; }
private:
unsigned ds;
};
static const unsigned MSECS_PER_DAY = 86400000;
QTime QTime::addMSecs( int ms ) const
{
QTime t;
if ( ms < 0 ) {
// % not well-defined for -ve, but / is.
int negdays = (MSECS_PER_DAY-ms) / MSECS_PER_DAY;
t.ds = ((int)ds + ms + negdays*MSECS_PER_DAY)
% MSECS_PER_DAY;
} else {
t.ds = ((int)ds + ms) % MSECS_PER_DAY;
}
return t;
}
int main(int argc, char* argv[] )
{
std::cout << "1 + 1 = " << QTime(1).addMSecs(1).msecs() << std::endl;
}
--
Summary: wrong-code with -O2 -fPIC on sparc-linux-gnu
Product: gcc
Version: 4.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: debian-gcc at lists dot debian dot org
GCC target triplet: sparc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38287
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/38287] [4.1/4.2/4.3 regression] segfault at -O2 -fPIC -mcpu=v8
2008-11-27 13:06 [Bug target/38287] New: wrong-code with -O2 -fPIC on sparc-linux-gnu debian-gcc at lists dot debian dot org
@ 2008-11-27 21:15 ` ebotcazou at gcc dot gnu dot org
2008-11-27 21:21 ` ebotcazou at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2008-11-27 21:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from ebotcazou at gcc dot gnu dot org 2008-11-27 21:14 -------
Reproducible on Solaris as well (with -mcpu=v8 since -mcpu=v9 is the default).
--
ebotcazou at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
GCC target triplet|sparc-linux-gnu |sparc*-*-*
Known to work|4.4.0 |3.4.6 4.4.0
Last reconfirmed|0000-00-00 00:00:00 |2008-11-27 21:14:18
date| |
Summary|wrong-code with -O2 -fPIC on|[4.1/4.2/4.3 regression]
|sparc-linux-gnu |segfault at -O2 -fPIC -
| |mcpu=v8
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38287
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/38287] [4.1/4.2/4.3 regression] segfault at -O2 -fPIC -mcpu=v8
2008-11-27 13:06 [Bug target/38287] New: wrong-code with -O2 -fPIC on sparc-linux-gnu debian-gcc at lists dot debian dot org
2008-11-27 21:15 ` [Bug target/38287] [4.1/4.2/4.3 regression] segfault at -O2 -fPIC -mcpu=v8 ebotcazou at gcc dot gnu dot org
@ 2008-11-27 21:21 ` ebotcazou at gcc dot gnu dot org
2008-11-30 19:21 ` ebotcazou at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2008-11-27 21:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from ebotcazou at gcc dot gnu dot org 2008-11-27 21:20 -------
Investigating.
--
ebotcazou at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |ebotcazou at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2008-11-27 21:14:18 |2008-11-27 21:20:00
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38287
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/38287] [4.1/4.2/4.3 regression] segfault at -O2 -fPIC -mcpu=v8
2008-11-27 13:06 [Bug target/38287] New: wrong-code with -O2 -fPIC on sparc-linux-gnu debian-gcc at lists dot debian dot org
2008-11-27 21:15 ` [Bug target/38287] [4.1/4.2/4.3 regression] segfault at -O2 -fPIC -mcpu=v8 ebotcazou at gcc dot gnu dot org
2008-11-27 21:21 ` ebotcazou at gcc dot gnu dot org
@ 2008-11-30 19:21 ` ebotcazou at gcc dot gnu dot org
2008-11-30 19:23 ` ebotcazou at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2008-11-30 19:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from ebotcazou at gcc dot gnu dot org 2008-11-30 19:20 -------
Subject: Bug 38287
Author: ebotcazou
Date: Sun Nov 30 19:19:06 2008
New Revision: 142295
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142295
Log:
PR target/38287
* config/sparc/sparc.md (divsi3 expander): Remove constraints.
(divsi3_sp32): Add new alternative with 'K' for operand #2.
(cmp_sdiv_cc_set): Factor common string.
(udivsi3_sp32): Add new alternative with 'K' for operand #2.
Add TARGET_V9 case.
(cmp_udiv_cc_set): Factor common string.
Added:
trunk/gcc/testsuite/g++.dg/opt/reload3.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/sparc/sparc.md
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38287
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/38287] [4.1/4.2/4.3 regression] segfault at -O2 -fPIC -mcpu=v8
2008-11-27 13:06 [Bug target/38287] New: wrong-code with -O2 -fPIC on sparc-linux-gnu debian-gcc at lists dot debian dot org
` (2 preceding siblings ...)
2008-11-30 19:21 ` ebotcazou at gcc dot gnu dot org
@ 2008-11-30 19:23 ` ebotcazou at gcc dot gnu dot org
2008-11-30 19:24 ` ebotcazou at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2008-11-30 19:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from ebotcazou at gcc dot gnu dot org 2008-11-30 19:22 -------
Subject: Bug 38287
Author: ebotcazou
Date: Sun Nov 30 19:21:10 2008
New Revision: 142296
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142296
Log:
PR target/38287
* config/sparc/sparc.md (divsi3 expander): Remove constraints.
(divsi3_sp32): Add new alternative with 'K' for operand #2.
(cmp_sdiv_cc_set): Factor common string.
(udivsi3_sp32): Add new alternative with 'K' for operand #2.
Add TARGET_V9 case.
(cmp_udiv_cc_set): Factor common string.
Added:
branches/gcc-4_3-branch/gcc/testsuite/g++.dg/opt/reload3.C
Modified:
branches/gcc-4_3-branch/gcc/ChangeLog
branches/gcc-4_3-branch/gcc/config/sparc/sparc.md
branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38287
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/38287] [4.1/4.2/4.3 regression] segfault at -O2 -fPIC -mcpu=v8
2008-11-27 13:06 [Bug target/38287] New: wrong-code with -O2 -fPIC on sparc-linux-gnu debian-gcc at lists dot debian dot org
` (3 preceding siblings ...)
2008-11-30 19:23 ` ebotcazou at gcc dot gnu dot org
@ 2008-11-30 19:24 ` ebotcazou at gcc dot gnu dot org
2008-11-30 19:25 ` ebotcazou at gcc dot gnu dot org
2008-11-30 19:29 ` ebotcazou at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2008-11-30 19:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from ebotcazou at gcc dot gnu dot org 2008-11-30 19:23 -------
Subject: Bug 38287
Author: ebotcazou
Date: Sun Nov 30 19:22:40 2008
New Revision: 142297
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142297
Log:
PR target/38287
* config/sparc/sparc.md (divsi3 expander): Remove constraints.
(divsi3_sp32): Add new alternative with 'K' for operand #2.
(cmp_sdiv_cc_set): Factor common string.
(udivsi3_sp32): Add new alternative with 'K' for operand #2.
Add TARGET_V9 case.
(cmp_udiv_cc_set): Factor common string.
Added:
branches/gcc-4_2-branch/gcc/testsuite/g++.dg/opt/reload3.C
Modified:
branches/gcc-4_2-branch/gcc/ChangeLog
branches/gcc-4_2-branch/gcc/config/sparc/sparc.md
branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38287
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/38287] [4.1/4.2/4.3 regression] segfault at -O2 -fPIC -mcpu=v8
2008-11-27 13:06 [Bug target/38287] New: wrong-code with -O2 -fPIC on sparc-linux-gnu debian-gcc at lists dot debian dot org
` (4 preceding siblings ...)
2008-11-30 19:24 ` ebotcazou at gcc dot gnu dot org
@ 2008-11-30 19:25 ` ebotcazou at gcc dot gnu dot org
2008-11-30 19:29 ` ebotcazou at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2008-11-30 19:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from ebotcazou at gcc dot gnu dot org 2008-11-30 19:24 -------
Subject: Bug 38287
Author: ebotcazou
Date: Sun Nov 30 19:23:38 2008
New Revision: 142298
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142298
Log:
PR target/38287
* config/sparc/sparc.md (divsi3 expander): Remove constraints.
(divsi3_sp32): Add new alternative with 'K' for operand #2.
(cmp_sdiv_cc_set): Factor common string.
(udivsi3_sp32): Add new alternative with 'K' for operand #2.
Add TARGET_V9 case.
(cmp_udiv_cc_set): Factor common string.
Modified:
branches/gcc-4_1-branch/gcc/ChangeLog
branches/gcc-4_1-branch/gcc/config/sparc/sparc.md
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38287
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/38287] [4.1/4.2/4.3 regression] segfault at -O2 -fPIC -mcpu=v8
2008-11-27 13:06 [Bug target/38287] New: wrong-code with -O2 -fPIC on sparc-linux-gnu debian-gcc at lists dot debian dot org
` (5 preceding siblings ...)
2008-11-30 19:25 ` ebotcazou at gcc dot gnu dot org
@ 2008-11-30 19:29 ` ebotcazou at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2008-11-30 19:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from ebotcazou at gcc dot gnu dot org 2008-11-30 19:27 -------
Thanks for the reduced testcase.
--
ebotcazou at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
URL| |http://gcc.gnu.org/ml/gcc-
| |patches/2008-
| |11/msg01526.html
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.1.3
Version|4.3.3 |4.1.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38287
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-11-30 19:29 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-27 13:06 [Bug target/38287] New: wrong-code with -O2 -fPIC on sparc-linux-gnu debian-gcc at lists dot debian dot org
2008-11-27 21:15 ` [Bug target/38287] [4.1/4.2/4.3 regression] segfault at -O2 -fPIC -mcpu=v8 ebotcazou at gcc dot gnu dot org
2008-11-27 21:21 ` ebotcazou at gcc dot gnu dot org
2008-11-30 19:21 ` ebotcazou at gcc dot gnu dot org
2008-11-30 19:23 ` ebotcazou at gcc dot gnu dot org
2008-11-30 19:24 ` ebotcazou at gcc dot gnu dot org
2008-11-30 19:25 ` ebotcazou at gcc dot gnu dot org
2008-11-30 19:29 ` ebotcazou 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).