This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/81679] use attribute unused on function arguments as an optimization hint


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

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Wed, 2 Aug 2017, msebor at gcc dot gnu.org wrote:

> 1) When attribute unused is specified on a function argument of pointer type in
> a declaration of a function, GCC could use that as an indication that the
> argument is, in fact, not used by the implementation of the function and assume
> that the object the pointer points to is unchanged by the function call.

It's peculiar to use the attribute on an argument in a declaration that's 
not a definition, but in definitions it very definitely means *may be 
unused* - for example, the attribute may be present unconditionally for a 
function where the argument might or might not be used, depending on 
various preprocessor conditionals, to avoid needing to replicate those 
conditionals when declaring the argument.  So this would not be a valid 
optimization.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]