public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Preudhomme <thomas.preudhomme@foss.arm.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [arm-embedded] [PATCH, GCC/LTO, ping] Fix PR69866: LTO with def for weak alias in regular object file
Date: Tue, 28 Nov 2017 15:49:00 -0000	[thread overview]
Message-ID: <e9051968-7e3d-fee6-c525-16c864dc5d03@foss.arm.com> (raw)
In-Reply-To: <20170615122318.GC84372@kam.mff.cuni.cz>

[-- Attachment #1: Type: text/plain, Size: 657 bytes --]

Hi,

We have decided to apply the forwarded patch to the embedded-7-branch to fix an 
ICE when doing partial LTO with weak symbols.

ChangeLog entry is as follows:

2017-11-28  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	Backport from mainline
	2017-06-15  Jan Hubicka  <hubicka@ucw.cz>
		    Thomas Preud'homme  <thomas.preudhomme@arm.com>

	PR lto/69866
	* lto-symtab.c (lto_symtab_merge_symbols): Drop useless definitions
	that resolved externally.

	Backport from mainline
	2017-06-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	PR lto/69866
	* gcc.dg/lto/pr69866_0.c: New test.
	* gcc.dg/lto/pr69866_1.c: Likewise.


Best regards,

Thomas

[-- Attachment #2: Re: [PATCH, GCC/LTO, ping] Fix PR69866: LTO with def for weak alias in regular object file.eml --]
[-- Type: message/rfc822, Size: 3319 bytes --]

From: Jan Hubicka <hubicka@ucw.cz>
To: Thomas Preudhomme <thomas.preudhomme@foss.arm.com>
Subject: Re: [PATCH, GCC/LTO, ping] Fix PR69866: LTO with def for weak alias in regular object file
Date: Thu, 15 Jun 2017 14:23:19 +0200
Message-ID: <20170615122318.GC84372@kam.mff.cuni.cz>

Hi,
I am testing the following. Let me know if it works for you.

Honza

Index: lto/lto-symtab.c
===================================================================
--- lto/lto-symtab.c	(revision 249213)
+++ lto/lto-symtab.c	(working copy)
@@ -952,6 +952,42 @@
 	      if (tgt)
 		node->resolve_alias (tgt, true);
 	    }
+	  /* If the symbol was preempted outside IR, see if we want to get rid
+	     of the definition.  */
+	  if (node->analyzed
+	      && !DECL_EXTERNAL (node->decl)
+	      && (node->resolution == LDPR_PREEMPTED_REG
+		  || node->resolution == LDPR_RESOLVED_IR
+		  || node->resolution == LDPR_RESOLVED_EXEC
+		  || node->resolution == LDPR_RESOLVED_DYN))
+	    {
+	      DECL_EXTERNAL (node->decl) = 1;
+	      /* If alias to local symbol was preempted by external definition,
+		 we know it is not pointing to the local symbol.  Remove it.  */
+	      if (node->alias
+		  && !node->weakref
+		  && !node->transparent_alias
+		  && node->get_alias_target ()->binds_to_current_def_p ())
+		{
+		  node->alias = false;
+		  node->remove_all_references ();
+		  node->definition = false;
+		  node->analyzed = false;
+		  node->cpp_implicit_alias = false;
+		}
+	      else if (!node->alias
+		       && node->definition
+		       && node->get_availability () <= AVAIL_INTERPOSABLE)
+		{
+		  if ((cnode = dyn_cast <cgraph_node *> (node)) != NULL)
+		    cnode->reset ();
+		  else
+		    {
+		      node->analyzed = node->definition = false;
+		      node->remove_all_references ();
+		    }
+		}
+	    }
 
 	  if (!(cnode = dyn_cast <cgraph_node *> (node))
 	      || !cnode->clone_of

       reply	other threads:[~2017-11-28 15:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170615122318.GC84372@kam.mff.cuni.cz>
2017-11-28 15:49 ` Thomas Preudhomme [this message]
2017-06-18 19:56 Jan Hubicka
2017-06-20 13:20 ` [arm-embedded] " Thomas Preudhomme

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=e9051968-7e3d-fee6-c525-16c864dc5d03@foss.arm.com \
    --to=thomas.preudhomme@foss.arm.com \
    --cc=gcc-patches@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).