[PATCH 2/4] New data structure for cgraph_summary introduced.

Trevor Saunders tsaunders@mozilla.com
Thu Nov 13 23:15:00 GMT 2014


On Thu, Nov 13, 2014 at 11:23:31PM +0100, Markus Trippelsdorf wrote:
> On 2014.11.14 at 01:19 -0500, Trevor Saunders wrote:
> > On Thu, Nov 13, 2014 at 03:48:34PM +0100, Markus Trippelsdorf wrote:
> > > On 2014.11.13 at 15:11 +0100, mliska wrote:
> > > 
> > > > +  /* Destructor.  */
> > > > +  virtual ~cgraph_summary ()
> > > > +  {
> > > > +    destroy ();
> > > > +  }
> > > 
> > > From https://gcc.gnu.org/wiki/CppConventions:
> > > 
> > > Constructors and destructors are often much larger than programmers
> > > expect. Prefer non-inline versions unless you have evidence that the
> > > inline version is needed.
> > 
> > I never really agreed with that, and we don't really follow it.  However
> > it really doesn't matter in this case since its virtual.
> 
> It doesn't really matter if the destructor is virtual or not, because the same
> bloat can happen.
> 
> Consider a trivial example that I've found on the web and compare the assembly
> output with "virtual ~A ()" defined inline vs. out-of-line:

I do see different assembly, but with gcc 4.9.2-1 (Debian) and -O2 what
I get with the inline dtor looks much better than with the out of line
one.  So your example isn't very convincing, and if it did cause worse
code I'd probably call that a compiler bug.

Trev

> 
> #include <string>
> 
> using namespace std;
> 
> class A
> {
>   string name;
>   string address;
>   string telephone;
> 
> public:
>   A (){};
>   virtual void
>   function ()
>   {
>   }
>   virtual ~A () {}
> };
> 
> //A::~A (){};
> 
> class B : public A
> {
> public:
>   B (){};
>   void
>   function ()
>   {
>   }
>   ~B () {}
> };
> 
> void
> abc ()
> {
>   B b;
>   b.function ();
> }
> 
> int
> main ()
> {
>   B b;
>   b.function ();
>   abc ();
> }
> 
> -- 
> Markus



More information about the Gcc-patches mailing list