]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/ipa-comdats.c
2019-01-09 Sandra Loosemore <sandra@codesourcery.com>
[thirdparty/gcc.git] / gcc / ipa-comdats.c
index a188da094eb9a34b53a3dd8a29994fdfb3f799b5..69cc3f3b907f1e51e8a1272480042fb0c06aa912 100644 (file)
@@ -1,5 +1,5 @@
 /* Localize comdats.
-   Copyright (C) 2014-2015 Free Software Foundation, Inc.
+   Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -52,18 +52,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
-#include "input.h"
-#include "alias.h"
-#include "symtab.h"
 #include "tree.h"
-#include "is-a.h"
-#include "plugin-api.h"
-#include "hard-reg-set.h"
-#include "input.h"
-#include "function.h"
-#include "ipa-ref.h"
-#include "cgraph.h"
 #include "tree-pass.h"
+#include "cgraph.h"
 
 /* Main dataflow loop propagating comdat groups across
    the symbol table.  All references to SYMBOL are examined
@@ -91,7 +82,7 @@ propagate_comdat_group (struct symtab_node *symbol,
          continue;
        }
 
-      /* One COMDAT group can not hold both variables and functions at
+      /* One COMDAT group cannot hold both variables and functions at
         a same time.  For now we just go to BOTTOM, in future we may
         invent special comdat groups for this case.  */
 
@@ -136,7 +127,7 @@ propagate_comdat_group (struct symtab_node *symbol,
 
        if (cgraph_node * cn = dyn_cast <cgraph_node *> (symbol2))
          {
-           /* Thunks can not call across section boundary.  */
+           /* Thunks cannot call across section boundary.  */
            if (cn->thunk.thunk_p)
              newgroup = propagate_comdat_group (symbol2, newgroup, map);
            /* If we see inline clone, its comdat group actually
@@ -220,8 +211,11 @@ set_comdat_group (symtab_node *symbol,
   symtab_node *head = (symtab_node *)head_p;
 
   gcc_assert (!symbol->get_comdat_group ());
-  symbol->set_comdat_group (head->get_comdat_group ());
-  symbol->add_to_same_comdat_group (head);
+  if (symbol->real_symbol_p ())
+    {
+      symbol->set_comdat_group (head->get_comdat_group ());
+      symbol->add_to_same_comdat_group (head);
+    }
   return false;
 }
 
@@ -263,7 +257,7 @@ ipa_comdats (void)
        /* Mark the symbol so we won't waste time visiting it for dataflow.  */
        symbol->aux = (symtab_node *) (void *) 1;
       }
-    /* See symbols that can not be privatized to comdats; that is externally
+    /* See symbols that cannot be privatized to comdats; that is externally
        visible symbols or otherwise used ones.  We also do not want to mangle
        user section names.  */
     else if (symbol->externally_visible
@@ -425,7 +419,7 @@ public:
 bool
 pass_ipa_comdats::gate (function *)
 {
-  return optimize;
+  return HAVE_COMDAT_GROUP;
 }
 
 } // anon namespace