https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123376

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
One thing I should note if plugh has a definition and not just a declaration,
then it works. So it is not being added to the cgraph but after adding it to
the cgraph it is removed as it is "referenced" (directly).


This patch seems to fix it (note it is just a hack):
```
diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc
index 88c1071c8de..28824aca871 100644
--- a/gcc/cgraphunit.cc
+++ b/gcc/cgraphunit.cc
@@ -1411,6 +1411,8 @@ analyze_functions (bool first_time)
              (*debug_hooks->late_global_decl) (node->decl);
            }

+  if (!first_time || in_lto_p
+      || (!flag_generate_lto && !flag_generate_offload))
          node->remove ();
          continue;
        }
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 4906de000e6..f8958a718f7 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -50,6 +50,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "omp-general.h"
 #include "pretty-print-markup.h"
 #include "contracts.h"
+#include "cgraph.h"

 /* The type of functions taking a tree, and some additional data, and
    returning an int.  */
@@ -23203,6 +23204,7 @@ mark_template_arguments_used (tree tmpl, tree args)
       else if (TREE_CODE (arg) == PTRMEM_CST)
        {
          bool ok = mark_used (PTRMEM_CST_MEMBER (arg), tf_none);
+         cgraph_node::get_create (PTRMEM_CST_MEMBER (arg));
          gcc_checking_assert (ok || seen_error ());
        }
       /* A class NTTP argument.  */

```

the pt.cc part adds the method to the cgraph but the cgraphunit.cc disables the
deleting it from the cgraph before the free-lang.

Reply via email to