diff mbox

[C++] Enable constructor decloning by default

Message ID 20140518193231.GE1828@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka May 18, 2014, 7:32 p.m. UTC
Hi,
this patch enables -fdeclone-ctor-dtor by default: I believe it is up to the
optimizers to decide when the actual worker body should be inlined into the
thunks.

Bootstrapped/regtested x86_64-linux, OK?

Honza

	* c-family/c.opt: Enable declonning by default.
	* c-family/c-opts.c: Do not enable decloning for -Os.
	* doc/invoke.texi (-fdeclone-ctor-dtor): Update documentation.

Comments

Richard Biener May 19, 2014, 9:17 a.m. UTC | #1
On Sun, May 18, 2014 at 9:32 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> Hi,
> this patch enables -fdeclone-ctor-dtor by default: I believe it is up to the
> optimizers to decide when the actual worker body should be inlined into the
> thunks.
>
> Bootstrapped/regtested x86_64-linux, OK?

Please make sure to not enable it for -O0 and -Og at least.

Richard.

> Honza
>
>         * c-family/c.opt: Enable declonning by default.
>         * c-family/c-opts.c: Do not enable decloning for -Os.
>         * doc/invoke.texi (-fdeclone-ctor-dtor): Update documentation.
> Index: c-family/c.opt
> ===================================================================
> --- c-family/c.opt      (revision 210521)
> +++ c-family/c.opt      (working copy)
> @@ -904,7 +904,7 @@ C++ ObjC++ Var(flag_deduce_init_list) In
>  -fdeduce-init-list     enable deduction of std::initializer_list for a template type parameter from a brace-enclosed initializer-list
>
>  fdeclone-ctor-dtor
> -C++ ObjC++ Var(flag_declone_ctor_dtor) Init(-1)
> +C++ ObjC++ Var(flag_declone_ctor_dtor) Init(1)
>  Factor complex constructors and destructors to favor space over speed
>
>  fdefault-inline
> Index: c-family/c-opts.c
> ===================================================================
> --- c-family/c-opts.c   (revision 210521)
> +++ c-family/c-opts.c   (working copy)
> @@ -906,10 +906,6 @@ c_common_post_options (const char **pfil
>    if (warn_implicit_function_declaration == -1)
>      warn_implicit_function_declaration = flag_isoc99;
>
> -  /* Declone C++ 'structors if -Os.  */
> -  if (flag_declone_ctor_dtor == -1)
> -    flag_declone_ctor_dtor = optimize_size;
> -
>    if (cxx_dialect >= cxx11)
>      {
>        /* If we're allowing C++0x constructs, don't warn about C++98
> Index: doc/invoke.texi
> ===================================================================
> --- doc/invoke.texi     (revision 210521)
> +++ doc/invoke.texi     (working copy)
> @@ -7413,7 +7414,7 @@ clones, which means two copies of the fu
>  base and complete variants are changed to be thunks that call a common
>  implementation.
>
> -Enabled by @option{-Os}.
> +Enabled by default.
>
>  @item -fdelete-null-pointer-checks
>  @opindex fdelete-null-pointer-checks
Jan Hubicka May 19, 2014, 2:45 p.m. UTC | #2
> On Sun, May 18, 2014 at 9:32 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> > Hi,
> > this patch enables -fdeclone-ctor-dtor by default: I believe it is up to the
> > optimizers to decide when the actual worker body should be inlined into the
> > thunks.
> >
> > Bootstrapped/regtested x86_64-linux, OK?
> 
> Please make sure to not enable it for -O0 and -Og at least.

Hmm, I tought this thunk can be implemented without clobbering debug info - 
all we need is to arrange it to be abstract and not show in unwind info...

Honza
> 
> Richard.
> 
> > Honza
> >
> >         * c-family/c.opt: Enable declonning by default.
> >         * c-family/c-opts.c: Do not enable decloning for -Os.
> >         * doc/invoke.texi (-fdeclone-ctor-dtor): Update documentation.
> > Index: c-family/c.opt
> > ===================================================================
> > --- c-family/c.opt      (revision 210521)
> > +++ c-family/c.opt      (working copy)
> > @@ -904,7 +904,7 @@ C++ ObjC++ Var(flag_deduce_init_list) In
> >  -fdeduce-init-list     enable deduction of std::initializer_list for a template type parameter from a brace-enclosed initializer-list
> >
> >  fdeclone-ctor-dtor
> > -C++ ObjC++ Var(flag_declone_ctor_dtor) Init(-1)
> > +C++ ObjC++ Var(flag_declone_ctor_dtor) Init(1)
> >  Factor complex constructors and destructors to favor space over speed
> >
> >  fdefault-inline
> > Index: c-family/c-opts.c
> > ===================================================================
> > --- c-family/c-opts.c   (revision 210521)
> > +++ c-family/c-opts.c   (working copy)
> > @@ -906,10 +906,6 @@ c_common_post_options (const char **pfil
> >    if (warn_implicit_function_declaration == -1)
> >      warn_implicit_function_declaration = flag_isoc99;
> >
> > -  /* Declone C++ 'structors if -Os.  */
> > -  if (flag_declone_ctor_dtor == -1)
> > -    flag_declone_ctor_dtor = optimize_size;
> > -
> >    if (cxx_dialect >= cxx11)
> >      {
> >        /* If we're allowing C++0x constructs, don't warn about C++98
> > Index: doc/invoke.texi
> > ===================================================================
> > --- doc/invoke.texi     (revision 210521)
> > +++ doc/invoke.texi     (working copy)
> > @@ -7413,7 +7414,7 @@ clones, which means two copies of the fu
> >  base and complete variants are changed to be thunks that call a common
> >  implementation.
> >
> > -Enabled by @option{-Os}.
> > +Enabled by default.
> >
> >  @item -fdelete-null-pointer-checks
> >  @opindex fdelete-null-pointer-checks
Jakub Jelinek May 19, 2014, 2:48 p.m. UTC | #3
On Mon, May 19, 2014 at 04:45:02PM +0200, Jan Hubicka wrote:
> > On Sun, May 18, 2014 at 9:32 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> > > Hi,
> > > this patch enables -fdeclone-ctor-dtor by default: I believe it is up to the
> > > optimizers to decide when the actual worker body should be inlined into the
> > > thunks.
> > >
> > > Bootstrapped/regtested x86_64-linux, OK?
> > 
> > Please make sure to not enable it for -O0 and -Og at least.
> 
> Hmm, I tought this thunk can be implemented without clobbering debug info - 
> all we need is to arrange it to be abstract and not show in unwind info...

I agree with Richard, you don't want to do this for -O0/-Og.
I don't think debuggers can filter functions from unwind info (they can do
that for inlines, but when it is not inlined...), and it will be a terrible
debugging experience if you see extra frame in there.

	Jakub
diff mbox

Patch

Index: c-family/c.opt
===================================================================
--- c-family/c.opt	(revision 210521)
+++ c-family/c.opt	(working copy)
@@ -904,7 +904,7 @@  C++ ObjC++ Var(flag_deduce_init_list) In
 -fdeduce-init-list	enable deduction of std::initializer_list for a template type parameter from a brace-enclosed initializer-list
 
 fdeclone-ctor-dtor
-C++ ObjC++ Var(flag_declone_ctor_dtor) Init(-1)
+C++ ObjC++ Var(flag_declone_ctor_dtor) Init(1)
 Factor complex constructors and destructors to favor space over speed
 
 fdefault-inline
Index: c-family/c-opts.c
===================================================================
--- c-family/c-opts.c	(revision 210521)
+++ c-family/c-opts.c	(working copy)
@@ -906,10 +906,6 @@  c_common_post_options (const char **pfil
   if (warn_implicit_function_declaration == -1)
     warn_implicit_function_declaration = flag_isoc99;
 
-  /* Declone C++ 'structors if -Os.  */
-  if (flag_declone_ctor_dtor == -1)
-    flag_declone_ctor_dtor = optimize_size;
-
   if (cxx_dialect >= cxx11)
     {
       /* If we're allowing C++0x constructs, don't warn about C++98
Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 210521)
+++ doc/invoke.texi	(working copy)
@@ -7413,7 +7414,7 @@  clones, which means two copies of the fu
 base and complete variants are changed to be thunks that call a common
 implementation.
 
-Enabled by @option{-Os}.
+Enabled by default.
 
 @item -fdelete-null-pointer-checks
 @opindex fdelete-null-pointer-checks