public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/11969] New: -foptimize-sibling-calls from -O2 creates bad code
@ 2003-08-18 16:23 grhoten at jtcsv dot com
  2003-08-18 16:36 ` [Bug optimization/11969] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: grhoten at jtcsv dot com @ 2003-08-18 16:23 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11969

           Summary: -foptimize-sibling-calls from -O2 creates bad code
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: grhoten at jtcsv dot com
                CC: gcc-bugs at gcc dot gnu dot org

The ICU (International Components for Unicode) project keeps on getting bug 
reports about how ICU won't build with the -O2 or -Os optimization flags. After 
many hours of debugging, I've been able to narrow the problem down.

I have narrowed it down to the -foptimize-sibling-calls option that is included 
with the -O2 and -Os flags. It causes one of our tools to generate an internal 
program error. It seems to affect only one file in ICU 
(icu/source/i18n/ucol_wgt.c). You can see a copy of the file here: 
http://oss.software.ibm.com/cvs/icu/~checkout~/icu/source/i18n/ucol_wgt.c?
only_with_tag=release-2-6

We know it fails with Red Hat Linux 8 and 9 on x86. Other people on Mac OS and 
Solaris have also reported the same problem. At least gcc 3.2, 3.2.2 and 3.3 
fail to properly optimize the code.

To get around this problem we use -O3. I think it includes the -Winline option, 
which seems to be the work around for now. If I declare all of the static 
functions as inline in ucol_wgt.c, the build problem will also disappear.

I'm not exactly sure what the exact problem is in the generated assembly code, 
but the -foptimize-sibling-calls option is the source of the problem. I'm just 
worried that this option causes something else to fail too, and we haven't run 
across is yet.

I know you guys don't like to download projects, but you can download the 
source code for testing from here: 
http://oss.software.ibm.com/icu/download/index.html

ICU 2.6 is known to have this problem, but other previous version are known to 
have it too, like ICU 2.2 and ICU 2.4.

BTW thanks for listing the optimization flags used in the gcc 3.3 
documentation. It helped a lot.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug optimization/11969] -foptimize-sibling-calls from -O2 creates bad code
  2003-08-18 16:23 [Bug optimization/11969] New: -foptimize-sibling-calls from -O2 creates bad code grhoten at jtcsv dot com
@ 2003-08-18 16:36 ` pinskia at gcc dot gnu dot org
  2003-08-18 17:28 ` grhoten at jtcsv dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-08-18 16:36 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11969


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal
             Status|UNCONFIRMED                 |WAITING
           Keywords|                            |wrong-code


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-08-18 16:36 -------
Is there a simple example which shows this problem like the the test in the source or is there do 
we have to find something else to test it with?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug optimization/11969] -foptimize-sibling-calls from -O2 creates bad code
  2003-08-18 16:23 [Bug optimization/11969] New: -foptimize-sibling-calls from -O2 creates bad code grhoten at jtcsv dot com
  2003-08-18 16:36 ` [Bug optimization/11969] " pinskia at gcc dot gnu dot org
@ 2003-08-18 17:28 ` grhoten at jtcsv dot com
  2003-08-18 18:10 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: grhoten at jtcsv dot com @ 2003-08-18 17:28 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11969



------- Additional Comments From grhoten at jtcsv dot com  2003-08-18 17:28 -------
I haven't been able to find a simplier example that reproduces this bug yet.

Though I have narrowed the problem down a bit further. If I just declare the 
function incWeight() as the following, the build error for ja.txt goes away. 
Maybe the other functions don't need to be inlined.

static U_INLINE uint32_t
incWeight(uint32_t weight, int32_t length, uint32_t maxByte) {



I just know that this code initializes several data structures incorrectly, and 
it causes our genrb build tool to fail. Specifically it fails during the build 
of ICU when this is run.

(Information from our bug reports)

On Solaris 
ICU_DATA=../data/out/build
LD_LIBRARY_PATH=../common:../i18n:../tools/toolutil:.
./layout:../extra/ustdio:../tools/ctestfw:../data/out:../data:../stubdata/:$LD_L
IBRARY_PATH  ../tools/genrb/genrb -k -q -p icudt24l -s ../data/locales -d
../data/out/build ja.txt
../data/locales/ja.txt:15: parse error. Stopped parsing with
U_INVALID_FORMAT_ERROR
couldn't parse the file ja.txt. Error:U_INVALID_FORMAT_ERROR
make[1]: *** [../data/out/build/icudt24l_ja.res] Error 3
make[1]: Leaving directory `/export/home/sys/test/icu/source/data'
make: *** [all-recursive] Error 2

