public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/66868] New: [5/6 Regression] wrong code generated with -O3 (dead code removal?)
@ 2015-07-14 12:06 doko at gcc dot gnu.org
  2015-07-14 12:25 ` [Bug tree-optimization/66868] " trippels at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: doko at gcc dot gnu.org @ 2015-07-14 12:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868

            Bug ID: 66868
           Summary: [5/6 Regression] wrong code generated with -O3 (dead
                    code removal?)
           Product: gcc
           Version: 5.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: doko at gcc dot gnu.org
  Target Milestone: ---

Created attachment 35975
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35975&action=edit
preprocessed source

[forwarded from https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1473674]

seen in the apt package manager, when built with -O3. Works with -O2 or -O3
-fno-inline-functions -finline-small-functions, on at least x86_64 and
powerpc64le. The test CDROMTest.FindPackages from the apt testsuite then fails.

built with g++ -c -g -O3 -fPIE -fstack-protector-strong -fPIC 

upstream writes:

There is a Cdrom wrapper:
"""
class Cdrom : public pkgCdrom {
   public:
      bool FindPackages(std::string const &CD,
     std::vector<std::string> &List,
     std::vector<std::string> &SList,
     std::vector<std::string> &SigList,
     std::vector<std::string> &TransList,
     std::string &InfoDir) {
  std::string const startdir = SafeGetCWD();
  EXPECT_FALSE(startdir.empty());
  bool const result = pkgCdrom::FindPackages(CD, List, SList, SigList,
TransList, InfoDir, NULL, 0);
...
}
"""

and a unittest that calls it:
"""
TEST(CDROMTest,FindPackages)
{
   Cdrom cd;
  std::string InfoDir;
  EXPECT_TRUE(cd.FindPackages(path, Packages, Sources, Signatur, Translation,
InfoDir));
...
  EXPECT_EQ(path + "/.disk/", InfoDir);
}
"""
The actual code for this is apt-pkg/cdrom.cc:
"""
bool pkgCdrom::FindPackages(string CD,
       vector<string> &List,
       vector<string> &SList,
       vector<string> &SigList,
       vector<string> &TransList,
       string &InfoDir, pkgCdromStatus *log,
       unsigned int Depth)
{
...
   if (DirectoryExists(".disk") == true)
   {
      if (InfoDir.empty() == true)
  InfoDir = CD + ".disk/";
   }
...
"""

So I suspect that the optimizer gets confused that InfoDir is a reference or it
gets confused because InfoDir is not used in FindPackages anymore and it
assumes its dead code.

I tried to create a simplified testcase but failed so far. Whats interessting
is that if I add a std::cerr << "debug" line into cdrom.cc lines (or even a "CD
= CD"):
"""
   if (DirectoryExists(".disk") == true)
   {
      if (InfoDir.empty() == true) {
std::cerr << "debug" << std::endl;
  InfoDir = CD + ".disk/";
}
   }
"""
it works (which indicates dead-code elimination to me).


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

* [Bug tree-optimization/66868] [5/6 Regression] wrong code generated with -O3 (dead code removal?)
  2015-07-14 12:06 [Bug tree-optimization/66868] New: [5/6 Regression] wrong code generated with -O3 (dead code removal?) doko at gcc dot gnu.org
@ 2015-07-14 12:25 ` trippels at gcc dot gnu.org
  2015-07-14 12:53 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-07-14 12:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |trippels at gcc dot gnu.org

--- Comment #1 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
Have you tried to build with -fsanitize=undefined?


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

* [Bug tree-optimization/66868] [5/6 Regression] wrong code generated with -O3 (dead code removal?)
  2015-07-14 12:06 [Bug tree-optimization/66868] New: [5/6 Regression] wrong code generated with -O3 (dead code removal?) doko at gcc dot gnu.org
  2015-07-14 12:25 ` [Bug tree-optimization/66868] " trippels at gcc dot gnu.org
@ 2015-07-14 12:53 ` rguenth at gcc dot gnu.org
  2015-07-14 13:02 ` doko at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-07-14 12:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |5.2


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

* [Bug tree-optimization/66868] [5/6 Regression] wrong code generated with -O3 (dead code removal?)
  2015-07-14 12:06 [Bug tree-optimization/66868] New: [5/6 Regression] wrong code generated with -O3 (dead code removal?) doko at gcc dot gnu.org
  2015-07-14 12:25 ` [Bug tree-optimization/66868] " trippels at gcc dot gnu.org
  2015-07-14 12:53 ` rguenth at gcc dot gnu.org
@ 2015-07-14 13:02 ` doko at gcc dot gnu.org
  2015-07-16  9:15 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: doko at gcc dot gnu.org @ 2015-07-14 13:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868

