Bug 63745 - [4.9/5 Regression] mythtv build failure due to aggressive speculative devirtualization
Summary: [4.9/5 Regression] mythtv build failure due to aggressive speculative devirtu...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: ipa (show other bugs)
Version: 4.9.3
: P3 normal
Target Milestone: 4.9.3
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2014-11-05 08:53 UTC by Markus Trippelsdorf
Modified: 2014-11-05 14:14 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
unreduced testcase (309.10 KB, application/x-bzip)
2014-11-05 08:54 UTC, Markus Trippelsdorf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2014-11-05 08:53:39 UTC
With the attached unreduced testcase I get:

markus@x4 /tmp % g++ -flto -O2 foo.ii 2>&1 | grep "VideoBuffers::StartDisplayingFrame"
markus@x4 /tmp % g++ -fno-devirtualize-speculatively  -O2 foo.ii 2>&1 | grep "VideoBuffers::StartDisplayingFrame"
markus@x4 /tmp % g++ -O2 foo.ii 2>&1 | grep "VideoBuffers::StartDisplayingFrame"
/tmp/ccEenHoO.o:main.cpp:function VideoOutput::StartDisplayingFrame(): error: undefined reference to 'VideoBuffers::StartDisplayingFrame()'
/tmp/ccEenHoO.o:main.cpp:function VideoPerformanceTest::Test(): error: undefined reference to 'VideoBuffers::StartDisplayingFrame()'

Creduce came up with the following (invalid) testcase:

 % cat main.ii
struct VideoBuffers
{
  void StartDisplayingFrame ();
};
struct B
{
  VideoBuffers vbuffers;
  virtual void
  StartDisplay ()
  {
    vbuffers.StartDisplayingFrame ();
  }
};
struct VideoPerformanceTest
{
  B *Test_vo;
  void
  Test ()
  {
    while (1)
      Test_vo->StartDisplay ();
  }
};

 % g++ -fno-devirtualize-speculatively -O2 -Wl,--no-undefined main.ii
 % g++ -flto -O2 -Wl,--no-undefined main.ii
 % g++ -O2 -Wl,--no-undefined main.ii
/tmp/ccTlyhda.o:main.ii:function B::StartDisplay(): error: undefined reference to 'VideoBuffers::StartDisplayingFrame()'
/tmp/ccTlyhda.o:main.ii:function main: error: undefined reference to 'VideoBuffers::StartDisplayingFrame()'
Comment 1 Markus Trippelsdorf 2014-11-05 08:54:01 UTC
Created attachment 33888 [details]
unreduced testcase
Comment 2 Markus Trippelsdorf 2014-11-05 09:03:13 UTC
Sorry reduced testcase was cut off. Here it is in its full glory:

struct VideoBuffers
{
  void StartDisplayingFrame ();
};
struct B
{
  VideoBuffers vbuffers;
  virtual void
  StartDisplay ()
  {
    vbuffers.StartDisplayingFrame ();
  }
};
struct VideoPerformanceTest
{
  B *Test_vo;
  void
  Test ()
  {
    while (1)
      Test_vo->StartDisplay ();
  }
};

VideoPerformanceTest a;
int
main () { a.Test (); }
Comment 3 Markus Trippelsdorf 2014-11-05 09:48:36 UTC
And here's a hopefully valid testcase:

markus@x4 tmp % cat main.ii

struct VideoBuffers
{
  void StartDisplayingFrame ();
};
struct B
{
  VideoBuffers vbuffers;
  virtual void
  StartDisplay ()
  {
    vbuffers.StartDisplayingFrame ();
  }
};
struct VideoPerformanceTest
{
  B *Test_vo;
  void
  Test ()
  {
    if (!Test_vo)
      return;
    while (1)
      Test_vo->StartDisplay ();
  }
};

VideoPerformanceTest a;
int
main () { a.Test (); }
Comment 4 Jan Hubicka 2014-11-05 13:38:45 UTC
> struct VideoBuffers
> {
>   void StartDisplayingFrame ();
> };
> struct B
> {
>   VideoBuffers vbuffers;
>   virtual void
>   StartDisplay ()
>   {
>     vbuffers.StartDisplayingFrame ();
>   }
So we devirtualize to StartDisplay but that leads to linker failure because
StartDisplayingFrame is not linked with the object file.

I think this is similar to some earlier testcases we run across in libreoffice
and we managed to declare it invalid - if you provide inline function body you
need to link the unit with symbols it uses.

Honza
Comment 5 Markus Trippelsdorf 2014-11-05 14:14:53 UTC
(In reply to Jan Hubicka from comment #4)
> > struct VideoBuffers
> > {
> >   void StartDisplayingFrame ();
> > };
> > struct B
> > {
> >   VideoBuffers vbuffers;
> >   virtual void
> >   StartDisplay ()
> >   {
> >     vbuffers.StartDisplayingFrame ();
> >   }
> So we devirtualize to StartDisplay but that leads to linker failure because
> StartDisplayingFrame is not linked with the object file.
> 
> I think this is similar to some earlier testcases we run across in
> libreoffice
> and we managed to declare it invalid - if you provide inline function body
> you
> need to link the unit with symbols it uses.

OK. That was my fist reaction, too. 
But it is irritating that it succeeds with -flto.