On Linux
ICU_DATA=../data/out/build
LD_LIBRARY_PATH=../common:../i18n:../tools/toolutil:../layout:../layoutex:../ext
ra/ustdio:../tools/ctestfw:../data/out:../data:../stubdata/:$LD_LIBRARY_PATH
 ../tools/genrb/genrb -k -q -p icudt26l -s ../data/locales -d ../data/out/build
ja.txt
../data/locales/ja.txt:15: parse error. Stopped parsing with
U_INVALID_FORMAT_ERROR
couldn't parse the file ja.txt. Error:U_INVALID_FORMAT_ERROR
make[1]: *** [../data/out/build/icudt26l_ja.res] Fehler 3
make[1]: Leaving directory `/workspace/software/libraries/icu/source/data'


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug optimization/11969] -foptimize-sibling-calls from -O2 creates bad code
  2003-08-18 16:23 [Bug optimization/11969] New: -foptimize-sibling-calls from -O2 creates bad code grhoten at jtcsv dot com
  2003-08-18 16:36 ` [Bug optimization/11969] " pinskia at gcc dot gnu dot org
  2003-08-18 17:28 ` grhoten at jtcsv dot com
@ 2003-08-18 18:10 ` pinskia at gcc dot gnu dot org
  2003-08-18 18:10 ` pinskia 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 @ 2003-08-18 18:10 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11969


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-08-18 18:10 -------
Feedback recieved so marking as invalid to mark ...


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug optimization/11969] -foptimize-sibling-calls from -O2 creates bad code
  2003-08-18 16:23 [Bug optimization/11969] New: -foptimize-sibling-calls from -O2 creates bad code grhoten at jtcsv dot com
                   ` (2 preceding siblings ...)
  2003-08-18 18:10 ` pinskia at gcc dot gnu dot org
@ 2003-08-18 18:10 ` pinskia at gcc dot gnu dot org
  2003-09-04 10:09 ` steven at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-08-18 18:10 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11969


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-08-18 18:10 -------
unconfirmed.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug optimization/11969] -foptimize-sibling-calls from -O2 creates bad code
  2003-08-18 16:23 [Bug optimization/11969] New: -foptimize-sibling-calls from -O2 creates bad code grhoten at jtcsv dot com
                   ` (3 preceding siblings ...)
  2003-08-18 18:10 ` pinskia at gcc dot gnu dot org
@ 2003-09-04 10:09 ` steven at gcc dot gnu dot org
  2003-09-06 15:52 ` steven at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: steven at gcc dot gnu dot org @ 2003-09-04 10:09 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11969


steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |steven at gcc dot gnu dot
                   |                            |org


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug optimization/11969] -foptimize-sibling-calls from -O2 creates bad code
  2003-08-18 16:23 [Bug optimization/11969] New: -foptimize-sibling-calls from -O2 creates bad code grhoten at jtcsv dot com
                   ` (4 preceding siblings ...)
  2003-09-04 10:09 ` steven at gcc dot gnu dot org
@ 2003-09-06 15:52 ` steven at gcc dot gnu dot org
  2003-09-13 11:37 ` steven at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: steven at gcc dot gnu dot org @ 2003-09-06 15:52 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11969



------- Additional Comments From steven at gcc dot gnu dot org  2003-09-06 15:52 -------
Here are all the replacements that replace_call_placeholder
does with "-O2 -fno-unit-at-a-time":

sibcall_use_sibcall:
getWeightByte -> getWeightTrail
incWeight -> setWeightByte
                                                                                
sibcall_use_normal:
incWeight -> getWeightByte
incWeight -> setWeightByte
lengthenRange -> setWeightTrail
lengthenRange -> setWeightTrail
getWeightRanges -> lengthOfWeight
getWeightRanges -> lengthOfWeight
getWeightRanges -> truncateWeight
getWeightRanges -> memset
getWeightRanges -> memset
getWeightRanges -> getWeightTrail
getWeightRanges -> getWeightTrail
getWeightRanges -> setWeightTrail
getWeightRanges -> truncateWeight
getWeightRanges -> incWeightTrail
getWeightRanges -> getWeightTrail
getWeightRanges -> setWeightTrail
getWeightRanges -> decWeightTrail
getWeightRanges -> truncateWeight
getWeightRanges -> decWeightTrail
getWeightRanges -> incWeight
getWeightRanges -> getWeightTrail
getWeightRanges -> getWeightTrail
getWeightRanges -> getWeightByte
getWeightRanges -> getWeightByte
ucol_allocWeights_2_6 -> getWeightRanges
ucol_allocWeights_2_6 -> lengthenRange
ucol_allocWeights_2_6 -> getWeightByte
ucol_allocWeights_2_6 -> setWeightByte
ucol_allocWeights_2_6 -> incWeight
ucol_allocWeights_2_6 -> truncateWeight
ucol_allocWeights_2_6 -> incWeight
ucol_allocWeights_2_6 -> lengthenRange
ucol_allocWeights_2_6 -> lengthenRange
ucol_allocWeights_2_6 -> qsort

So there are only two sibcalls, and all the other "potentials" are replaced with
normal calls.

If this problem is real, then the sibcall incWeight -> setWeightByte may be the
cause of it.  But the RTL for this looks quite OK AFAICT... :-\


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug optimization/11969] -foptimize-sibling-calls from -O2 creates bad code
  2003-08-18 16:23 [Bug optimization/11969] New: -foptimize-sibling-calls from -O2 creates bad code grhoten at jtcsv dot com
                   ` (5 preceding siblings ...)
  2003-09-06 15:52 ` steven at gcc dot gnu dot org
@ 2003-09-13 11:37 ` steven at gcc dot gnu dot org
  2003-11-09  3:19 ` pinskia at gcc dot gnu dot org
  2004-01-17 23:39 ` dhazeghi at yahoo dot com
  8 siblings, 0 replies; 10+ messages in thread
