public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55319] New: Using -fwhole-program inhibits optimization
@ 2012-11-14  4:48 m101010a at gmail dot com
  2012-11-18 14:01 ` [Bug c++/55319] " paolo.carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: m101010a at gmail dot com @ 2012-11-14  4:48 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55319
           Summary: Using -fwhole-program inhibits optimization
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: m101010a@gmail.com


Created attachment 28681
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28681
The preprocessed source

The attached code is a template-based brainfuck interpreter, and the brainfuck
code in it prints "Hello world!".  When the attached code is compiled with "g++
-std=c++11 -O2 bf.ii", it produces a series of calls to _IO_putc which directly
print "Hello World!".  However, when compiled with "g++ -std=c++11 -O2
-fwhole-program bf.ii", it produces a more direct and less optimized
interpretation of the associated brainfuck.

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/src/gcc-4.7.2/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--enable-libstdcxx-time --enable-gnu-unique-object --enable-linker-build-id
--with-ppl --enable-cloog-backend=isl --disable-ppl-version-check
--disable-cloog-version-check --enable-lto --enable-gold --enable-ld=default
--enable-plugin --with-plugin-ld=ld.gold --with-linker-hash-style=gnu
--enable-multilib --disable-libssp --disable-build-with-cxx
--disable-build-poststage1-with-cxx --enable-checking=release
Thread model: posix
gcc version 4.7.2 (GCC)


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

* [Bug c++/55319] Using -fwhole-program inhibits optimization
  2012-11-14  4:48 [Bug c++/55319] New: Using -fwhole-program inhibits optimization m101010a at gmail dot com
@ 2012-11-18 14:01 ` paolo.carlini at oracle dot com
  2012-11-18 22:13 ` m101010a at gmail dot com
  2012-11-19  0:16 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-18 14:01 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-18 14:00:37 UTC ---
In order to quickly make progress on the issue, I recommend filing something
much smaller and less obfuscated. Also, not using internal stdio interfaces
(anyway, very likely i/o itself isn't essential and an assert or an abort would
do)


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

* [Bug c++/55319] Using -fwhole-program inhibits optimization
  2012-11-14  4:48 [Bug c++/55319] New: Using -fwhole-program inhibits optimization m101010a at gmail dot com
  2012-11-18 14:01 ` [Bug c++/55319] " paolo.carlini at oracle dot com
@ 2012-11-18 22:13 ` m101010a at gmail dot com
  2012-11-19  0:16 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: m101010a at gmail dot com @ 2012-11-18 22:13 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from m101010a at gmail dot com 2012-11-18 22:13:23 UTC ---
Actually, it does depend on IO; the optimizations aren't performed in either
case if I declare but don't define putchar, and if do something simple like
assigning to a volatile int in putchar then the optimizations are performed in
both cases.  If I assert(false) in putchar, gcc optimizes the fwhole-program
version to a failed assert, but doesn't without fwhole-program, which is the
opposite of what it does with IO.


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

* [Bug c++/55319] Using -fwhole-program inhibits optimization
  2012-11-14  4:48 [Bug c++/55319] New: Using -fwhole-program inhibits optimization m101010a at gmail dot com
  2012-11-18 14:01 ` [Bug c++/55319] " paolo.carlini at oracle dot com
  2012-11-18 22:13 ` m101010a at gmail dot com
@ 2012-11-19  0:16 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-19  0:16 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-19 00:16:03 UTC ---
If it does depend on I/O please trim down all the rest, and, if at all
possible, please use standard functions for that.


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

end of thread, other threads:[~2012-11-19  0:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-14  4:48 [Bug c++/55319] New: Using -fwhole-program inhibits optimization m101010a at gmail dot com
2012-11-18 14:01 ` [Bug c++/55319] " paolo.carlini at oracle dot com
2012-11-18 22:13 ` m101010a at gmail dot com
2012-11-19  0:16 ` paolo.carlini at oracle 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).