public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Jan Hubicka <hubicka@ucw.cz>, Martin Liska <mliska@suse.cz>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix ICF sem_function::merge (PR target/63892)
Date: Fri, 20 Feb 2015 14:51:00 -0000	[thread overview]
Message-ID: <20150220144838.GD1746@tucnak.redhat.com> (raw)

Hi!

As written in the PR, the sibcall-3.c testcase fails on Darwin, because
!sem_item::target_supports_symbol_aliases_p () and we don't really try
redirect_callers, even when that is the best way to perform ICF (both
original and alias are local).

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2015-02-20  Jakub Jelinek  <jakub@redhat.com>
	    Martin Liska  <mliska@suse.cz>

	PR target/63892
	* ipa-icf.c (sem_function::merge): If DECL_COMDAT_GROUP (alias->decl),
	don't try to create_thunk if stdarg_p.  If
	!sem_item::target_supports_symbol_aliases_p (), similarly, and try to
	redirect_callers if possible.
	(sem_item_optimizer::execute): Call unregister_hooks here...
	(ipa_icf_driver): ... instead of here.

--- gcc/ipa-icf.c
+++ gcc/ipa-icf.c
@@ -651,7 +651,9 @@ sem_function::merge (sem_item *alias_item)
      section (or we risk link failures when section is discarded).  */
   if ((original_address_matters
        && alias_address_matters)
-      || original_discardable)
+      || original_discardable
+      || DECL_COMDAT_GROUP (alias->decl)
+      || !sem_item::target_supports_symbol_aliases_p ())
     {
       create_thunk = !stdarg_p (TREE_TYPE (alias->decl));
       create_alias = false;
@@ -659,6 +661,7 @@ sem_function::merge (sem_item *alias_item)
          the extra thunk wrapper for direct calls.  */
       redirect_callers
 	= (!original_discardable
+	   && !DECL_COMDAT_GROUP (alias->decl)
 	   && alias->get_availability () > AVAIL_INTERPOSABLE
 	   && original->get_availability () > AVAIL_INTERPOSABLE
 	   && !alias->instrumented_version);
@@ -670,13 +673,6 @@ sem_function::merge (sem_item *alias_item)
       redirect_callers = false;
     }
 
-  if (create_alias && (DECL_COMDAT_GROUP (alias->decl)
-		       || !sem_item::target_supports_symbol_aliases_p ()))
-    {
-      create_alias = false;
-      create_thunk = true;
-    }
-
   /* We want thunk to always jump to the local function body
      unless the body is comdat and may be optimized out.  */
   if ((create_thunk || redirect_callers)
@@ -1717,6 +1713,8 @@ void
 sem_item_optimizer::execute (void)
 {
   filter_removed_items ();
+  unregister_hooks ();
+
   build_hash_based_classes ();
 
   if (dump_file)
@@ -2578,7 +2576,6 @@ ipa_icf_driver (void)
   gcc_assert (optimizer);
 
   optimizer->execute ();
-  optimizer->unregister_hooks ();
 
   delete optimizer;
   optimizer = NULL;

	Jakub

             reply	other threads:[~2015-02-20 14:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-20 14:51 Jakub Jelinek [this message]
2015-02-20 16:53 ` Jeff Law
2015-02-21 16:22   ` Iain Sandoe
2015-02-22 12:29     ` Jakub Jelinek

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=20150220144838.GD1746@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=mliska@suse.cz \
    /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).