This is the mail archive of the gcc-patches@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]

Re: genattrtab speedup 4/4


From: "Geert Bosch" <bosch@adacore.com>

Note that this exactly matches semantics for Ada's pragma Pure, so there
is some precedent for such a pragma. Mathematical functions, such as
square
root or even simple integer division are pure, but still may not  return
and
throw an exception or abort. As it is hard to verify that a function
really
returns (see halting problem), these semantics make a lot of sense to  me.
  -Geert

If someone kindly implements such an attribute (such as pure_noreturn/const_noreturn?) there are a *lot* of functions in GCC that can be tagged as such. (Dig dig dig...) here's the message where I discussed the issue originally in 2002 containing some links from 2000: http://gcc.gnu.org/ml/gcc-patches/2002-03/msg01319.html

I actually had a patch to detect const/pure functions and tell the user
via -Wmissing-const/-Wmissing-pure similar to -Wmissing-noreturn.  It would
also warn about bad declarations to address concerns about functions
changing to impure over time and the programmer not realizing they must
remove the attribute.  (Some messages downthread aren't linked by mailer
reference so sort by subject or you'll miss some replies):
http://gcc.gnu.org/ml/gcc-patches/2002-03/msg01371.html

Patch take 2 and more discussion (same problem with thread links):
http://gcc.gnu.org/ml/gcc-patches/2002-03/msg01477.html

There's a lot of interesting stuff about noreturn functions in there.  Even
loops can potentially cause a function to be noreturn.  There was some
disagreement about whether to add a new attribute "maynotreturn", or change
the behavior of attribute "pure".  I don't think consensus was achieved as I
never installed my patch.  How we optimize pure/const functions seven years
later may change opinions on how and whether to proceed.

--Kaveh


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