From: steven at gcc dot gnu dot org @ 2003-09-13 11:37 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11969



------- Additional Comments From steven at gcc dot gnu dot org  2003-09-13 09:15 -------
Maybe this patch fixes it for you:
http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00736.html

But of course there's no way for us to tell without a test case.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug optimization/11969] -foptimize-sibling-calls from -O2 creates bad code
  2003-08-18 16:23 [Bug optimization/11969] New: -foptimize-sibling-calls from -O2 creates bad code grhoten at jtcsv dot com
                   ` (6 preceding siblings ...)
  2003-09-13 11:37 ` steven at gcc dot gnu dot org
@ 2003-11-09  3:19 ` pinskia at gcc dot gnu dot org
  2004-01-17 23:39 ` dhazeghi at yahoo dot com
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-11-09  3:19 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4                         |---


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11969


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug optimization/11969] -foptimize-sibling-calls from -O2 creates bad code
  2003-08-18 16:23 [Bug optimization/11969] New: -foptimize-sibling-calls from -O2 creates bad code grhoten at jtcsv dot com
                   ` (7 preceding siblings ...)
  2003-11-09  3:19 ` pinskia at gcc dot gnu dot org
@ 2004-01-17 23:39 ` dhazeghi at yahoo dot com
  8 siblings, 0 replies; 10+ messages in thread
From: dhazeghi at yahoo dot com @ 2004-01-17 23:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dhazeghi at yahoo dot com  2004-01-17 23:39 -------
No testcase, and no feedback on the patch Steven mentioned. If you get a chance to test this again 
(preferably with gcc 3.3.2 or a snapshot), we can reopen this.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11969


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-01-17 23:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-18 16:23 [Bug optimization/11969] New: -foptimize-sibling-calls from -O2 creates bad code grhoten at jtcsv dot com
2003-08-18 16:36 ` [Bug optimization/11969] " pinskia at gcc dot gnu dot org
2003-08-18 17:28 ` grhoten at jtcsv dot com
2003-08-18 18:10 ` pinskia at gcc dot gnu dot org
2003-08-18 18:10 ` pinskia at gcc dot gnu dot org
2003-09-04 10:09 ` steven at gcc dot gnu dot org
2003-09-06 15:52 ` steven at gcc dot gnu dot org
2003-09-13 11:37 ` steven at gcc dot gnu dot org
2003-11-09  3:19 ` pinskia at gcc dot gnu dot org
2004-01-17 23:39 ` dhazeghi at yahoo dot com

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).