Patchwork [PR,libmudflap/53359] don't register symbols not emitted

mail settings
Submitter Alexandre Oliva
Date Jan. 18, 2013, 11:14 a.m.
Message ID <orsj5yzqrw.fsf@livre.localdomain>
Download mbox | patch
Permalink /patch/213577/
State New
Headers show


Alexandre Oliva - Jan. 18, 2013, 11:14 a.m.
On Jan 16, 2013, Jan Hubicka <> wrote:

> For 2) the symtab_get_node test seems resonable to me.  It is what
> dwarf2out does, too.  We keep nodes for external vars that are
> refereed but we remove all optimized out nodes.

Since you agreed this was the right approach and richi said he didn't
care much, I went ahead and installed the patch I'd proposed at first.


don't let mudflap register global symbols that won't be emitted

From: Alexandre Oliva <>

for  gcc/ChangeLog

	PR libmudflap/53359
	* tree-mudflap.c (mudflap_finish_file): Skip deferred decls
	not found in the symtab.

 gcc/tree-mudflap.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/gcc/tree-mudflap.c b/gcc/tree-mudflap.c
index 3c866bc..b250bfe 100644
--- a/gcc/tree-mudflap.c
+++ b/gcc/tree-mudflap.c
@@ -1334,6 +1334,16 @@  mudflap_finish_file (void)
           if (! TREE_PUBLIC (obj) && ! TREE_ADDRESSABLE (obj))
+	  /* If we're neither emitting nor referencing the symbol,
+	     don't register it.  We have to register external symbols
+	     if they happen to be in other files not compiled with
+	     mudflap (say system libraries), and we must not register
+	     internal symbols that we don't emit or they'll become
+	     dangling references or force symbols to be emitted that
+	     didn't have to.  */
+	  if (!symtab_get_node (obj))
+	    continue;
           if (! COMPLETE_TYPE_P (TREE_TYPE (obj)))
               warning (OPT_Wmudflap,