Bug 15517 - -O2 and higher removes some static const
Summary: -O2 and higher removes some static const
Status: RESOLVED DUPLICATE of bug 14911
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.3.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-18 13:50 UTC by Till Dörges
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i586-suse-linux
Target: i586-suse-linux
Build: (?) i586-suse-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments
preprocessed file (31.61 KB, application/octet-stream)
2004-05-18 13:53 UTC, Till Dörges
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Till Dörges 2004-05-18 13:50:52 UTC
The problem arises with ffmpeg/libavcodec (no version known) included in
transcode 0.6.11 (http://www.theorie.physik.uni-goettingen.de/~ostreich/transcode/)


# Cmdline triggering the bug (sources configured with a plain ./configure)

/tmp/gcc/transcode-0.6.11/ffmpeg/libavcodec>  gcc -DHAVE_CONFIG_H -I../.. -I.
-I../.. -I. -I../../    -O2 -g -Wall -ffast-math  -DARCH_X86 -DHAVE_MMX
-DHAVE_AV_CONFIG_H -D_GNU_SOURCE --include=../av_config.h -g -O3 -O3
-fomit-frame-pointer -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -MT dsputil_mmx.o -MD -MP -MF ".deps/dsputil_mmx.Tpo"  -c
-o dsputil_mmx.o `test -f 'i386/dsputil_mmx.c' || echo './'`i386/dsputil_mmx.c;

# Compiler output
i386/dsputil_mmx_rnd.h:362: warning: `avg_no_rnd_pixels8_l2_mmx' defined but not
used
i386/dsputil_mmx_rnd.h:409: warning: `avg_no_rnd_pixels16_l2_mmx' defined but
not used
i386/dsputil_mmx_avg.h:57: warning: `put_pixels8_l2_3dnow' defined but not used
i386/dsputil_mmx_avg.h:129: warning: `put_pixels16_l2_3dnow' defined but not used
i386/dsputil_mmx_avg.h:57: warning: `put_pixels8_l2_mmx2' defined but not used
i386/dsputil_mmx_avg.h:129: warning: `put_pixels16_l2_mmx2' defined but not used


# That's the code
/tmp/gcc/transcode-0.6.11/ffmpeg/libavcodec> grep ff_pw_.. i386/dsputil_mmx.c |
grep static
static const uint64_t ff_pw_20 __attribute__ ((aligned(8))) = 0x0014001400140014ULL;
static const uint64_t ff_pw_3  __attribute__ ((aligned(8))) = 0x0003000300030003ULL;
static const uint64_t ff_pw_16 __attribute__ ((aligned(8))) = 0x0010001000100010ULL;
static const uint64_t ff_pw_15 __attribute__ ((aligned(8))) = 0x000F000F000F000FULL;


# That's what's missing
/tmp/gcc/transcode-0.6.11/ffmpeg/libavcodec> nm dsputil_mmx.o | grep ff_pw
00000008 r ff_pw_15
00000000 r ff_pw_16
         U ff_pw_20
         U ff_pw_3


Resolution:
-----------
Replace -O2 and -O3 by -O1


Versions etc.:
--------------
# gcc -v

Reading specs from /usr/lib/gcc-lib/i586-suse-linux/3.3.3/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man
--enable-languages=c,c++,f77,objc,java,ada --disable-checking --libdir=/usr/lib
--enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib
--with-system-zlib --enable-shared --enable-__cxa_atexit i586-suse-linux
Thread model: posix
gcc version 3.3.3 (SuSE Linux)

# Distribution: SuSE 9.1

# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 2
model name      : Mobile Intel(R) Pentium(R) 4 - M CPU 2.00GHz
stepping        : 7
cpu MHz         : 1998.497
cache size      : 512 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat
pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid
bogomips        : 3956.73
Comment 1 Till Dörges 2004-05-18 13:53:55 UTC
Created attachment 6329 [details]
preprocessed file

Produced by the same commandline as in the report with '-save-temps' added
Comment 2 Falk Hueffner 2004-05-18 13:56:16 UTC
The compiler is free to remove unused statics. Use __attribute__((used)), as
newer ffmpeg versions already do.
Comment 3 Andrew Pinski 2004-05-18 13:56:29 UTC
This is a dup of bug 14911, well it looks like SUSE turns on -funit-at-a-time at -O2 for their 3.3.3, so 
using the same method as mentioned in the other bug except change the "__GNUC_MINOR__ >=4" to 
be "__GNUC_MINOR__ >= 3" and it will work.

*** This bug has been marked as a duplicate of 14911 ***

*** This bug has been marked as a duplicate of 14911 ***
Comment 4 Till Dörges 2004-05-18 14:15:25 UTC
Subject: Re:  -O2 and higher removes some static const

Hi,

pinskia at gcc dot gnu dot org wrote:

> *** This bug has been marked as a duplicate of 14911 ***

Thanks for the *extremely* quick response. :-) Sorry for the duplicate,
but I didn't find anything with my previous bugzilla queries.

Bye -- Till