--- Comment #2 from Matthias Klose <doko at gcc dot gnu.org> ---
the testsuite passes with -fsanitize=undefined (no additional output) and both
-fsanitize=undefined -fsanitize-undefined-trap-on-error doesn't abort either.


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

* [Bug tree-optimization/66868] [5/6 Regression] wrong code generated with -O3 (dead code removal?)
  2015-07-14 12:06 [Bug tree-optimization/66868] New: [5/6 Regression] wrong code generated with -O3 (dead code removal?) doko at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2015-07-14 13:02 ` doko at gcc dot gnu.org
@ 2015-07-16  9:15 ` rguenth at gcc dot gnu.org
  2015-07-21 22:10 ` wschmidt at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-07-16  9:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|5.2                         |5.3

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 5.2 is being released, adjusting target milestone to 5.3.


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

* [Bug tree-optimization/66868] [5/6 Regression] wrong code generated with -O3 (dead code removal?)
  2015-07-14 12:06 [Bug tree-optimization/66868] New: [5/6 Regression] wrong code generated with -O3 (dead code removal?) doko at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2015-07-16  9:15 ` rguenth at gcc dot gnu.org
@ 2015-07-21 22:10 ` wschmidt at gcc dot gnu.org
  2015-07-22 13:54 ` wschmidt at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2015-07-21 22:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868

--- Comment #4 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
Hm.  I compiled it as stated and I see a bunch of code that appears to be
storing the ".disk/" string.  So it doesn't look like dead code elimination. 
Perhaps a branch is short circuiting this, or the address of where to store it
has been corrupted.

I don't have any way to confirm that I'm reproducing the problem when I
compile, from what's given here.  It might be helpful to provide the full test
case without ellipses, and the failure message given by the test.


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

* [Bug tree-optimization/66868] [5/6 Regression] wrong code generated with -O3 (dead code removal?)
  2015-07-14 12:06 [Bug tree-optimization/66868] New: [5/6 Regression] wrong code generated with -O3 (dead code removal?) doko at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2015-07-21 22:10 ` wschmidt at gcc dot gnu.org
@ 2015-07-22 13:54 ` wschmidt at gcc dot gnu.org
  2015-07-22 13:55 ` wschmidt at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2015-07-22 13:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868

--- Comment #5 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
Using current trunk, I compared the 193t.optimized dumps for the original
cdrom.ii attachment and for the same attachment modified to add the debug
output statement from the end of comment 2.  Other than the added statements
for the debug output, there don't appear to be any changes.  This bug is marked
as 5.1/6 regression -- are you certain that it regresses on trunk?  Will check
5.1 the same way.


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

* [Bug tree-optimization/66868] [5/6 Regression] wrong code generated with -O3 (dead code removal?)
  2015-07-14 12:06 [Bug tree-optimization/66868] New: [5/6 Regression] wrong code generated with -O3 (dead code removal?) doko at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2015-07-22 13:54 ` wschmidt at gcc dot gnu.org
@ 2015-07-22 13:55 ` wschmidt at gcc dot gnu.org
  2015-07-22 14:07 ` wschmidt at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2015-07-22 13:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868

--- Comment #6 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
Sorry, not from comment 2 on this bugzilla; comment 2 from the launchpad bug.


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

