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

--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #5)
> The function should probably inherit all of the IPA pure/const/modref
> analysis result, that is all "IPA" state should be copied.  I think we want
> some helper
> here - IPA clone creation must have something, no?

Well, in IPA clones utilize so-called function_summary that is a typical place
where we store analysis results. And we don't typically create a new tree
declarations when we clone cgraph_nodes (clones share the same FE declaration).

However, I noticed we want to do likely something similar to what cp/decl.c
does:

static void
merge_attribute_bits (tree newdecl, tree olddecl)
{
  TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
  TREE_THIS_VOLATILE (olddecl) |= TREE_THIS_VOLATILE (newdecl);
  TREE_NOTHROW (newdecl) |= TREE_NOTHROW (olddecl);
  TREE_NOTHROW (olddecl) |= TREE_NOTHROW (newdecl);
  TREE_READONLY (newdecl) |= TREE_READONLY (olddecl);
  TREE_READONLY (olddecl) |= TREE_READONLY (newdecl);
  DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl);
  DECL_IS_MALLOC (olddecl) |= DECL_IS_MALLOC (newdecl);
  DECL_PURE_P (newdecl) |= DECL_PURE_P (olddecl);
  DECL_PURE_P (olddecl) |= DECL_PURE_P (newdecl);
  DECL_UNINLINABLE (newdecl) |= DECL_UNINLINABLE (olddecl);
  DECL_UNINLINABLE (olddecl) |= DECL_UNINLINABLE (newdecl);
}

...

              /* Merge the noreturn bit.  */
              TREE_THIS_VOLATILE (olddecl) = TREE_THIS_VOLATILE (newdecl);
              TREE_READONLY (olddecl) = TREE_READONLY (newdecl);
              TREE_NOTHROW (olddecl) = TREE_NOTHROW (newdecl);
              DECL_IS_MALLOC (olddecl) = DECL_IS_MALLOC (newdecl);
              DECL_PURE_P (olddecl) = DECL_PURE_P (newdecl);

I can see IPA passes doing similar declaration clonning for VAR_DECLs
(gcc/ipa-param-manipulation.cc, gcc/tree-inline.c).

@Martin: Do we have a declaration cloning code for functions somewhere?

Reply via email to