On Wed, Feb 17, 2021 at 09:34:34AM -0800, H.J. Lu wrote: > -fretain-used-symols. > +/* Add the NAME attribute to *ANODE. */ > + > +static void > +add_attribute (tree *anode, int flags, tree name, tree args, tree ns, > + const bool cxx11_attr_p, > + const struct attribute_spec *spec)
Why do you need this and can't instead do what decl_attributes does e.g. for "noipa" attribute? /* A "noipa" function attribute implies "noinline", "noclone" and "no_icf" for those targets that support it. */ if (TREE_CODE (*node) == FUNCTION_DECL && attributes && lookup_attribute ("noipa", attributes) != NULL && lookup_attribute_spec (get_identifier ("noipa"))) { if (lookup_attribute ("noinline", attributes) == NULL) attributes = tree_cons (get_identifier ("noinline"), NULL, attributes); if (lookup_attribute ("noclone", attributes) == NULL) attributes = tree_cons (get_identifier ("noclone"), NULL, attributes); if (lookup_attribute ("no_icf", attributes) == NULL) attributes = tree_cons (get_identifier ("no_icf"), NULL, attributes); } Of course, for "used" attributes and flag_retain_used_symbols it would need to be DECL_P, but otherwise pretty much the same thing. > --- a/gcc/common.opt > +++ b/gcc/common.opt > @@ -2404,6 +2404,10 @@ frerun-loop-opt > Common Ignore > Does nothing. Preserved for backward compatibility. > > +fretain-used-symols s/symols/symbols/ - many times in the patch. > +@item retain > +@cindex @code{retain} function attribute > +This attribute is the same as the @code{used} attribute, except > +for ELF targets that support the GNU or FreeBSD OSABIs, this attribute I'm not sure "retain" attribute should imply "used", one can always use __attribute__((used, retain)) if one wants both. I think it should only imply the GC avoidance and nothing else. Jakub