* [Bug tree-optimization/66868] [5/6 Regression] wrong code generated with -O3 (dead code removal?)
  2015-07-14 12:06 [Bug tree-optimization/66868] New: [5/6 Regression] wrong code generated with -O3 (dead code removal?) doko at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2015-07-22 13:55 ` wschmidt at gcc dot gnu.org
@ 2015-07-22 14:07 ` wschmidt at gcc dot gnu.org
  2015-07-22 14:28 ` wschmidt at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2015-07-22 14:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868

--- Comment #7 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
I tried the same thing with a snapshot of the 5 branch I had lying around: 
r225783 from 2015-07-14.  I also don't see any differences in the output from
the middle end, as I would expect since this bug has shown up on multiple
targets.  So maybe this has been fixed recently?  Let me see if I can find an
older snapshot.


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

* [Bug tree-optimization/66868] [5/6 Regression] wrong code generated with -O3 (dead code removal?)
  2015-07-14 12:06 [Bug tree-optimization/66868] New: [5/6 Regression] wrong code generated with -O3 (dead code removal?) doko at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2015-07-22 14:07 ` wschmidt at gcc dot gnu.org
@ 2015-07-22 14:28 ` wschmidt at gcc dot gnu.org
  2015-07-24 19:58 ` doko at gcc dot gnu.org
  2015-07-27 17:05 ` doko at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2015-07-22 14:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868

--- Comment #8 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
Same experiment with r222218 from 2015-04-18.  Same results.

At this point I can't reproduce anything from the information given.  Do you
have any local modifications that could be causing this?


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

* [Bug tree-optimization/66868] [5/6 Regression] wrong code generated with -O3 (dead code removal?)
  2015-07-14 12:06 [Bug tree-optimization/66868] New: [5/6 Regression] wrong code generated with -O3 (dead code removal?) doko at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2015-07-22 14:28 ` wschmidt at gcc dot gnu.org
@ 2015-07-24 19:58 ` doko at gcc dot gnu.org
  2015-07-27 17:05 ` doko at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: doko at gcc dot gnu.org @ 2015-07-24 19:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868

Matthias Klose <doko at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |powerpc64le-linux-gnu,
                   |                            |x86_64-linux-gnu
      Known to work|                            |6.0
      Known to fail|5.1.1, 6.0                  |5.2.0

--- Comment #9 from Matthias Klose <doko at gcc dot gnu.org> ---
this works ok with trunk r226068, still fails on the branch.

gcc is configured with
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-libquadmath --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-ppc64el/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-ppc64el
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-ppc64el
--with-arch-directory=ppc64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-secureplt --with-cpu=power7 --with-tune=power8
--disable-multilib --enable-multiarch --disable-werror --with-long-double-128
--enable-checking=release --build=powerpc64le-linux-gnu
--host=powerpc64le-linux-gnu --target=powerpc64le-linux-gnu


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

* [Bug tree-optimization/66868] [5/6 Regression] wrong code generated with -O3 (dead code removal?)
  2015-07-14 12:06 [Bug tree-optimization/66868] New: [5/6 Regression] wrong code generated with -O3 (dead code removal?) doko at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2015-07-24 19:58 ` doko at gcc dot gnu.org
@ 2015-07-27 17:05 ` doko at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: doko at gcc dot gnu.org @ 2015-07-27 17:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66868

Matthias Klose <doko at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |5.1.0

--- Comment #11 from Matthias Klose <doko at gcc dot gnu.org> ---
rechecked with a 5.1.0 release tarball, fails with -O3


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

end of thread, other threads:[~2015-07-27 17:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-14 12:06 [Bug tree-optimization/66868] New: [5/6 Regression] wrong code generated with -O3 (dead code removal?) doko at gcc dot gnu.org
2015-07-14 12:25 ` [Bug tree-optimization/66868] " trippels at gcc dot gnu.org
2015-07-14 12:53 ` rguenth at gcc dot gnu.org
2015-07-14 13:02 ` doko at gcc dot gnu.org
2015-07-16  9:15 ` rguenth at gcc dot gnu.org
2015-07-21 22:10 ` wschmidt at gcc dot gnu.org
2015-07-22 13:54 ` wschmidt at gcc dot gnu.org
2015-07-22 13:55 ` wschmidt at gcc dot gnu.org
2015-07-22 14:07 ` wschmidt at gcc dot gnu.org
2015-07-22 14:28 ` wschmidt at gcc dot gnu.org
2015-07-24 19:58 ` doko at gcc dot gnu.org
2015-07-27 17:05 ` doko at gcc dot gnu.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).