public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/51663] Desirable/undesirable elimination of unused variables & functions at -O0, -O0 -flto and -O0 -fwhole-program
Date: Mon, 26 Mar 2012 07:07:00 -0000	[thread overview]
Message-ID: <bug-51663-4-foTw8vCUL5@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-51663-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #9 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-26 07:05:58 UTC ---
(In reply to comment #8)
> The inconsistency should be solved. The question however is what kind of
> behaviour we want at -O0 from LTO.
> 
> It seems to me that at -O0 the LTO/non-LTO output should be as close as
> possible and thus LTO should not privatize symbols and break more silly
> debuggers/tools (this is especially important for SLIM mode).
> 
> We still do renaming of statics and other nasty things, but we should not do
> more than neccesary.
> 
> On the the other hand, I think -fwhole-program should still do privatization.
> This patch implements it.  In addition to this it drops more unobvious
> transformation from -fwhole-program where we bring local COMDAT virtual tables
> and functions w/o address taken since we know duplicating them does not hurt.
> 
> Does this look sane?

Yes.  I think for -O0 -flto we should default to 1:1 partitioning and
_not_ do the renaming of local symbols though ... of course -O0 -flto
does not make too much sense?

> Honza
> 
> Index: ipa.c
> ===================================================================
> --- ipa.c       (revision 185777)
> +++ ipa.c       (working copy)
> @@ -616,7 +616,8 @@ cgraph_externally_visible_p (struct cgra
>    if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
>        && lookup_attribute ("dllexport", DECL_ATTRIBUTES (node->decl)))
>      return true;
> -  if (node->resolution == LDPR_PREVAILING_DEF_IRONLY)
> +  if (node->resolution == LDPR_PREVAILING_DEF_IRONLY
> +      && optimize)
>      return false;
>    /* When doing LTO or whole program, we can bring COMDAT functoins static.
>       This improves code quality and we know we will duplicate them at most
> twice
> @@ -624,11 +625,13 @@ cgraph_externally_visible_p (struct cgra
>        implementing same COMDAT)  */
>    if ((in_lto_p || whole_program)
>        && DECL_COMDAT (node->decl)
> +      && optimize
>        && cgraph_comdat_can_be_unshared_p (node))
>      return false;
> 
>    /* When doing link time optimizations, hidden symbols become local.  */
>    if (in_lto_p
> +      && optimize
>        && (DECL_VISIBILITY (node->decl) == VISIBILITY_HIDDEN
>           || DECL_VISIBILITY (node->decl) == VISIBILITY_INTERNAL)
>        /* Be sure that node is defined in IR file, not in other object
> @@ -681,7 +684,8 @@ varpool_externally_visible_p (struct var
>       This is needed for i.e. references from asm statements.   */
>    if (varpool_used_from_object_file_p (vnode))
>      return true;
> -  if (vnode->resolution == LDPR_PREVAILING_DEF_IRONLY)
> +  if (vnode->resolution == LDPR_PREVAILING_DEF_IRONLY
> +      && optimize)
>      return false;
> 
>    /* As a special case, the COMDAT virutal tables can be unshared.
> @@ -690,6 +694,7 @@ varpool_externally_visible_p (struct var
>       is faster for dynamic linking.  Also this match logic hidding vtables
>       from LTO symbol tables.  */
>    if ((in_lto_p || flag_whole_program)
> +      && optimize
>        && !vnode->force_output
>        && DECL_COMDAT (vnode->decl) && DECL_VIRTUAL_P (vnode->decl))
>      return false;


  parent reply	other threads:[~2012-03-26  7:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-23 11:24 [Bug lto/51663] New: LTO does not reclaim comdat-local statics rguenth at gcc dot gnu.org
2012-01-04 12:50 ` [Bug lto/51663] " rguenth at gcc dot gnu.org
2012-01-04 12:54 ` rguenth at gcc dot gnu.org
2012-02-29 15:58 ` hubicka at gcc dot gnu.org
2012-03-20 16:52 ` hubicka at gcc dot gnu.org
2012-03-24 21:08 ` hubicka at gcc dot gnu.org
2012-03-24 21:13 ` hubicka at gcc dot gnu.org
2012-03-24 22:08 ` hubicka at gcc dot gnu.org
2012-03-25 13:40 ` hubicka at gcc dot gnu.org
2012-03-25 13:52 ` hubicka at gcc dot gnu.org
2012-03-26  7:07 ` rguenth at gcc dot gnu.org [this message]
2012-03-26 10:49 ` [Bug middle-end/51663] Desirable/undesirable elimination of unused variables & functions at -O0, -O0 -flto and -O0 -fwhole-program hubicka at ucw dot cz
2020-03-17  9:42 ` vries at gcc dot gnu.org
2020-03-17 10:33 ` rguenth at gcc dot gnu.org
2020-03-17 10:50 ` vries at gcc dot gnu.org
2020-03-17 12:16 ` rguenth at gcc dot gnu.org
2020-03-17 12:18 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-51663-4-foTw8vCUL5@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).